更新代客下单模块
This commit is contained in:
@@ -24,7 +24,7 @@
|
||||
<view>就餐类型</view>
|
||||
<view class="u-m-t-24 u-flex ">
|
||||
<view class="u-flex color-666">
|
||||
<up-radio-group v-model="eatTypes.active" placement="row">
|
||||
<up-radio-group :disabled="option.type=='add'" v-model="eatTypes.active" placement="row">
|
||||
<up-radio :customStyle="{marginRight: '30px'}" v-for="(item, index) in eatTypes.list"
|
||||
:key="index" :label="item.name" :name="item.value">
|
||||
</up-radio>
|
||||
@@ -75,7 +75,7 @@
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<template v-if="$shop.registerType!='restaurant'">
|
||||
<template v-if="!$shop.isTableFee">
|
||||
<!-- 不免餐位费 -->
|
||||
<view class="block">
|
||||
<view class=" ">
|
||||
@@ -89,7 +89,7 @@
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
||||
|
||||
<view class="block">
|
||||
<view class="u-p-b-24 ">
|
||||
@@ -184,7 +184,9 @@
|
||||
</view>
|
||||
|
||||
<view class="u-flex u-row-right u-m-t-38">
|
||||
<view class="color-main" @tap="showModel('editMoney')">修改</view>
|
||||
<template v-if="$shop.registerType=='munchies'">
|
||||
<view class="color-main" @tap="showModel('editMoney')">修改</view>
|
||||
</template>
|
||||
<view class="u-flex price u-m-l-32">
|
||||
<view class="">实收金额</view>
|
||||
<view class="font-bold u-font-32">¥{{formatPrice(allPrice) }}</view>
|
||||
@@ -242,6 +244,7 @@
|
||||
} from '@/commons/utils/format.js';
|
||||
import color from '@/commons/color.js';
|
||||
import * as Api from '@/http/yskApi/Instead.js'
|
||||
import $storageManage from '@/commons/utils/storageManage.js'
|
||||
import {
|
||||
tbShopInfo
|
||||
} from '@/http/yskApi/user.js'
|
||||
@@ -284,15 +287,17 @@
|
||||
//更新就餐人数
|
||||
async function updateChoseCount() {
|
||||
console.log($shop.value);
|
||||
if($shop.value.registerType!='restaurant'){
|
||||
if (!$shop.value.isTableFee) {
|
||||
//不免餐位费
|
||||
await Api.$choseCount({
|
||||
const res = await Api.$choseCount({
|
||||
masterId: option.masterId,
|
||||
tableId: option.tableId,
|
||||
tableId: table.value.tableId,
|
||||
num: userNumbers.defaultCateIndex,
|
||||
})
|
||||
Object.assign($seatFee, res)
|
||||
userNumbers.defaultCateIndex = res.totalNumber
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function userNumberChange(e) {
|
||||
@@ -310,7 +315,7 @@
|
||||
} = item
|
||||
const par = {
|
||||
masterId: option.masterId,
|
||||
tableId: option.tableId,
|
||||
tableId: table.value.tableId,
|
||||
productId,
|
||||
num: number,
|
||||
skuId
|
||||
@@ -349,14 +354,18 @@
|
||||
...table.value
|
||||
})
|
||||
}
|
||||
|
||||
const option = reactive({
|
||||
masterId: '',
|
||||
tableId: ""
|
||||
})
|
||||
// 监听选择用户事件
|
||||
let user = ref(null)
|
||||
//更新选择用户
|
||||
function setUser(par) {
|
||||
console.log(option);
|
||||
const submitPar = {
|
||||
masterId: option.masterId,
|
||||
tableId: option.tableId,
|
||||
tableId: table.value.tableId,
|
||||
vipUserId: user.value.id ? user.value.id : '',
|
||||
type: user.value.id ? 0 : 1 //0 设置 1 取消
|
||||
}
|
||||
@@ -392,10 +401,7 @@
|
||||
})
|
||||
}
|
||||
|
||||
const option = reactive({
|
||||
masterId: '',
|
||||
tableId: ""
|
||||
})
|
||||
|
||||
const goods = reactive({
|
||||
list: [],
|
||||
sel: 0
|
||||
@@ -413,9 +419,10 @@
|
||||
totalAmount: 0,
|
||||
})
|
||||
const allPrice = computed(() => {
|
||||
return goods.list.reduce((prve, cur) => {
|
||||
const goodsTotalPrice = goods.list.reduce((prve, cur) => {
|
||||
return prve + cur.salePrice * cur.number * (cur.isGift ? 0 : 1)
|
||||
}, 0).toFixed(2)
|
||||
}, 0)
|
||||
return (goodsTotalPrice + $seatFee.totalAmount || 0).toFixed(2)
|
||||
})
|
||||
|
||||
function setGoodsItem(key, val) {
|
||||
@@ -430,12 +437,18 @@
|
||||
page: 0,
|
||||
size: 300,
|
||||
masterId: option.masterId,
|
||||
tableId: option.tableId
|
||||
tableId: table.value.tableId
|
||||
}) {
|
||||
const {
|
||||
records,
|
||||
seatFee
|
||||
} = await Api.getCart(par)
|
||||
if (seatFee && seatFee.useType) {
|
||||
$storageManage.useType(seatFee.useType)
|
||||
// uni.setStorageSync('useType',seatFee.useType);
|
||||
eatTypes.active = seatFee.useType == 'takeout' ? seatFee.useType : seatFee.useType.replace(
|
||||
/-after|-before/g, '');
|
||||
}
|
||||
goods.list = getNowCart(records)
|
||||
if (seatFee && seatFee.totalNumber) {
|
||||
userNumbers.defaultCateIndex = seatFee.totalNumber || 1
|
||||
@@ -445,7 +458,9 @@
|
||||
console.log(goods.list);
|
||||
}
|
||||
|
||||
let $shop = ref()
|
||||
let $shop = ref({
|
||||
registerType: ''
|
||||
})
|
||||
// 获取账号信息
|
||||
async function getTbShopInfo() {
|
||||
const res = await tbShopInfo()
|
||||
@@ -453,7 +468,7 @@
|
||||
console.log(res);
|
||||
return res
|
||||
}
|
||||
|
||||
|
||||
// 创建订单
|
||||
async function createOrder(par = {
|
||||
masterId: option.masterId,
|
||||
@@ -461,29 +476,48 @@
|
||||
note: note.value,
|
||||
postPay: true,
|
||||
orderId: '',
|
||||
tableId: option.tableId
|
||||
tableId: table.value.tableId
|
||||
}) {
|
||||
updateChoseCount()
|
||||
if (!$shop.value.isTableFee) {
|
||||
//不免餐位费
|
||||
await Api.$choseCount({
|
||||
masterId: option.masterId,
|
||||
tableId: table.value.tableId,
|
||||
num: userNumbers.defaultCateIndex,
|
||||
})
|
||||
}
|
||||
// updateChoseCount()
|
||||
const res = await Api.$createOrder(par)
|
||||
console.log($shop.value);
|
||||
if($shop.value.registerType=='munchies'){
|
||||
console.log(res);
|
||||
if ($shop.value.registerType == 'munchies') {
|
||||
//先付
|
||||
return go.to('PAGES_ORDER_DETAIL',{
|
||||
id:res.id
|
||||
return go.to('PAGES_CRESATE_ORDER_PAY', {
|
||||
orderId: res.id
|
||||
})
|
||||
} else {
|
||||
//后付
|
||||
uni.navigateBack({delta:2})
|
||||
// return go.to('PAGES_ORDER_DETAIL', {
|
||||
// id: res.id
|
||||
// })
|
||||
}
|
||||
uni.showToast({
|
||||
title: '提交成功',
|
||||
icon: 'none'
|
||||
})
|
||||
setTimeout(() => {
|
||||
uni.$emit('orderDetail:update')
|
||||
uni.navigateBack({
|
||||
delta: 2
|
||||
})
|
||||
}, 500)
|
||||
// setTimeout(() => {
|
||||
// uni.$emit('orderDetail:update')
|
||||
// uni.navigateBack({
|
||||
// delta: 2
|
||||
// })
|
||||
// }, 500)
|
||||
}
|
||||
|
||||
|
||||
function init(){
|
||||
|
||||
}
|
||||
|
||||
onLoad((opt) => {
|
||||
console.log(opt);
|
||||
Object.assign(option, opt)
|
||||
@@ -493,9 +527,10 @@
|
||||
name: opt.name
|
||||
}
|
||||
}
|
||||
init()
|
||||
getCart()
|
||||
getTbShopInfo()
|
||||
updateChoseCount()
|
||||
// updateChoseCount()
|
||||
})
|
||||
|
||||
async function changeUseType() {
|
||||
@@ -512,8 +547,10 @@
|
||||
useType = `dine-in-${isPayAfter? "after" : "before"}`;
|
||||
uni.setStorageSync("useType", useType);
|
||||
}
|
||||
const tableId = useType=='takeout'?undefined: table.value.tableId;
|
||||
const res = await Api.$changeUseType({
|
||||
useType,
|
||||
tableId,
|
||||
cartIds: goods.list.map((v) => v.id),
|
||||
})
|
||||
return res
|
||||
|
||||
Reference in New Issue
Block a user