代客下单增加扫码选择桌台
This commit is contained in:
parent
0d1d353830
commit
03d820bc9a
|
|
@ -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)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue