代客下单增加扫码选择桌台
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
|
||||||
|
// })
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -329,7 +355,7 @@
|
||||||
return v.foods.length
|
return v.foods.length
|
||||||
})
|
})
|
||||||
data.tabbar = tabbar
|
data.tabbar = tabbar
|
||||||
nextTick(()=>{
|
nextTick(() => {
|
||||||
getMenuItemTop()
|
getMenuItemTop()
|
||||||
})
|
})
|
||||||
storageManage.cacheGoods(data.tabbar)
|
storageManage.cacheGoods(data.tabbar)
|
||||||
|
|
@ -450,17 +476,20 @@
|
||||||
})
|
})
|
||||||
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let $originGoods = []
|
let $originGoods = []
|
||||||
let $category = []
|
let $category = []
|
||||||
async function init() {
|
async function init() {
|
||||||
if(option.type=='add'){
|
if (option.type == 'add') {
|
||||||
data.masterId = option.masterId
|
data.masterId = option.masterId
|
||||||
setTabBar($category, $originGoods, [])
|
setTabBar($category, $originGoods, [])
|
||||||
}else{
|
} else {
|
||||||
const masterRes = await getMasterId()
|
const masterRes = await getMasterId()
|
||||||
data.masterId = masterRes.masterId
|
data.masterId = masterRes.masterId
|
||||||
}
|
}
|
||||||
|
|
@ -490,7 +519,7 @@
|
||||||
});
|
});
|
||||||
$originGoods = goods
|
$originGoods = goods
|
||||||
console.log(option);
|
console.log(option);
|
||||||
if(option.type=='add'){
|
if (option.type == 'add') {
|
||||||
cars.length = 0
|
cars.length = 0
|
||||||
setTabBar(category, goods, [])
|
setTabBar(category, goods, [])
|
||||||
return
|
return
|
||||||
|
|
@ -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() {
|
function watchChooseTable() {
|
||||||
uni.$off('choose-table')
|
uni.$off('choose-table')
|
||||||
uni.$on('choose-table', async (item) => {
|
uni.$on('choose-table', (item) => {
|
||||||
if (data.table.tableId || cars.length <= 0) {
|
onChooseTable(item)
|
||||||
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
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1047,12 +1103,12 @@
|
||||||
}, 10);
|
}, 10);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let arr=[]
|
let arr = []
|
||||||
rects.forEach((rect) => {
|
rects.forEach((rect) => {
|
||||||
// 这里减去rects[0].top,是因为第一项顶部可能不是贴到导航栏(比如有个搜索框的情况)
|
// 这里减去rects[0].top,是因为第一项顶部可能不是贴到导航栏(比如有个搜索框的情况)
|
||||||
arr.push(rect.top - rects[0].top);
|
arr.push(rect.top - rects[0].top);
|
||||||
})
|
})
|
||||||
data.arr=arr
|
data.arr = arr
|
||||||
console.log(data.arr);
|
console.log(data.arr);
|
||||||
storageManage.cacheGoodsNode(data.arr)
|
storageManage.cacheGoodsNode(data.arr)
|
||||||
resolve();
|
resolve();
|
||||||
|
|
@ -1107,7 +1163,7 @@
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
watch(() => data.table.tableId, (newval, oldval) => {
|
watch(() => data.table.tableId, (newval, oldval) => {
|
||||||
if(option.type!='add'){
|
if (option.type != 'add') {
|
||||||
onSelTable()
|
onSelTable()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue