增加代客下单搜索联动
This commit is contained in:
@@ -101,13 +101,14 @@
|
||||
<view class="u-flex u-m-t-20 u-flex-wrap u-row-between">
|
||||
<view class="u-m-b-30" v-for="(goodsItem, goodsIndex) in searchResult" :key="goodsIndex">
|
||||
<goods-item :img="{width:'330rpx',height:'330rpx'}"
|
||||
@chooseGuige="chooseGuige($event,goodsItem.index)"
|
||||
@add="goodsUpdate($event,goodsItem.index,true)"
|
||||
@reduce="goodsUpdate($event,index,false)" :index="goodsItem.goodsIndex"
|
||||
@chooseGuige="chooseGuige(goodsItem.goodsIndex,goodsItem.index)"
|
||||
@add="searchGoodsUpdate(goodsItem,goodsIndex,true)"
|
||||
@reduce="searchGoodsUpdate(goodsItem,goodsIndex,false)" :index="goodsItem.goodsIndex"
|
||||
:data="goodsItem"></goods-item>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
<my-img-empty v-if="!searchResult.length" tips="未搜索到相关商品"></my-img-empty>
|
||||
</view>
|
||||
|
||||
</scroll-view>
|
||||
@@ -122,6 +123,7 @@
|
||||
|
||||
<!-- 选择规格 -->
|
||||
<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>
|
||||
<!-- 添加附加费 -->
|
||||
@@ -304,7 +306,7 @@
|
||||
masterId: data.masterId,
|
||||
tableId: data.table.tableId
|
||||
}) {
|
||||
const res= await Api.getCart(par)
|
||||
const res = await Api.getCart(par)
|
||||
return res
|
||||
}
|
||||
//获取取餐码
|
||||
@@ -491,6 +493,10 @@
|
||||
}
|
||||
|
||||
function search() {
|
||||
if(searchValue.value===''){
|
||||
isSearch.value = false
|
||||
return
|
||||
}
|
||||
isSearch.value = true
|
||||
searchResult.value = returnSearchGoods()
|
||||
console.log(searchResult.value);
|
||||
@@ -673,7 +679,9 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
let selGoods=ref({})
|
||||
function chooseGuige(foodsindex, index) {
|
||||
if (!canAddGoods()) {
|
||||
return infoBox.showToast('清先选择桌台', 0.5).then(res => {
|
||||
@@ -681,6 +689,7 @@
|
||||
})
|
||||
}
|
||||
const $goods = data.tabbar[index].foods[foodsindex]
|
||||
selGoods.value=$goods
|
||||
guigeModelData.title = $goods.name
|
||||
const specList = $goods.specList;
|
||||
const tagSnap = JSON.parse($goods.skuResult.tagSnap)
|
||||
@@ -744,8 +753,8 @@
|
||||
const tabbarIndex = data.tabbar.findIndex(v => v.id == categoryId)
|
||||
const $goods = data.tabbar[tabbarIndex].foods.find(v => v.id == productId)
|
||||
const $sku = $goods.specList.find(v => v.id == skuId)
|
||||
|
||||
if (num === 0||num<$sku.suit) {
|
||||
|
||||
if (num === 0 || num < $sku.suit) {
|
||||
//移除
|
||||
await removeCartGoods({
|
||||
cartId
|
||||
@@ -782,7 +791,16 @@
|
||||
function canAddGoods() {
|
||||
return data.table.tableId
|
||||
}
|
||||
async function goodsUpdate(foodsindex, index, isAdd) {
|
||||
|
||||
function searchGoodsUpdate(goodsItem,goodsIndex, isAdd) {
|
||||
goodsUpdate(goodsItem.goodsIndex, goodsItem.index, isAdd,goodsIndex)
|
||||
}
|
||||
function setSearchGoods(index,chooseNumber){
|
||||
if(index!==undefined){
|
||||
searchResult.value[index].chooseNumber=chooseNumber
|
||||
}
|
||||
}
|
||||
async function goodsUpdate(foodsindex, index, isAdd,searchGoodsIndex) {
|
||||
if (!canAddGoods()) {
|
||||
return infoBox.showToast('请先选择桌台', 0.5).then(res => {
|
||||
chooseTable()
|
||||
@@ -796,17 +814,18 @@
|
||||
});
|
||||
const productId = $goods.id
|
||||
const skuId = $goods.specList[0].id
|
||||
const suit=$goods.specList[0].suit||1
|
||||
const suit = $goods.specList[0].suit || 1
|
||||
if (goodsInCarIndex !== -1) {
|
||||
//更新
|
||||
const carGoods = cars[goodsInCarIndex]
|
||||
const cartId = carGoods.id
|
||||
const step = isAdd ? 1 : -1
|
||||
const num = carGoods.number * 1 + step
|
||||
if (num === 0||num<suit) {
|
||||
if (num === 0 || num < suit) {
|
||||
//移除
|
||||
cars.splice(goodsInCarIndex, 1)
|
||||
$goods.chooseNumber = 0
|
||||
setSearchGoods(searchGoodsIndex,0)
|
||||
return await removeCartGoods({
|
||||
cartId
|
||||
})
|
||||
@@ -821,6 +840,7 @@
|
||||
})
|
||||
carGoods.number = number
|
||||
$goods.chooseNumber = number
|
||||
setSearchGoods(searchGoodsIndex,number)
|
||||
} else {
|
||||
//增加
|
||||
const num = suit
|
||||
|
||||
Reference in New Issue
Block a user