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

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 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() { function scanCode() {
// //
@ -278,6 +286,24 @@
success: function(res) { success: function(res) {
console.log('条码类型:' + res.scanType); console.log('条码类型:' + res.scanType);
console.log('条码内容:' + res.result); 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
// })
} }
}); });
} }
@ -450,7 +476,10 @@
}) })
console.log(res); console.log(res);
if (res && res.content[0]) { if (res && res.content[0]) {
data.table={...res.content[0],...data.table} data.table = {
...res.content[0],
...data.table
}
} }
} }
} }
@ -588,19 +617,40 @@
}) })
} }
function watchChooseTable() {
uni.$off('choose-table') async function onChooseTable(item) {
uni.$on('choose-table', async (item) => { console.log('onChooseTable');
if (data.table.tableId || cars.length <= 0) {
data.table = item
return;
}
if (item.status != "idle") {
return infoBox.showToast('该台桌已在使用中')
}
const res = await $returnTableDetail({ const res = await $returnTableDetail({
tableId: item.tableId, 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) { if (res.cartCount > 0) {
setModalShow('clear', true, item) setModalShow('clear', true, item)
} else { } else {
@ -611,6 +661,12 @@
}); });
data.table = item data.table = item
} }
}
function watchChooseTable() {
uni.$off('choose-table')
uni.$on('choose-table', (item) => {
onChooseTable(item)
}) })
} }