代客下单更新部分页面跳转请求。页面展示
This commit is contained in:
@@ -25,7 +25,8 @@
|
||||
<view class="u-flex color-666">
|
||||
<radio-group @change="radioGroupChange">
|
||||
<label class="radio u-m-r-60" v-for="(item,index) in eatTypes.list" :key="index">
|
||||
<radio :value="''+index" :checked="index === eatTypes.active" class="scale7 " />
|
||||
<radio :value="''+item.value" :checked="item.value == eatTypes.active"
|
||||
class="scale7 " />
|
||||
<text>{{item.label}}</text>
|
||||
</label>
|
||||
</radio-group>
|
||||
@@ -176,10 +177,10 @@
|
||||
|
||||
<view class="u-flex u-row-between u-m-t-30 u-p-b-34 border-bottom">
|
||||
<view>
|
||||
<text v-if="eatTypes.active==1">包装费</text>
|
||||
<text v-if="eatTypes.active==2">包装费</text>
|
||||
<text v-else>桌位费</text>
|
||||
</view>
|
||||
<view>¥0.00</view>
|
||||
<view>¥{{$seatFee.totalAmount||'0.00'}}</view>
|
||||
</view>
|
||||
|
||||
<view class="u-flex u-row-right u-m-t-38">
|
||||
@@ -218,13 +219,15 @@
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
onLoad,onShow
|
||||
onLoad,
|
||||
onShow
|
||||
} from '@dcloudio/uni-app'
|
||||
import {
|
||||
ref,
|
||||
onBeforeUnmount,
|
||||
reactive,
|
||||
computed
|
||||
computed,
|
||||
watch
|
||||
} from 'vue';
|
||||
import myButton from '@/components/my-components/my-button'
|
||||
import modelDiscount from './components/discount'
|
||||
@@ -237,9 +240,11 @@
|
||||
} from '@/commons/utils/format.js';
|
||||
import color from '@/commons/color.js';
|
||||
import * as Api from '@/http/yskApi/Instead.js'
|
||||
import {getNowCart} from '@/pagesCreateOrder/util.js'
|
||||
const models = new Map();
|
||||
//备注
|
||||
let note=ref('')
|
||||
let note = ref('')
|
||||
|
||||
function setModel(el) {
|
||||
if (el && el.$attrs['name']) {
|
||||
models.set(el.$attrs['name'], el);
|
||||
@@ -264,6 +269,18 @@
|
||||
}),
|
||||
defaultCateIndex: 1,
|
||||
})
|
||||
watch(() => userNumbers.defaultCateIndex, (newval) => {
|
||||
updateChoseCount()
|
||||
})
|
||||
|
||||
//更新就餐人数
|
||||
async function updateChoseCount(){
|
||||
await Api.$choseCount({
|
||||
masterId: option.masterId,
|
||||
tableId: option.tableId,
|
||||
num: userNumbers.defaultCateIndex,
|
||||
})
|
||||
}
|
||||
|
||||
function userNumberChange(e) {
|
||||
userNumbers.defaultCateIndex = e.detail.value
|
||||
@@ -299,11 +316,11 @@
|
||||
const eatTypes = reactive({
|
||||
list: [{
|
||||
label: '堂食',
|
||||
value: '1'
|
||||
value: 1
|
||||
},
|
||||
{
|
||||
label: '自取',
|
||||
value: '2'
|
||||
value: 2
|
||||
},
|
||||
],
|
||||
active: 1
|
||||
@@ -311,7 +328,6 @@
|
||||
|
||||
function radioGroupChange(e) {
|
||||
eatTypes.active = e.detail.value
|
||||
console.log(eatTypes.active);
|
||||
}
|
||||
|
||||
|
||||
@@ -320,7 +336,7 @@
|
||||
}
|
||||
|
||||
function chooseTable() {
|
||||
go.to('PAGES_CHOOSE_TABLE',{
|
||||
go.to('PAGES_CHOOSE_TABLE', {
|
||||
...table.value
|
||||
})
|
||||
}
|
||||
@@ -336,6 +352,16 @@
|
||||
})
|
||||
}
|
||||
let table = ref(null)
|
||||
//监听桌台改变
|
||||
watch(() => table.value, (newval, oldval) => {
|
||||
if (newval && oldval) {
|
||||
Api.$choseTable({
|
||||
orderId: 4462,
|
||||
oldTableId: oldval.tableId,
|
||||
newTableId: newval.tableId,
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
function watchChooseTable() {
|
||||
uni.$off('choose-table')
|
||||
@@ -344,7 +370,7 @@
|
||||
console.log(table.value);
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
const option = reactive({
|
||||
masterId: '',
|
||||
tableId: ""
|
||||
@@ -360,6 +386,11 @@
|
||||
}, 0)
|
||||
return result
|
||||
})
|
||||
//餐位费
|
||||
const $seatFee = reactive({
|
||||
totalNumber: 0,
|
||||
totalAmount: 0,
|
||||
})
|
||||
const allPrice = computed(() => {
|
||||
return goods.list.reduce((prve, cur) => {
|
||||
return prve + cur.salePrice * cur.number * (cur.isGift ? 0 : 1)
|
||||
@@ -380,43 +411,49 @@
|
||||
masterId: option.masterId,
|
||||
tableId: option.tableId
|
||||
}) {
|
||||
const res = await Api.getCart(par)
|
||||
goods.list = res.records.map(item => {
|
||||
return {
|
||||
...item,
|
||||
isPack: returnBoolean(item.isPack),
|
||||
isGift: returnBoolean(item.isGift)
|
||||
}
|
||||
})
|
||||
const {
|
||||
records,
|
||||
seatFee
|
||||
} = await Api.getCart(par)
|
||||
goods.list =getNowCart(records)
|
||||
if(seatFee&&seatFee.totalNumber){
|
||||
userNumbers.defaultCateIndex = seatFee.totalNumber || 1
|
||||
Object.assign($seatFee, seatFee)
|
||||
}
|
||||
|
||||
console.log(goods.list);
|
||||
}
|
||||
|
||||
|
||||
// 创建订单
|
||||
async function createOrder(par = {
|
||||
masterId: option.masterId,
|
||||
vipUserId:user.value?user.value.id:'',
|
||||
note:note.value,
|
||||
postPay:true,
|
||||
orderId:'',
|
||||
vipUserId: user.value ? user.value.id : '',
|
||||
note: note.value,
|
||||
postPay: true,
|
||||
orderId: '',
|
||||
tableId: option.tableId
|
||||
}) {
|
||||
updateChoseCount()
|
||||
const res = await Api.$createOrder(par)
|
||||
uni.showToast({
|
||||
title:'提交成功',
|
||||
icon:'none'
|
||||
title: '提交成功',
|
||||
icon: 'none'
|
||||
})
|
||||
setTimeout(()=>{
|
||||
uni.navigateBack({delta:2})
|
||||
},500)
|
||||
setTimeout(() => {
|
||||
uni.$emit('orderDetail:update')
|
||||
uni.navigateBack({
|
||||
delta: 2
|
||||
})
|
||||
}, 500)
|
||||
}
|
||||
|
||||
|
||||
onLoad((opt) => {
|
||||
console.log(opt);
|
||||
Object.assign(option, opt)
|
||||
if(opt){
|
||||
table.value={
|
||||
tableId:opt.tableId,
|
||||
name:opt.tableName
|
||||
if (opt) {
|
||||
table.value = {
|
||||
tableId: opt.tableId,
|
||||
name: opt.tableName
|
||||
}
|
||||
}
|
||||
getCart()
|
||||
@@ -424,11 +461,10 @@
|
||||
onBeforeUnmount(() => {
|
||||
|
||||
})
|
||||
onShow(()=>{
|
||||
onShow(() => {
|
||||
watchChooseuser()
|
||||
watchChooseTable()
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
Reference in New Issue
Block a user