增加就餐人数限制处理

This commit is contained in:
YeMingfei666 2024-10-30 14:54:23 +08:00
parent 1f099e2174
commit b6d79c9319
1 changed files with 77 additions and 58 deletions

View File

@ -40,7 +40,7 @@
</view>
</view>
</view>
<!-- <view class="u-p-b-24 u-m-b-24 border-bottom">
<view>就餐类型</view>
<view class="u-m-t-24 u-flex ">
@ -116,7 +116,7 @@
<view class="u-p-b-24 ">
<view class="font-bold">订单备注</view>
<view class="u-m-t-32 u-flex ">
<uni-easyinput type="textarea" v-model="note" placeholder="请输入备注"></uni-easyinput>
<uni-easyinput type="textarea" v-model="note" placeholder="请输入备注"></uni-easyinput>
</view>
</view>
@ -183,7 +183,7 @@
<button class="tag" hover-class="hover-class"
@tap="toggleGoodsItemKey(item,index,'isGift')">{{item.isGift?'取消赠送':'赠送'}}</button>
</view>
<view class="u-flex u-m-r-20 " >
<view class="u-flex u-m-r-20 ">
<button class="tag" hover-class="hover-class"
@tap="toggleGoodsItemKey(item,index,'isPack')">{{item.isPack?'取消打包':'打包'}}</button>
</view>
@ -201,24 +201,24 @@
</view>
<view class="border-bottom">
<template v-if="$seatFee&&$seatFee.totalAmount">
<view class="u-flex u-row-between u-m-t-18 u-p-b-34 ">
<view class="u-flex u-row-between u-m-t-18 u-p-b-34 ">
<view>
<text >桌位费</text>
<text>桌位费</text>
</view>
<view>{{$seatFee.totalAmount||'0.00'}}</view>
</view>
</template>
<template v-if="$packFee>0">
<view class="u-flex u-row-between u-m-t-18 u-p-b-34 ">
<view class="u-flex u-row-between u-m-t-18 u-p-b-34 ">
<view>
<text >打包费</text>
<text>打包费</text>
</view>
<view>{{$packFee||'0.00'}}</view>
</view>
</template>
</view>
<view class="u-flex u-row-right u-m-t-38">
<!-- <template v-if="$shop.registerType=='munchies'">
@ -273,7 +273,9 @@
computed,
watch
} from 'vue';
import {getSafeBottomHeight} from '@/commons/utils/safe-bottom.js'
import {
getSafeBottomHeight
} from '@/commons/utils/safe-bottom.js'
import modelDiscount from './components/discount'
import giveFood from './components/give-food'
import oneRemark from './components/remark'
@ -291,7 +293,9 @@
import {
getNowCart
} from '@/pagesCreateOrder/util.js'
import {hasPermission} from '@/commons/utils/hasPermission.js'
import {
hasPermission
} from '@/commons/utils/hasPermission.js'
const models = new Map();
const modelData = reactive({
data: {},
@ -311,7 +315,7 @@
modelData.selIndex = index
const model = models.get(key)
model && model.open({
remark: modelData.data.note||''
remark: modelData.data.note || ''
})
}
@ -325,7 +329,7 @@
const userNumbers = reactive({
list: new Array(100).fill(1).map((v, index) => {
// return index === 0 ? '' : index + ''
return (index+1)+ '人'
return (index + 1) + '人'
}),
defaultCateIndex: 0,
})
@ -336,15 +340,23 @@
//
async function updateChoseCount() {
console.log($shop.value);
if (!$shop.value.isTableFee&& table.value.tableId) {
const maxCapacity = table.value.tableId ? (table.value.maxCapacity || 0) : 100
if (table.value.tableId && userNumbers.defaultCateIndex * 1 + 1 > maxCapacity) {
uni.showToast({
title: '当前台桌最大人数为: ' + maxCapacity
})
userNumbers.defaultCateIndex=maxCapacity-1
return
}
if (!$shop.value.isTableFee && table.value.tableId) {
//
const res = await Api.$choseCount({
masterId: option.masterId,
tableId: table.value.tableId||'',
num: userNumbers.defaultCateIndex+1,
tableId: table.value.tableId || '',
num: userNumbers.defaultCateIndex * 1 + 1,
})
Object.assign($seatFee, res)
userNumbers.defaultCateIndex = res.totalNumber-1
userNumbers.defaultCateIndex = res.totalNumber - 1
}
}
@ -362,14 +374,15 @@
skuId,
id,
number,
isPack,isGift
isPack,
isGift
} = item
const par = {
cartId:id,
cartId: id,
isPack,
isGift,
masterId: option.masterId,
tableId: table.value.tableId||'',
tableId: table.value.tableId || '',
productId,
num: number,
skuId
@ -377,7 +390,7 @@
par[key] = !item[key]
const res = await Api.$updateCart(par)
goods.list[index][key] = returnBoolean(res[key])
if(key=='isPack'){
if (key == 'isPack') {
getCart()
}
}
@ -400,11 +413,11 @@
],
active: 'dine-in'
})
const $packFee=computed(()=>{
return goods.list.reduce((prve,cur)=>{
return prve+cur.packFee
},0).toFixed(2)
const $packFee = computed(() => {
return goods.list.reduce((prve, cur) => {
return prve + cur.packFee
}, 0).toFixed(2)
})
function chooseUser() {
@ -427,7 +440,7 @@
console.log(option);
const submitPar = {
masterId: option.masterId,
tableId: table.value.tableId||"",
tableId: table.value.tableId || "",
vipUserId: user.value.id ? user.value.id : '',
type: user.value.id ? 0 : 1 //0 1
}
@ -481,16 +494,16 @@
})
const goodsPrice = computed(() => {
const goodsTotalPrice = goods.list.reduce((prve, cur) => {
const tPrice=cur.salePrice * cur.number
const tPrice = cur.salePrice * cur.number
console.log(cur.isPack);
const tpackFee=cur.isPack? cur.packFee*1:0
return prve +(cur.isGift?0:tPrice) +tpackFee
const tpackFee = cur.isPack ? cur.packFee * 1 : 0
return prve + (cur.isGift ? 0 : tPrice) + tpackFee
}, 0)
return (goodsTotalPrice|| 0).toFixed(2)
return (goodsTotalPrice || 0).toFixed(2)
})
const allPrice = computed(() => {
console.log(goodsPrice.value);
const n=goodsPrice.value*1 + $seatFee.totalAmount
const n = goodsPrice.value * 1 + $seatFee.totalAmount
return n.toFixed(2)
// const goodsTotalPrice = goods.list.reduce((prve, cur) => {
// return prve + cur.salePrice * cur.number * (cur.isGift ? 0 : 1)
@ -510,7 +523,7 @@
page: 0,
size: 300,
masterId: option.masterId,
tableId: table.value.tableId||''
tableId: table.value.tableId || ''
}) {
const {
records,
@ -524,10 +537,10 @@
}
goods.list = getNowCart(records)
if (seatFee && seatFee.totalNumber) {
userNumbers.defaultCateIndex = seatFee.totalNumber-1 || 0
userNumbers.defaultCateIndex = seatFee.totalNumber - 1 || 0
Object.assign($seatFee, seatFee)
}else{
$seatFee.totalAmount=0
} else {
$seatFee.totalAmount = 0
}
console.log(userNumbers.defaultCateIndex);
}
@ -550,20 +563,20 @@
note: note.value,
postPay: true,
orderId: '',
tableId: table.value.tableId||''
tableId: table.value.tableId || ''
}) {
if (!$shop.value.isTableFee) {
//
await Api.$choseCount({
masterId: option.masterId,
tableId: table.value.tableId||"",
num: userNumbers.defaultCateIndex+1,
tableId: table.value.tableId || "",
num: userNumbers.defaultCateIndex + 1,
})
}
if ($shop.value.registerType == 'munchies'||eatTypes.active=='takeout') {
const canJiesuan=await hasPermission('允许收款')
if(!canJiesuan){
return
if ($shop.value.registerType == 'munchies' || eatTypes.active == 'takeout') {
const canJiesuan = await hasPermission('允许收款')
if (!canJiesuan) {
return
}
}
// updateChoseCount()
@ -571,21 +584,20 @@
uni.$emit('update:createOrderIndex')
console.log($shop.value);
console.log(res);
if ($shop.value.registerType == 'munchies'||eatTypes.active=='takeout') {
if ($shop.value.registerType == 'munchies' || eatTypes.active == 'takeout') {
//
return go.to('PAGES_ORDER_PAY', {
orderId: res.id,
isNowPay:true
},'redirect'
)
isNowPay: true
}, 'redirect')
} else {
//
console.log(option.isCreateOrderToDetail);
if (option.isCreateOrderToDetail!='0') {
if (option.isCreateOrderToDetail != '0') {
console.log('PAGES_ORDER_DETAIL');
go.to('PAGES_ORDER_DETAIL', {
id: res.id
},'redirect')
}, 'redirect')
} else {
console.log('back');
uni.navigateBack({
@ -616,7 +628,7 @@
cartId: cart.id,
productId: cart.productId,
skuId: cart.skuId,
tableId: option.tableId||"",
tableId: option.tableId || "",
note: e.remark,
num: cart.number // 0
})
@ -634,22 +646,27 @@
onLoad((opt) => {
Object.assign(option, opt)
console.log(option,);
console.log(opt);
if (opt) {
table.value = {
tableId: opt.tableId||'',
...option,
tableId: opt.tableId || '',
name: opt.name
}
userNumbers.list = new Array(opt.maxCapacity?opt.maxCapacity*1:100).fill(1).map((v, index) => {
return (index + 1) + '人'
})
// console.log(userNumbers.list);
}
init()
// updateChoseCount()
})
let bottomHeight=ref(100)
onReady(()=>{
getSafeBottomHeight('safe-bottom').then(res=>{
let bottomHeight = ref(100)
onReady(() => {
getSafeBottomHeight('safe-bottom').then(res => {
console.log(res);
bottomHeight.value=res
bottomHeight.value = res
})
})
@ -668,12 +685,12 @@
uni.setStorageSync("useType", useType);
}
const tableId = useType == 'takeout' ? undefined : table.value.tableId;
if(!goods.list.length){
if (!goods.list.length) {
return
}
const res = await Api.$changeUseType({
useType,
tableId:tableId||'',
tableId: tableId || '',
cartIds: goods.list.map((v) => v.id),
})
getCart()
@ -712,6 +729,7 @@
border-radius: 18rpx;
margin-bottom: 32rpx;
}
.textarea {
border-radius: 12rpx 12rpx 12rpx 12rpx;
padding: 32rpx 0 32rpx 24rpx;
@ -722,6 +740,7 @@
.goods {
// padding-bottom: 30rpx;
border-bottom: 1px dashed #E5E5E5;
.item {
.img {
width: 84rpx;