更新代客下单模块

This commit is contained in:
2024-09-28 15:07:26 +08:00
parent 587965020b
commit b88efd1c6c
5 changed files with 199 additions and 110 deletions

View File

@@ -81,7 +81,7 @@
</scroll-view>
</view>
<view class="bottom w-full">
<my-car @updateNumber="carsNumberChange" :user="data.vipUser" :masterId="data.masterId" :table="data.table"
<my-car @updateNumber="carsNumberChange" :user="data.vipUser" :masterId="data.masterId" :table="data.table"
:data="cars" @clear="onClearCart"></my-car>
</view>
@@ -128,6 +128,12 @@
import {
getNowCart
} from '@/pagesCreateOrder/util.js'
import {
$returnUseType
} from './util.js'
import {
tbShopInfo
} from '@/http/yskApi/user.js'
const cars = reactive([])
const data = reactive({
scrollTop: 0, //tab标题的滚动条位置
@@ -153,7 +159,19 @@
},
})
// 获取账号信息
let $shop=ref({})
async function getTbShopInfo() {
const res = await tbShopInfo()
$shop.value = res
const useType=data.table.status=='using'?data.table.useType:$returnUseType(res)
uni.setStorageSync('useType',useType)
console.log(res);
return res
}
function setTabBar(category, goods, cars) {
@@ -247,6 +265,9 @@
}
//加入购物车
function addCart(par) {
if(!data.table.tableId){
return infoBox.showToast('请先选择台桌!')
}
const submitPar = {
masterId: data.masterId,
tableId: data.table.tableId,
@@ -318,18 +339,8 @@
}
}
async function init() {
getTbShopInfo()
getTableInfo()
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])
}
const categoryRes = await getCategory()
const category = categoryRes.content.reduce((prve, cur) => {
prve.push({
@@ -347,6 +358,21 @@
}
return isShow;
});
if(!data.table.tableId){
//无台桌
setTabBar(category, goods, [])
return
}
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, goods, cars)
@@ -849,12 +875,15 @@
onLoad((opt) => {
console.log(opt)
Object.assign(data.table, opt)
if (!opt.tableId) {
infoBox.showErrorToast('暂不支持不选择台桌下载,请从桌台点餐')
return setTimeout(() => {
go.back()
}, 1500)
if(opt.useType){
uni.setStorageSync('useType',opt.useType)
}
// if (!opt.tableId) {
// infoBox.showErrorToast('暂不支持不选择台桌下载,请从桌台点餐')
// return setTimeout(() => {
// go.back()
// }, 1500)
// }
init()
})
</script>