代客下单增加无台桌下单
This commit is contained in:
@@ -63,8 +63,9 @@
|
||||
|
||||
|
||||
</view>
|
||||
<up-modal title="提示" content="是否清空全部已添加的商品?" :show="modal.clear" showCancelButton closeOnClickOverlay @confirm="confirmModelConfirm"
|
||||
@cancel="setModalShow('clear',false)" @close="setModalShow('clear',false)" width="300px"></up-modal>
|
||||
<up-modal title="提示" content="是否清空全部已添加的商品?" :show="modal.clear" showCancelButton closeOnClickOverlay
|
||||
@confirm="confirmModelConfirm" @cancel="setModalShow('clear',false)" @close="setModalShow('clear',false)"
|
||||
width="300px"></up-modal>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@@ -114,7 +115,7 @@
|
||||
})
|
||||
const modal = reactive({
|
||||
key: '',
|
||||
clear:false
|
||||
clear: false
|
||||
})
|
||||
|
||||
function confirmModelConfirm() {
|
||||
@@ -124,7 +125,7 @@
|
||||
}
|
||||
|
||||
function setModalShow(key = 'show', show = true) {
|
||||
if (key == 'clear'&&show&&props.data.length<=0) {
|
||||
if (key == 'clear' && show && props.data.length <= 0) {
|
||||
return infoBox.showToast('购物车是空的!')
|
||||
}
|
||||
modal.key = key
|
||||
@@ -132,7 +133,7 @@
|
||||
console.log(modal);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
const edmits = defineEmits(['clear', 'updateNumber'])
|
||||
|
||||
@@ -163,6 +164,13 @@
|
||||
status,
|
||||
type
|
||||
} = props.table
|
||||
if (props.table.tableId == '') {
|
||||
go.to('PAGES_CONFIRM_ORDER', {
|
||||
masterId: props.masterId,
|
||||
isCreateOrderToDetail: props.isCreateOrderToDetail ? 1 : 0
|
||||
})
|
||||
return
|
||||
}
|
||||
go.to('PAGES_CONFIRM_ORDER', {
|
||||
masterId: props.masterId,
|
||||
type,
|
||||
@@ -200,7 +208,7 @@
|
||||
}
|
||||
|
||||
function clear() {
|
||||
setModalShow('clear',false)
|
||||
setModalShow('clear', false)
|
||||
edmits('clear')
|
||||
hideGoods()
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
toRefs,
|
||||
watch
|
||||
} from 'vue';
|
||||
import util from '../util.js';
|
||||
const props = defineProps({
|
||||
img:{
|
||||
type:Object,
|
||||
@@ -99,7 +100,7 @@
|
||||
}
|
||||
return (
|
||||
item.isPauseSale ||
|
||||
(item.typeEnum !== "sku" && item.specList[0].stockNumber <= 0)
|
||||
(item.typeEnum !== "sku" && item.isStock==1&& item.stockNumber <= 0)
|
||||
);
|
||||
})
|
||||
|
||||
|
||||
@@ -103,8 +103,8 @@
|
||||
<list-goods-item :img="{width:'330rpx',height:'330rpx'}"
|
||||
@chooseGuige="chooseGuige(goodsItem.goodsIndex,goodsItem.index)"
|
||||
@add="searchGoodsUpdate(goodsItem,goodsIndex,true)"
|
||||
@reduce="searchGoodsUpdate(goodsItem,goodsIndex,false)" :index="goodsItem.goodsIndex"
|
||||
:data="goodsItem"></list-goods-item>
|
||||
@reduce="searchGoodsUpdate(goodsItem,goodsIndex,false)"
|
||||
:index="goodsItem.goodsIndex" :data="goodsItem"></list-goods-item>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
@@ -122,20 +122,27 @@
|
||||
</view>
|
||||
|
||||
<!-- 选择规格 -->
|
||||
<guige-model @update-sku="updateSkuSel" @confirm="guigeConfirm" ref="chooseGuigeModel"
|
||||
:goodsData="selGoods"
|
||||
<guige-model @update-sku="updateSkuSel" @confirm="guigeConfirm" ref="chooseGuigeModel" :goodsData="selGoods"
|
||||
:title="guigeModelData.title" :sku-map="guigeModelData.chooseGoods.skuMap"
|
||||
:skus="guigeModelData.chooseGoods.skus"></guige-model>
|
||||
<!-- 添加附加费 -->
|
||||
<my-surcharge @confirm="surchargeConfirm" ref="surcharge" title="添加附加费"></my-surcharge>
|
||||
</view>
|
||||
|
||||
|
||||
</view>
|
||||
<up-modal title="提示" content="该台桌购物车里有商品,是否清除该台桌里的商品?" :show="modal.clear" showCancelButton closeOnClickOverlay
|
||||
@confirm="confirmModelConfirm" @cancel="confirmModelConfirm('cancel')" @close="setModalShow('clear',false)"
|
||||
width="300px">
|
||||
|
||||
</up-modal>
|
||||
</template>
|
||||
<script setup>
|
||||
import _ from 'lodash';
|
||||
import * as Api from '@/http/yskApi/Instead.js'
|
||||
import {
|
||||
$table
|
||||
$table,
|
||||
$choseTable,
|
||||
$returnTableDetail
|
||||
} from '@/http/yskApi/table.js'
|
||||
import {
|
||||
$tbShopCategory
|
||||
@@ -158,7 +165,8 @@
|
||||
reactive,
|
||||
ref,
|
||||
nextTick,
|
||||
watch,getCurrentInstance
|
||||
watch,
|
||||
getCurrentInstance
|
||||
} from 'vue';
|
||||
import myCar from './components/car'
|
||||
import go from '@/commons/utils/go.js';
|
||||
@@ -173,11 +181,45 @@
|
||||
import {
|
||||
tbShopInfo
|
||||
} from '@/http/yskApi/user.js'
|
||||
import {hasPermission} from '@/commons/utils/hasPermission.js'
|
||||
import {
|
||||
hasPermission
|
||||
} from '@/commons/utils/hasPermission.js'
|
||||
|
||||
|
||||
const modal = reactive({
|
||||
key: '',
|
||||
clear: false,
|
||||
data: ''
|
||||
})
|
||||
|
||||
async function confirmModelConfirm(isCancel = false) {
|
||||
if (modal.key == 'clear') {
|
||||
try {
|
||||
await $choseTable({
|
||||
masterId: data.masterId,
|
||||
tableId: modal.data.tableId,
|
||||
isClear: !isCancel ? true : false,
|
||||
});
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
//TODO handle the exception
|
||||
}
|
||||
data.table = modal.data;
|
||||
setModalShow('clear', false, '')
|
||||
}
|
||||
}
|
||||
|
||||
function setModalShow(key = 'show', show = true, data) {
|
||||
modal.key = key
|
||||
modal[key] = show
|
||||
modal.data = data
|
||||
}
|
||||
|
||||
|
||||
const instance = getCurrentInstance();
|
||||
let canXiadan=ref(false)
|
||||
async function xiadanClick(){
|
||||
canXiadan.value=await hasPermission('允许下单')
|
||||
let canXiadan = ref(false)
|
||||
async function xiadanClick() {
|
||||
canXiadan.value = await hasPermission('允许下单')
|
||||
}
|
||||
xiadanClick()
|
||||
//临时菜
|
||||
@@ -198,9 +240,9 @@
|
||||
menuHeight: 0, // 左边菜单的高度
|
||||
menuItemHeight: 0, // 左边菜单item的高度
|
||||
itemId: '', // 栏目右边scroll-view用于滚动的id
|
||||
tabbar: storageManage.cacheGoods()||[],
|
||||
tabbar: storageManage.cacheGoods() || [],
|
||||
menuItemPos: [],
|
||||
arr: storageManage.cacheGoodsNode()||[],//左右联动布局节点信息
|
||||
arr: storageManage.cacheGoodsNode() || [], //左右联动布局节点信息
|
||||
scrollRightTop: 0, // 右边栏目scroll-view的滚动条高度
|
||||
timer: null, // 定时器
|
||||
topZhanwei: 136 + 24,
|
||||
@@ -305,8 +347,8 @@
|
||||
page: 0,
|
||||
size: 300
|
||||
}) {
|
||||
const showLoading=data.tabbar.length<=0?true:false
|
||||
return Api.getGoodsLists(par,showLoading)
|
||||
const showLoading = data.tabbar.length <= 0 ? true : false
|
||||
return Api.getGoodsLists(par, showLoading)
|
||||
}
|
||||
//获取购物车数据
|
||||
async function getCart(par = {
|
||||
@@ -400,7 +442,7 @@
|
||||
|
||||
//获取桌台信息
|
||||
async function getTableInfo() {
|
||||
if(data.table.tableId){
|
||||
if (data.table.tableId) {
|
||||
const res = await $table.get({
|
||||
qrcode: data.table.tableId
|
||||
})
|
||||
@@ -414,7 +456,7 @@
|
||||
let $category = []
|
||||
async function init() {
|
||||
const masterRes = await getMasterId()
|
||||
data.masterId =masterRes.masterId
|
||||
data.masterId = masterRes.masterId
|
||||
const shopInfo = await tbShopInfo()
|
||||
$shop.value = shopInfo
|
||||
const useType = data.table.status == 'using' ? data.table.useType : $returnUseType(shopInfo)
|
||||
@@ -442,7 +484,7 @@
|
||||
$originGoods = goods
|
||||
if (!data.table.tableId) {
|
||||
//无桌台
|
||||
|
||||
|
||||
setTabBar(category, goods, [])
|
||||
return
|
||||
}
|
||||
@@ -508,9 +550,9 @@
|
||||
}
|
||||
|
||||
function search() {
|
||||
if(searchValue.value===''){
|
||||
if (searchValue.value === '') {
|
||||
isSearch.value = false
|
||||
return
|
||||
return
|
||||
}
|
||||
isSearch.value = true
|
||||
searchResult.value = returnSearchGoods()
|
||||
@@ -533,8 +575,27 @@
|
||||
|
||||
function watchChooseTable() {
|
||||
uni.$off('choose-table')
|
||||
uni.$on('choose-table', (tableData) => {
|
||||
data.table = tableData
|
||||
uni.$on('choose-table', async (item) => {
|
||||
if (data.table.tableId || cars.length <= 0) {
|
||||
data.table = item
|
||||
return;
|
||||
}
|
||||
if (item.status != "idle") {
|
||||
return infoBox.showToast('该台桌已在使用中')
|
||||
}
|
||||
const res = await $returnTableDetail({
|
||||
tableId: item.tableId,
|
||||
});
|
||||
if (res.cartCount > 0) {
|
||||
setModalShow('clear', true, item)
|
||||
} else {
|
||||
await $choseTable({
|
||||
masterId: data.masterId,
|
||||
tableId: item.tableId,
|
||||
isClear:false
|
||||
});
|
||||
data.table = item
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -590,7 +651,7 @@
|
||||
return prve;
|
||||
}, {});
|
||||
const canBudyGoods = specList
|
||||
.filter((v) => util.isCanBuy(v,guigeModelData.chooseGoods.item))
|
||||
.filter((v) => util.isCanBuy(v, guigeModelData.chooseGoods.item))
|
||||
.sort((a, b) => {
|
||||
const aNumber = a.specSnap.split(",").reduce((prve, cur) => {
|
||||
return prve + skuMapNumber[cur];
|
||||
@@ -679,7 +740,7 @@
|
||||
prve[i] = matchArr
|
||||
.filter((v) => v.specSnap.match(i))
|
||||
.every((v) => {
|
||||
return !util.isCanBuy(v,guigeModelData.chooseGoods.item)
|
||||
return !util.isCanBuy(v, guigeModelData.chooseGoods.item)
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -694,9 +755,10 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let selGoods=ref({})
|
||||
|
||||
|
||||
let selGoods = ref({})
|
||||
|
||||
function chooseGuige(foodsindex, index) {
|
||||
if (!canAddGoods()) {
|
||||
return infoBox.showToast('请先选择桌台', 0.5).then(res => {
|
||||
@@ -704,7 +766,7 @@
|
||||
})
|
||||
}
|
||||
const $goods = data.tabbar[index].foods[foodsindex]
|
||||
selGoods.value=$goods
|
||||
selGoods.value = $goods
|
||||
guigeModelData.title = $goods.name
|
||||
const specList = $goods.specList;
|
||||
const tagSnap = JSON.parse($goods.skuResult.tagSnap)
|
||||
@@ -808,15 +870,16 @@
|
||||
return true
|
||||
}
|
||||
|
||||
function searchGoodsUpdate(goodsItem,goodsIndex, isAdd) {
|
||||
goodsUpdate(goodsItem.goodsIndex, goodsItem.index, isAdd,goodsIndex)
|
||||
function searchGoodsUpdate(goodsItem, goodsIndex, isAdd) {
|
||||
goodsUpdate(goodsItem.goodsIndex, goodsItem.index, isAdd, goodsIndex)
|
||||
}
|
||||
function setSearchGoods(index,chooseNumber){
|
||||
if(index!==undefined){
|
||||
searchResult.value[index].chooseNumber=chooseNumber
|
||||
|
||||
function setSearchGoods(index, chooseNumber) {
|
||||
if (index !== undefined) {
|
||||
searchResult.value[index].chooseNumber = chooseNumber
|
||||
}
|
||||
}
|
||||
async function goodsUpdate(foodsindex, index, isAdd,searchGoodsIndex) {
|
||||
async function goodsUpdate(foodsindex, index, isAdd, searchGoodsIndex) {
|
||||
// if (!canAddGoods()) {
|
||||
// return infoBox.showToast('请先选择桌台', 0.5).then(res => {
|
||||
// chooseTable()
|
||||
@@ -841,7 +904,7 @@
|
||||
//移除
|
||||
cars.splice(goodsInCarIndex, 1)
|
||||
$goods.chooseNumber = 0
|
||||
setSearchGoods(searchGoodsIndex,0)
|
||||
setSearchGoods(searchGoodsIndex, 0)
|
||||
return await removeCartGoods({
|
||||
cartId
|
||||
})
|
||||
@@ -856,7 +919,7 @@
|
||||
})
|
||||
carGoods.number = number
|
||||
$goods.chooseNumber = number
|
||||
setSearchGoods(searchGoodsIndex,number)
|
||||
setSearchGoods(searchGoodsIndex, number)
|
||||
} else {
|
||||
//增加
|
||||
const num = suit
|
||||
@@ -991,8 +1054,8 @@
|
||||
if (!data.menuHeight) {
|
||||
await getElRect('menu-scroll-view', 'menuHeight');
|
||||
}
|
||||
if(e.detail.scrollTop==0){
|
||||
isTabClickOver=true
|
||||
if (e.detail.scrollTop == 0) {
|
||||
isTabClickOver = true
|
||||
return swichMenu(0)
|
||||
}
|
||||
setTimeout(() => { // 节流
|
||||
@@ -1230,10 +1293,12 @@
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
::v-deep .uni-searchbar{
|
||||
padding-top: 12px!important;
|
||||
padding-bottom: 16px!important;
|
||||
|
||||
::v-deep .uni-searchbar {
|
||||
padding-top: 12px !important;
|
||||
padding-bottom: 16px !important;
|
||||
}
|
||||
|
||||
.right-box {
|
||||
width: 572rpx;
|
||||
// background-color: rgb(250, 250, 250);
|
||||
@@ -1257,7 +1322,8 @@
|
||||
.item-title {
|
||||
font-size: 26rpx;
|
||||
font-weight: bold;
|
||||
&.active{
|
||||
|
||||
&.active {
|
||||
color: $my-main-color;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user