代客下单增加扫码选择桌台

This commit is contained in:
YeMingfei666 2024-11-15 15:12:59 +08:00
parent 0d1d353830
commit 03d820bc9a
1 changed files with 86 additions and 30 deletions

View File

@ -269,6 +269,14 @@
return res
}
function returnUrlPar(str) {
let arr = str.split("?")[1].split("&"); //&
let obj = {};
for (let i of arr) {
obj[i.split("=")[0]] = i.split("=")[1]; //===
}
return obj
}
function scanCode() {
//
@ -278,6 +286,24 @@
success: function(res) {
console.log('条码类型:' + res.scanType);
console.log('条码内容:' + res.result);
if (res.result.includes('codeplate?code=')) {
const par = returnUrlPar(res.result)
const tableId = par.code
console.log('par');
console.log(par);
onChooseTable({
tableId
})
} else {
uni.showToast({
icon: 'error',
title: '请扫描正确的桌台码'
})
}
// uni.showModal({
// title:'',
// content:res.result
// })
}
});
}
@ -329,7 +355,7 @@
return v.foods.length
})
data.tabbar = tabbar
nextTick(()=>{
nextTick(() => {
getMenuItemTop()
})
storageManage.cacheGoods(data.tabbar)
@ -450,17 +476,20 @@
})
console.log(res);
if (res && res.content[0]) {
data.table={...res.content[0],...data.table}
data.table = {
...res.content[0],
...data.table
}
}
}
}
let $originGoods = []
let $category = []
async function init() {
if(option.type=='add'){
if (option.type == 'add') {
data.masterId = option.masterId
setTabBar($category, $originGoods, [])
}else{
} else {
const masterRes = await getMasterId()
data.masterId = masterRes.masterId
}
@ -490,7 +519,7 @@
});
$originGoods = goods
console.log(option);
if(option.type=='add'){
if (option.type == 'add') {
cars.length = 0
setTabBar(category, goods, [])
return
@ -506,7 +535,7 @@
setTabBar(category, goods, cars)
return
}
const cartRes = await getCart()
cars.length = 0
const cartArr = getNowCart(cartRes.records)
@ -588,29 +617,56 @@
})
}
async function onChooseTable(item) {
console.log('onChooseTable');
const res = await $returnTableDetail({
tableId: item.tableId,
});
if (!res) {
// #ifdef MP-WEIXIN
uni.showModal({
title: '提示',
content: '桌台不存在或不是该店铺的桌台'
})
// #endif
// #ifndef MP-WEIXIN
infoBox.showToast('桌台不存在或不是该店铺的桌台')
// #endif
return
}
console.log('---table:detail-----');
console.log(res);
if (data.table.tableId || cars.length <= 0) {
data.table = {
...res,
...item
}
return;
}
if (res.status == "unbind") {
return infoBox.showToast('该台桌未绑定,清先去桌台管理里绑定码牌')
}
if (res.status != "idle") {
return infoBox.showToast('该台桌已在使用中')
}
if (res.cartCount > 0) {
setModalShow('clear', true, item)
} else {
await $choseTable({
masterId: data.masterId,
tableId: item.tableId,
isClear: false
});
data.table = item
}
}
function watchChooseTable() {
uni.$off('choose-table')
uni.$on('choose-table', async (item) => {
if (data.table.tableId || cars.length <= 0) {
data.table = item
return;
}
if (item.status != "idle") {
return infoBox.showToast('该台桌已在使用中')
}
const res = await $returnTableDetail({
tableId: item.tableId,
});
if (res.cartCount > 0) {
setModalShow('clear', true, item)
} else {
await $choseTable({
masterId: data.masterId,
tableId: item.tableId,
isClear:false
});
data.table = item
}
uni.$on('choose-table', (item) => {
onChooseTable(item)
})
}
@ -1047,12 +1103,12 @@
}, 10);
return;
}
let arr=[]
let arr = []
rects.forEach((rect) => {
// rects[0].top()
arr.push(rect.top - rects[0].top);
})
data.arr=arr
data.arr = arr
console.log(data.arr);
storageManage.cacheGoodsNode(data.arr)
resolve();
@ -1107,7 +1163,7 @@
})
}
watch(() => data.table.tableId, (newval, oldval) => {
if(option.type!='add'){
if (option.type != 'add') {
onSelTable()
}
})