代客下单页面增加获取台桌信息接口
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<view class="u-wrap">
|
||||
|
||||
|
||||
<view class="top bg-fff w-full">
|
||||
<template v-if="option.type!='add'">
|
||||
<view class="u-flex u-row-between choose-user" @tap="chooseTable">
|
||||
@@ -15,7 +15,7 @@
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
||||
<!-- <view class="u-flex u-row-between choose-user" @tap="chooseUser">
|
||||
<view>
|
||||
<view v-if="!data.vipUser.id">选择用户</view>
|
||||
@@ -100,14 +100,16 @@
|
||||
<view class="u-font-28 color-666 ">搜索</view>
|
||||
<view class="u-flex u-m-t-20 u-flex-wrap u-row-between">
|
||||
<view class="u-m-b-30" v-for="(goodsItem, goodsIndex) in searchResult" :key="goodsIndex">
|
||||
<goods-item :img="{width:'330rpx',height:'330rpx'}" @chooseGuige="chooseGuige($event,goodsItem.index)"
|
||||
@add="goodsUpdate($event,goodsItem.index,true)" @reduce="goodsUpdate($event,index,false)"
|
||||
:index="goodsItem.goodsIndex" :data="goodsItem"></goods-item>
|
||||
|
||||
<goods-item :img="{width:'330rpx',height:'330rpx'}"
|
||||
@chooseGuige="chooseGuige($event,goodsItem.index)"
|
||||
@add="goodsUpdate($event,goodsItem.index,true)"
|
||||
@reduce="goodsUpdate($event,index,false)" :index="goodsItem.goodsIndex"
|
||||
:data="goodsItem"></goods-item>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
</scroll-view>
|
||||
|
||||
</view>
|
||||
@@ -395,6 +397,7 @@
|
||||
}
|
||||
}
|
||||
let $originGoods = []
|
||||
let $category = []
|
||||
async function init() {
|
||||
const shopInfo = await tbShopInfo()
|
||||
$shop.value = shopInfo
|
||||
@@ -410,7 +413,7 @@
|
||||
});
|
||||
return [...prve, ...cur.childrenList];
|
||||
}, []);
|
||||
console.log(category);
|
||||
$category = category
|
||||
const goodsRes = await getGoods()
|
||||
const goods = goodsRes.records.filter((v) => {
|
||||
let isShow = true;
|
||||
@@ -419,7 +422,7 @@
|
||||
}
|
||||
return isShow;
|
||||
});
|
||||
$originGoods=goods
|
||||
$originGoods = goods
|
||||
if (!data.table.tableId) {
|
||||
//无桌台
|
||||
setTabBar(category, goods, [])
|
||||
@@ -465,14 +468,14 @@
|
||||
function returnSearchGoods() {
|
||||
const newval = searchValue.value
|
||||
let arr = []
|
||||
let goods=[]
|
||||
for(let i in data.tabbar){
|
||||
const goodsArr=data.tabbar[i].foods||[]
|
||||
for(let k in goodsArr){
|
||||
let goods = []
|
||||
for (let i in data.tabbar) {
|
||||
const goodsArr = data.tabbar[i].foods || []
|
||||
for (let k in goodsArr) {
|
||||
goods.push({
|
||||
...goodsArr[k],
|
||||
index:i,
|
||||
goodsIndex:k
|
||||
index: i,
|
||||
goodsIndex: k
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -672,7 +675,7 @@
|
||||
|
||||
function chooseGuige(foodsindex, index) {
|
||||
if (!canAddGoods()) {
|
||||
return infoBox.showToast('清先选择桌台',0.5).then(res=>{
|
||||
return infoBox.showToast('清先选择桌台', 0.5).then(res => {
|
||||
chooseTable()
|
||||
})
|
||||
}
|
||||
@@ -778,7 +781,7 @@
|
||||
}
|
||||
async function goodsUpdate(foodsindex, index, isAdd) {
|
||||
if (!canAddGoods()) {
|
||||
return infoBox.showToast('请先选择桌台',0.5).then(res=>{
|
||||
return infoBox.showToast('请先选择桌台', 0.5).then(res => {
|
||||
chooseTable()
|
||||
})
|
||||
}
|
||||
@@ -977,14 +980,27 @@
|
||||
setUser()
|
||||
})
|
||||
}
|
||||
watch(() => data.table.tableId, (newval) => {
|
||||
console.log(newval);
|
||||
init()
|
||||
watch(() => data.table.tableId, (newval, oldval) => {
|
||||
onSelTable()
|
||||
})
|
||||
async function onSelTable() {
|
||||
const {
|
||||
masterId
|
||||
} = await getMasterId()
|
||||
data.masterId = masterId
|
||||
const cartRes = await getCart()
|
||||
cars.length = 0
|
||||
const cartArr = getNowCart(cartRes.records)
|
||||
for (let i in cartArr) {
|
||||
cars.push(cartArr[i])
|
||||
}
|
||||
setTabBar($category, $originGoods, cars)
|
||||
}
|
||||
onBeforeUnmount(() => {})
|
||||
|
||||
function watchUpdate() {
|
||||
uni.$off('update:createOrderIndex')
|
||||
uni.$off('get:table')
|
||||
uni.$on('update:createOrderIndex', () => {
|
||||
// data.table = {
|
||||
// tableId: ""
|
||||
@@ -993,6 +1009,20 @@
|
||||
console.log('update:createOrderIndex');
|
||||
init()
|
||||
})
|
||||
uni.$on('get:table', () => {
|
||||
console.log('get:table');
|
||||
if (data.table.tableId) {
|
||||
$table.get({
|
||||
qrcode: data.table.tableId
|
||||
}).then(res => {
|
||||
if (res.content[0] && res.content[0].status != 'idle') {
|
||||
data.table = {
|
||||
tableId: ''
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
onShow(() => {
|
||||
// watchChooseuser()
|
||||
@@ -1000,16 +1030,18 @@
|
||||
watchUpdate()
|
||||
})
|
||||
let isCreateOrderToDetail = ref(false)
|
||||
let option={type:''}
|
||||
let option = {
|
||||
type: ''
|
||||
}
|
||||
onLoad((opt) => {
|
||||
console.log(opt)
|
||||
option=opt
|
||||
option = opt
|
||||
Object.assign(data.table, opt)
|
||||
if (opt.useType) {
|
||||
uni.setStorageSync('useType', opt.useType)
|
||||
}
|
||||
uni.setNavigationBarTitle({
|
||||
title:(opt&&opt.type=='add')?'顾客加菜':'代客下单'
|
||||
title: (opt && opt.type == 'add') ? '顾客加菜' : '代客下单'
|
||||
})
|
||||
if (JSON.stringify(opt) == '{}') {
|
||||
isCreateOrderToDetail.value = true
|
||||
|
||||
Reference in New Issue
Block a user