修复:

代客下单支付完订单号未将购物车置空
未将台桌置空
This commit is contained in:
YeMingfei666 2024-10-10 17:09:35 +08:00
parent 35d5dc3d32
commit 8361ec77ec
2 changed files with 69 additions and 56 deletions

View File

@ -145,10 +145,12 @@
content content
} = await $table.get(query) } = await $table.get(query)
tables.hasAjax = true tables.hasAjax = true
content = content.filter(v => v.status == 'idle') content = content.filter(v =>{
return v.status == 'idle'||(v.status=='using')
})
console.log(content );
tables.list = content tables.list = content
tables.selIndex = content.findIndex(v => v.tableId == option.tableId) tables.selIndex = content.findIndex(v => v.tableId == option.tableId)
console.log(tables.selIndex );
tables.originList = content tables.originList = content
} }
async function getArea() { async function getArea() {

View File

@ -35,8 +35,7 @@
<view class="search u-flex u-col-center "> <view class="search u-flex u-col-center ">
<view class="u-flex-1"> <view class="u-flex-1">
<uni-search-bar bgColor="#F9F9F9" cancelButton="none" placeholder="搜索店内商品" @confirm="search" <uni-search-bar bgColor="#F9F9F9" cancelButton="none" placeholder="搜索店内商品" @confirm="search"
@clear="clearSearch" @clear="clearSearch" v-model="searchValue">
v-model="searchValue">
</uni-search-bar> </uni-search-bar>
</view> </view>
<view class="u-flex"> <view class="u-flex">
@ -46,8 +45,8 @@
</view> </view>
<template v-if="!isSearch"> <template v-if="!isSearch">
<view class="u-menu-wrap"> <view class="u-menu-wrap">
<scroll-view scroll-y scroll-with-animation class="u-tab-view menu-scroll-view" :scroll-top="data.scrollTop" <scroll-view scroll-y scroll-with-animation class="u-tab-view menu-scroll-view"
:scroll-into-view="data.itemId"> :scroll-top="data.scrollTop" :scroll-into-view="data.itemId">
<view v-for="(item,index) in data.tabbar" :key="index" class="u-tab-item" <view v-for="(item,index) in data.tabbar" :key="index" class="u-tab-item"
:class="[data.current == index ? 'u-tab-item-active' : '']" @tap.stop="swichMenu(index)"> :class="[data.current == index ? 'u-tab-item-active' : '']" @tap.stop="swichMenu(index)">
<text class="u-line-1">{{item.name}}</text> <text class="u-line-1">{{item.name}}</text>
@ -58,7 +57,7 @@
<view class="page-view u-p-l-24"> <view class="page-view u-p-l-24">
<view class="list-tight-top"> <view class="list-tight-top">
<template v-if="lingshi.show"> <template v-if="lingshi.show">
<view id="lingshi" class="lingshi" @tap="toLinshi" > <view id="lingshi" class="lingshi" @tap="toLinshi">
<uni-icons type="plus-filled" size="24" :color="color.ColorMain"></uni-icons> <uni-icons type="plus-filled" size="24" :color="color.ColorMain"></uni-icons>
<view class="u-m-t-24 color-main">临时菜</view> <view class="u-m-t-24 color-main">临时菜</view>
</view> </view>
@ -67,7 +66,8 @@
<view style="height: 24px;"></view> <view style="height: 24px;"></view>
</template> </template>
</view> </view>
<view class="class-item" :id="'item' + index" v-for="(item , index) in data.tabbar" :key="index"> <view class="class-item" :id="'item' + index" v-for="(item , index) in data.tabbar"
:key="index">
<view class="item-title"> <view class="item-title">
<text>{{item.name}}</text> <text>{{item.name}}</text>
</view> </view>
@ -76,7 +76,7 @@
<goods-item @chooseGuige="chooseGuige($event,index)" <goods-item @chooseGuige="chooseGuige($event,index)"
@add="goodsUpdate($event,index,true)" @reduce="goodsUpdate($event,index,false)" @add="goodsUpdate($event,index,true)" @reduce="goodsUpdate($event,index,false)"
:index="goodsIndex" :data="goodsItem"></goods-item> :index="goodsIndex" :data="goodsItem"></goods-item>
</view> </view>
<!-- <template v-if="item.name==='附加费'"> <!-- <template v-if="item.name==='附加费'">
<view class="addCai" @tap="surchargeShow"> <view class="addCai" @tap="surchargeShow">
@ -95,10 +95,10 @@
11 11
</view> </view>
</template> </template>
<view class="bottom w-full"> <view class="bottom w-full">
<my-car :isCreateOrderToDetail="isCreateOrderToDetail" @updateNumber="carsNumberChange" :user="data.vipUser" :masterId="data.masterId" :table="data.table" <my-car :isCreateOrderToDetail="isCreateOrderToDetail" @updateNumber="carsNumberChange" :user="data.vipUser"
:data="cars" @clear="onClearCart"></my-car> :masterId="data.masterId" :table="data.table" :data="cars" @clear="onClearCart"></my-car>
</view> </view>
<!-- 选择规格 --> <!-- 选择规格 -->
@ -113,7 +113,9 @@
<script setup> <script setup>
import _ from 'lodash'; import _ from 'lodash';
import * as Api from '@/http/yskApi/Instead.js' import * as Api from '@/http/yskApi/Instead.js'
import {$table} from '@/http/yskApi/table.js' import {
$table
} from '@/http/yskApi/table.js'
import { import {
$tbShopCategory $tbShopCategory
} from '@/http/yskApi/goods.js' } from '@/http/yskApi/goods.js'
@ -134,7 +136,8 @@
computed, computed,
reactive, reactive,
ref, ref,
nextTick,getCurrentInstance , nextTick,
getCurrentInstance,
watch watch
} from 'vue'; } from 'vue';
import myCar from './components/car' import myCar from './components/car'
@ -151,15 +154,15 @@
} from '@/http/yskApi/user.js' } from '@/http/yskApi/user.js'
const instance = getCurrentInstance(); const instance = getCurrentInstance();
// //
const lingshi=reactive({ const lingshi = reactive({
show:false show: false
}) })
// //
const extraFee=reactive({ const extraFee = reactive({
show:false show: false
}) })
const cars = reactive([]) const cars = reactive([])
const data = reactive({ const data = reactive({
scrollTop: 0, //tab scrollTop: 0, //tab
@ -185,21 +188,21 @@
}, },
}) })
// //
let $shop=ref({}) let $shop = ref({})
async function getTbShopInfo() { async function getTbShopInfo() {
const res = await tbShopInfo() const res = await tbShopInfo()
$shop.value = res $shop.value = res
const useType=data.table.status=='using'?data.table.useType:$returnUseType(res) const useType = data.table.status == 'using' ? data.table.useType : $returnUseType(res)
uni.setStorageSync('useType',useType) uni.setStorageSync('useType', useType)
console.log(res); console.log(res);
return res return res
} }
function setTabBar(category, goods, cars) { function setTabBar(category, goods, cars) {
const goodsCategoryMap = goods.reduce((prve, cur) => { const goodsCategoryMap = goods.reduce((prve, cur) => {
@ -287,7 +290,7 @@
} }
// //
function addCart(par) { function addCart(par) {
if(!data.table.tableId){ if (!data.table.tableId) {
return infoBox.showToast('请先选择桌台!') return infoBox.showToast('请先选择桌台!')
} }
const submitPar = { const submitPar = {
@ -353,18 +356,20 @@
// //
async function getTableInfo(){ async function getTableInfo() {
const res=await $table.get({qrcode:data.table.tableId}) const res = await $table.get({
qrcode: data.table.tableId
})
console.log(res); console.log(res);
if(res&&res.content[0]){ if (res && res.content[0]) {
// data.table=res.content[0] // data.table=res.content[0]
} }
} }
async function init() { async function init() {
const shopInfo = await tbShopInfo() const shopInfo = await tbShopInfo()
$shop.value = shopInfo $shop.value = shopInfo
const useType=data.table.status=='using'?data.table.useType:$returnUseType(shopInfo) const useType = data.table.status == 'using' ? data.table.useType : $returnUseType(shopInfo)
uni.setStorageSync('useType',useType) uni.setStorageSync('useType', useType)
console.log(shopInfo); console.log(shopInfo);
getTableInfo() getTableInfo()
const categoryRes = await getCategory() const categoryRes = await getCategory()
@ -384,10 +389,10 @@
} }
return isShow; return isShow;
}); });
if(!data.table.tableId){ if (!data.table.tableId) {
// //
setTabBar(category, goods, []) setTabBar(category, goods, [])
return return
} }
const { const {
masterId masterId
@ -423,16 +428,18 @@
let searchValue = ref('') let searchValue = ref('')
let isSearch=ref(false) let isSearch = ref(false)
function search() { function search() {
// isSearch.value=true // isSearch.value=true
console.log(searchValue.value); console.log(searchValue.value);
console.log(data.tabbar ); console.log(data.tabbar);
} }
function clearSearch(){
function clearSearch() {
// isSearch.value=false // isSearch.value=false
} }
function chooseUser() { function chooseUser() {
go.to('PAGES_CHOOSE_USER') go.to('PAGES_CHOOSE_USER')
} }
@ -608,7 +615,7 @@
} }
function chooseGuige(foodsindex, index) { function chooseGuige(foodsindex, index) {
if(!canAddGoods()){ if (!canAddGoods()) {
return infoBox.showToast('清先选择桌台') return infoBox.showToast('清先选择桌台')
} }
const $goods = data.tabbar[index].foods[foodsindex] const $goods = data.tabbar[index].foods[foodsindex]
@ -707,12 +714,12 @@
carGoods carGoods
} : false } : false
} }
function canAddGoods(){ function canAddGoods() {
return data.table.tableId return data.table.tableId
} }
async function goodsUpdate(foodsindex, index, isAdd) { async function goodsUpdate(foodsindex, index, isAdd) {
if(!canAddGoods()){ if (!canAddGoods()) {
return infoBox.showToast('清先选择桌台') return infoBox.showToast('清先选择桌台')
} }
const $goods = data.tabbar[index].foods[foodsindex] const $goods = data.tabbar[index].foods[foodsindex]
@ -765,10 +772,10 @@
} }
onReady(() => { onReady(() => {
getElRect('list-tight-top').then(res=>{ getElRect('list-tight-top').then(res => {
data.topZhanwei=res.height data.topZhanwei = res.height
}) })
getMenuItemTop() getMenuItemTop()
}) })
@ -803,7 +810,7 @@
return; return;
} }
console.log(res); console.log(res);
if(dataVal){ if (dataVal) {
data[dataVal] = res.height; data[dataVal] = res.height;
} }
resolve(res); resolve(res);
@ -910,15 +917,19 @@
setUser() setUser()
}) })
} }
watch(()=>data.table.tableId,(newval)=>{ watch(() => data.table.tableId, (newval) => {
console.log(newval); console.log(newval);
init() init()
}) })
onBeforeUnmount(() => {}) onBeforeUnmount(() => {})
function watchUpdate() { function watchUpdate() {
uni.$off('update:createOrderIndex') uni.$off('update:createOrderIndex')
uni.$on('update:createOrderIndex', (data) => { uni.$on('update:createOrderIndex', () => {
data.table = {
tableId: ""
}
cars.length = 0
console.log('update:createOrderIndex'); console.log('update:createOrderIndex');
init() init()
}) })
@ -928,15 +939,15 @@
watchChooseTable() watchChooseTable()
watchUpdate() watchUpdate()
}) })
let isCreateOrderToDetail=ref(false) let isCreateOrderToDetail = ref(false)
onLoad((opt) => { onLoad((opt) => {
console.log(opt) console.log(opt)
Object.assign(data.table, opt) Object.assign(data.table, opt)
if(opt.useType){ if (opt.useType) {
uni.setStorageSync('useType',opt.useType) uni.setStorageSync('useType', opt.useType)
} }
if(JSON.stringify(opt)=='{}'){ if (JSON.stringify(opt) == '{}') {
isCreateOrderToDetail.value=true isCreateOrderToDetail.value = true
} }
// if (!opt.tableId) { // if (!opt.tableId) {
// infoBox.showErrorToast('') // infoBox.showErrorToast('')