更新代客下单模块
This commit is contained in:
@@ -55,7 +55,7 @@
|
||||
<view>¥</view>
|
||||
<view>{{allPrice}}</view>
|
||||
</view>
|
||||
<my-button shape="circle" height="80" width="220" @tap="toConfimOrder">去下单</my-button>
|
||||
<my-button shape="circle" height="80" width="220" @tap="toConfimOrder">{{table.type=='add'?'确认加菜':'去下单'}} </my-button>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -1,52 +1,74 @@
|
||||
//根据店铺信息返回是否是后付款
|
||||
export function $trturnPayAfter(shop) {
|
||||
//munchies 先付 restaurant 后付
|
||||
const payAfter = shop.registerType == "munchies" ? false : true;
|
||||
return payAfter
|
||||
}
|
||||
//根据店铺信息返回就餐类型
|
||||
export function $returnUseType(shop, useType) {
|
||||
//是否是后付款
|
||||
const payAfter = $trturnPayAfter(shop)
|
||||
let result = "takeout";
|
||||
if (useType == "takeout") {
|
||||
result = 'takeout'
|
||||
} else {
|
||||
//堂食
|
||||
result = `dine-in-${payAfter ? "after" : "before"}`;
|
||||
}
|
||||
return result
|
||||
}
|
||||
//判断商品是否可以下单
|
||||
export function isCanBuy(goods,isStock) {
|
||||
return goods.isGrounding && goods.isPauseSale == 0 && (isStock?goods.stockNumber > 0:true) ;
|
||||
export function isCanBuy(goods, isStock) {
|
||||
return goods.isGrounding && goods.isPauseSale == 0 && (isStock ? goods.stockNumber > 0 : true);
|
||||
}
|
||||
|
||||
|
||||
// 一个数组是否包含另外一个数组全部元素
|
||||
function arrayContainsAll(arr1, arr2) {
|
||||
for (let i = 0; i < arr2.length; i++) {
|
||||
if (!arr1.includes(arr2[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
for (let i = 0; i < arr2.length; i++) {
|
||||
if (!arr1.includes(arr2[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//n项 n-1项组合,生成全部结果
|
||||
function generateCombinations(arr, k) {
|
||||
let result = [];
|
||||
let result = [];
|
||||
|
||||
function helper(index, current) {
|
||||
if (current.length === k) {
|
||||
result.push(current.slice()); // 使用slice()来避免直接修改原始数组
|
||||
} else {
|
||||
for (let i = index; i < arr.length; i++) {
|
||||
current.push(arr[i]); // 将当前元素添加到组合中
|
||||
helper(i + 1, current); // 递归调用,索引增加以避免重复选择相同的元素
|
||||
current.pop(); // 回溯,移除当前元素以便尝试其他组合
|
||||
}
|
||||
}
|
||||
}
|
||||
function helper(index, current) {
|
||||
if (current.length === k) {
|
||||
result.push(current.slice()); // 使用slice()来避免直接修改原始数组
|
||||
} else {
|
||||
for (let i = index; i < arr.length; i++) {
|
||||
current.push(arr[i]); // 将当前元素添加到组合中
|
||||
helper(i + 1, current); // 递归调用,索引增加以避免重复选择相同的元素
|
||||
current.pop(); // 回溯,移除当前元素以便尝试其他组合
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
helper(0, []); // 从索引0开始,初始空数组作为起点
|
||||
return result;
|
||||
helper(0, []); // 从索引0开始,初始空数组作为起点
|
||||
return result;
|
||||
}
|
||||
|
||||
function returnReverseVal(val, isReturnString = true) {
|
||||
const isBol = typeof val === "boolean";
|
||||
const isString = typeof val === "string";
|
||||
let reverseNewval = "";
|
||||
if (isBol) {
|
||||
reverseNewval = !val;
|
||||
}
|
||||
if (isString) {
|
||||
reverseNewval = val === "true" ? "false" : "true";
|
||||
}
|
||||
return reverseNewval;
|
||||
const isBol = typeof val === "boolean";
|
||||
const isString = typeof val === "string";
|
||||
let reverseNewval = "";
|
||||
if (isBol) {
|
||||
reverseNewval = !val;
|
||||
}
|
||||
if (isString) {
|
||||
reverseNewval = val === "true" ? "false" : "true";
|
||||
}
|
||||
return reverseNewval;
|
||||
}
|
||||
|
||||
export default{
|
||||
isCanBuy,arrayContainsAll,generateCombinations,returnReverseVal
|
||||
export default {
|
||||
isCanBuy,
|
||||
arrayContainsAll,
|
||||
generateCombinations,
|
||||
returnReverseVal,$returnUseType
|
||||
}
|
||||
Reference in New Issue
Block a user