套餐
This commit is contained in:
@@ -105,7 +105,6 @@
|
||||
@add="searchGoodsUpdate(goodsItem,goodsIndex,true)"
|
||||
@reduce="searchGoodsUpdate(goodsItem,goodsIndex,false)"
|
||||
:index="goodsItem.goodsIndex" :data="goodsItem"></list-goods-item>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
<my-img-empty v-if="!searchResult.length" tips="未搜索到相关商品"></my-img-empty>
|
||||
@@ -120,7 +119,8 @@
|
||||
<my-car :isCreateOrderToDetail="isCreateOrderToDetail" @updateNumber="carsNumberChange" :user="data.vipUser"
|
||||
:masterId="data.masterId" :table="data.table" :data="cars" @clear="onClearCart"></my-car>
|
||||
</view>
|
||||
|
||||
<!-- 套餐选择规格 -->
|
||||
<taocanModel ref="taocanModelRef" @confirm="taocanConfirm" :goodsData="selGoods"></taocanModel>
|
||||
<!-- 选择规格 -->
|
||||
<guige-model @update-sku="updateSkuSel" @confirm="guigeConfirm" ref="chooseGuigeModel" :goodsData="selGoods"
|
||||
:title="guigeModelData.title" :sku-map="guigeModelData.chooseGoods.skuMap"
|
||||
@@ -150,6 +150,7 @@
|
||||
import util from './util.js';
|
||||
import color from '@/commons/color.js';
|
||||
import guigeModel from './components/guige'
|
||||
import taocanModel from './components/taocanModel.vue'
|
||||
import listGoodsItem from './components/list-goods-item.vue'
|
||||
import mySurcharge from './components/surcharge'
|
||||
import {
|
||||
@@ -277,6 +278,26 @@
|
||||
}
|
||||
return obj
|
||||
}
|
||||
// 添加套餐
|
||||
async function taocanConfirm(d, item) {
|
||||
const cartGoods = await addCart({
|
||||
num: 1,
|
||||
groupProductIdList: d,
|
||||
productId: item.id,
|
||||
skuId: item.specList[0].id
|
||||
})
|
||||
infoBox.showToast('添加成功')
|
||||
// guigeConfirm(item, 1)
|
||||
// updateCartGoods({
|
||||
// productId: item.id,
|
||||
// skuId: item.specList[0].id,
|
||||
// cartId: cartGoods.id
|
||||
// })
|
||||
cars.push({
|
||||
...cartGoods,
|
||||
specSnap: item.specSnap
|
||||
})
|
||||
}
|
||||
|
||||
function scanCode() {
|
||||
// 只允许通过相机扫码
|
||||
@@ -671,11 +692,11 @@
|
||||
}
|
||||
|
||||
function toLinshi() {
|
||||
go.to('PAGES_CHOOSE_ADD_TEMP_CUISINE',{
|
||||
masterId:data.masterId,
|
||||
tableId:data.table.tableId,
|
||||
vipUserId:option.vipUserId?option.vipUserId:'',
|
||||
useType:uni.getStorageSync('useType')
|
||||
go.to('PAGES_CHOOSE_ADD_TEMP_CUISINE', {
|
||||
masterId: data.masterId,
|
||||
tableId: data.table.tableId,
|
||||
vipUserId: option.vipUserId ? option.vipUserId : '',
|
||||
useType: uni.getStorageSync('useType')
|
||||
})
|
||||
}
|
||||
|
||||
@@ -833,7 +854,7 @@
|
||||
}
|
||||
|
||||
|
||||
let selGoods = ref({})
|
||||
let selGoods = ref({});
|
||||
|
||||
function chooseGuige(foodsindex, index) {
|
||||
if (!canAddGoods()) {
|
||||
@@ -843,13 +864,19 @@
|
||||
}
|
||||
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)
|
||||
const skuMap = returnSelGoodsSkuMap(specList)
|
||||
const skuList = returnSelGoodsSkuList(tagSnap)
|
||||
setSkugoodsDefaultInit($goods, skuList, skuMap, specList)
|
||||
chooseGuigeModel.value.open()
|
||||
if ($goods.groupType == 1) {
|
||||
instance.ctx.$refs.taocanModelRef.open()
|
||||
} else {
|
||||
guigeModelData.title = $goods.name
|
||||
const specList = $goods.specList;
|
||||
const skuMap = returnSelGoodsSkuMap(specList)
|
||||
// 多规格,和套餐规格区分.groupType=1 套餐多规格
|
||||
let tagSnap = JSON.parse($goods.skuResult.tagSnap)
|
||||
const skuList = returnSelGoodsSkuList(tagSnap)
|
||||
setSkugoodsDefaultInit($goods, skuList, skuMap, specList)
|
||||
chooseGuigeModel.value.open()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async function guigeConfirm(sku, num) {
|
||||
@@ -902,13 +929,15 @@
|
||||
categoryId,
|
||||
skuId
|
||||
} = goods
|
||||
|
||||
|
||||
const cartId = goods.id
|
||||
const tabbarIndex = data.tabbar.findIndex(v => v.id == categoryId)
|
||||
//临时菜没有对应商品数据
|
||||
const $goods =!productId?undefined:data.tabbar[tabbarIndex].foods.find(v => v.id == productId)
|
||||
const $goods = !productId ? undefined : data.tabbar[tabbarIndex].foods.find(v => v.id == productId)
|
||||
//临时菜没有skuList
|
||||
const $sku =!productId?{suit:1}:$goods.specList.find(v => v.id == skuId)
|
||||
const $sku = !productId ? {
|
||||
suit: 1
|
||||
} : $goods.specList.find(v => v.id == skuId)
|
||||
|
||||
if (num === 0 || num < $sku.suit) {
|
||||
//移除
|
||||
@@ -1000,16 +1029,19 @@
|
||||
$goods.chooseNumber = number
|
||||
setSearchGoods(searchGoodsIndex, number)
|
||||
} else {
|
||||
//增加
|
||||
const num = suit
|
||||
const cartGoods = await addCart({
|
||||
num,
|
||||
productId,
|
||||
skuId
|
||||
})
|
||||
infoBox.showToast('添加成功')
|
||||
$goods.chooseNumber = num
|
||||
cars.push(cartGoods)
|
||||
// 套餐和单规格
|
||||
if ($goods.groupType != 1) {
|
||||
//增加
|
||||
const num = suit
|
||||
const cartGoods = await addCart({
|
||||
num,
|
||||
productId,
|
||||
skuId
|
||||
})
|
||||
infoBox.showToast('添加成功')
|
||||
$goods.chooseNumber = num
|
||||
cars.push(cartGoods)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -1188,7 +1220,7 @@
|
||||
setTabBar($category, $originGoods, cars)
|
||||
}
|
||||
onBeforeUnmount(() => {})
|
||||
|
||||
|
||||
function watchUpdate() {
|
||||
uni.$off('update:createOrderIndex')
|
||||
uni.$off('get:table')
|
||||
@@ -1201,7 +1233,7 @@
|
||||
console.log('update:createOrderIndex');
|
||||
init()
|
||||
})
|
||||
uni.$on('add:cashCai', async() => {
|
||||
uni.$on('add:cashCai', async () => {
|
||||
console.log('add:cashCai');
|
||||
const cartRes = await getCart()
|
||||
cars.length = 0
|
||||
|
||||
Reference in New Issue
Block a user