优化预下单选择人数

This commit is contained in:
gyq
2025-12-04 09:39:53 +08:00
parent 00c5987ccc
commit ca829d7f00
6 changed files with 573 additions and 340 deletions

View File

@@ -513,6 +513,42 @@
<recommendGoodsModal v-if="isDataLoaded" @onBuyClick="onBuyClick"></recommendGoodsModal>
<goodsModal></goodsModal>
<xbSwiperPreview :visable="showPrveImg" :imgs="prveImgsList" @update:visable="showPrveImg = $event"></xbSwiperPreview>
<!-- 显示选择人数popup -->
<u-popup mode="bottom" :safe-area-inset-bottom="false" :show="showTableInfoPeopleNumPopup">
<view class="select_num_wrap">
<image class="top_bg" src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/order/orderAMeal.png" mode="aspectFill"></image>
<view class="sn-bnottom">
<view class="sn-header">
<text class="t1">请选择就餐人数</text>
<text class="t2">桌号{{ shopTable.name }}</text>
</view>
<view class="sn-num-wrap">
<view class="sn-num">
<view
class="item"
:class="{ active: tableInfoPeopleActive == index }"
v-for="(item, index) in 10"
:key="item"
@click="tableInfoPeopleNumHandle(item, index)"
>
<text class="t">{{ item }}</text>
</view>
</view>
<view class="input">
<u-input v-model="tableInfoPeopleNum" :maxlength="2" placeholder="请输入自定义人数" clearable @change="tableInfoPeopleNumInput"></u-input>
</view>
</view>
<view class="sn-footer-wrap">
<view class="btn">
<u-button plain shape="circle" @click="closeTableInfoPeopleNum">取消</u-button>
</view>
<view class="btn">
<u-button type="primary" shape="circle" @click="tableInfoPeopleNumConfirm">确认</u-button>
</view>
</view>
</view>
</view>
</u-popup>
</view>
</template>
@@ -541,6 +577,7 @@ import Loading from '@/components/Loading.vue';
import dayjs from 'dayjs';
import isBetween from 'dayjs/plugin/isBetween';
dayjs.extend(isBetween);
import { filterNumberInput } from '@/utils/util.js';
//点单智能推荐
function onBuyClick(item) {
@@ -1461,8 +1498,19 @@ async function onMessage(Message) {
// 转桌成功
if (Message.operate_type == 'rottable' && Message.status == 1) {
console.log('转桌成功了');
uni.showToast({
title: '扫码成功,请下单',
icon: 'none'
});
orderType.value = 'scan';
uni.cache.set('tableCode', Message.data.new_table_code);
if (showTableInfoPeopleNumPopup.value == true) {
showTableInfoPeopleNumPopup.value = false;
}
websocketsendMessage(options.initMessage);
}
@@ -1860,27 +1908,78 @@ provide('shopInfo', shopInfo);
const orderType = ref('scan');
// 扫码下单
// 台桌信息
const showTableInfoPeopleNumPopup = ref(false);
const tableInfo = ref('');
// 选择的人数
const tableInfoPeopleActive = ref(-1);
const tableInfoPeopleNum = ref('');
// 选择人数
function tableInfoPeopleNumHandle(num, index) {
tableInfoPeopleActive.value = index;
tableInfoPeopleNum.value = num;
}
// 人数输入框
function tableInfoPeopleNumInput(e) {
tableInfoPeopleActive.value = -1;
setTimeout(() => {
tableInfoPeopleNum.value = filterNumberInput(e, 1);
}, 50);
}
// 取消选择人数
function closeTableInfoPeopleNum() {
showTableInfoPeopleNumPopup.value = false;
tableInfoPeopleActive.value = -1;
tableInfoPeopleNum.value = '';
}
// 确认选择人数
function tableInfoPeopleNumConfirm() {
uni.cache.set('dinersNum', tableInfoPeopleNum.value);
startUseTable();
}
// 开始换桌
function startUseTable() {
const shopInfo = uni.cache.get('shopInfo');
const oldTableCode = uni.cache.get('tableCode');
const cartIds = cartStore.carts.map((item) => item.id);
const data = {
type: 'onboc',
operate_type: 'rottable',
account: shopInfo.phone,
table_code: oldTableCode,
new_table_code: tableInfo.value.tableCode,
cart_id: cartIds,
shop_id: shopInfo.id
};
websocketsendMessage(data);
}
// 预点单扫码下单
function beforehandHandle() {
uni.scanCode({
success(res) {
const shopInfo = uni.cache.get('shopInfo');
const oldTableCode = uni.cache.get('tableCode');
const newTableCode = userStore.getQueryString(res.result, 'code');
const cartIds = cartStore.carts.map((item) => item.id);
success: async (res) => {
try {
const newTableCode = userStore.getQueryString(res.result, 'code');
const data = {
type: 'onboc',
operate_type: 'rottable',
account: shopInfo.phone,
table_code: oldTableCode,
new_table_code: newTableCode,
cart_id: cartIds,
shop_id: shopInfo.id
};
console.log('scanCode.data===', data);
// return;
websocketsendMessage(data);
if (shopInfo.isTableFee) {
startUseTable();
} else {
await userStore.actionsproductqueryShop(newTableCode);
tableInfo.value = uni.cache.get('shopTable');
showTableInfoPeopleNumPopup.value = true;
}
} catch (error) {
console.log(error);
}
}
});
}
@@ -2961,4 +3060,81 @@ function toHistory() {
z-index: 9;
color: #fff;
}
.select_num_wrap {
width: 100vw;
height: 100vh;
position: relative;
.top_bg {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
z-index: 1;
}
.sn-bnottom {
width: 90vw;
border-radius: 20upx;
background-color: #fff;
position: absolute;
left: 5vw;
bottom: 20vw;
z-index: 2;
.sn-header {
height: 120upx;
display: flex;
align-items: center;
justify-content: space-between;
border-bottom: 1px solid #ececec;
padding: 0 28upx;
.t1 {
color: #333;
font-size: 32upx;
}
.t2 {
color: #999;
font-size: 28upx;
}
}
.sn-num-wrap {
padding: 38upx 28upx;
border-bottom: 1px solid #ececec;
.sn-num {
display: grid;
grid-template-columns: repeat(5, 1fr);
gap: 14px;
.item {
height: 40px;
border-radius: 6px;
background-color: #fef4eb;
display: flex;
align-items: center;
justify-content: center;
&.active {
background-color: #e8ad7b;
.t {
color: #fff;
}
}
.t {
color: #333333;
font-size: 32upx;
}
}
}
.input {
display: flex;
padding-top: 28upx;
}
}
.sn-footer-wrap {
display: flex;
gap: 28upx;
padding: 28upx;
.btn {
flex: 1;
}
}
}
}
</style>