称重增加
This commit is contained in:
@@ -78,7 +78,8 @@
|
||||
<view class="thumb-box" v-for="(goodsItem, goodsIndex) in item.foods" :key="goodsIndex">
|
||||
<list-goods-item @chooseGuige="chooseGuige($event,index)"
|
||||
@add="goodsUpdate($event,index,true)" @reduce="goodsUpdate($event,index,false)"
|
||||
:index="goodsIndex" :data="goodsItem"></list-goods-item>
|
||||
@tapweigh="tapweigh($event,index)" :index="goodsIndex"
|
||||
:data="goodsItem"></list-goods-item>
|
||||
|
||||
</view>
|
||||
<!-- <template v-if="item.name==='附加费'">
|
||||
@@ -104,6 +105,7 @@
|
||||
@chooseGuige="chooseGuige(goodsItem.goodsIndex,goodsItem.index)"
|
||||
@add="searchGoodsUpdate(goodsItem,goodsIndex,true)"
|
||||
@reduce="searchGoodsUpdate(goodsItem,goodsIndex,false)"
|
||||
@tapweigh="tapweigh(goodsItem.goodsIndex,goodsItem.index)"
|
||||
:index="goodsItem.goodsIndex" :data="goodsItem"></list-goods-item>
|
||||
</view>
|
||||
</view>
|
||||
@@ -127,8 +129,8 @@
|
||||
:skus="guigeModelData.chooseGoods.skus"></guige-model>
|
||||
<!-- 添加附加费 -->
|
||||
<my-surcharge @confirm="surchargeConfirm" ref="surcharge" title="添加附加费"></my-surcharge>
|
||||
|
||||
|
||||
<!-- 称重 -->
|
||||
<weigh-item ref="refweighitem" @weighgoodsUpdate='goodsUpdate'></weigh-item>
|
||||
</view>
|
||||
<up-modal title="提示" content="该台桌购物车里有商品,是否清除该台桌里的商品?" :show="modal.clear" showCancelButton closeOnClickOverlay
|
||||
@confirm="confirmModelConfirm" @cancel="confirmModelConfirm('cancel')" @close="setModalShow('clear',false)"
|
||||
@@ -151,6 +153,7 @@
|
||||
import color from '@/commons/color.js';
|
||||
import guigeModel from './components/guige'
|
||||
import taocanModel from './components/taocanModel.vue'
|
||||
import weighItem from './components/weigh.vue'
|
||||
import listGoodsItem from './components/list-goods-item.vue'
|
||||
import mySurcharge from './components/surcharge'
|
||||
import {
|
||||
@@ -856,6 +859,14 @@
|
||||
|
||||
let selGoods = ref({});
|
||||
|
||||
// 称重
|
||||
const refweighitem = ref(null)
|
||||
const tapweigh = (foodsindex, index) => {
|
||||
console.log(foodsindex, index)
|
||||
const goods = data.tabbar[index].foods[foodsindex]
|
||||
refweighitem.value.open(foodsindex, index, goods)
|
||||
}
|
||||
|
||||
function chooseGuige(foodsindex, index) {
|
||||
if (!canAddGoods()) {
|
||||
return infoBox.showToast('请先选择桌台', 0.5).then(res => {
|
||||
@@ -979,6 +990,7 @@
|
||||
}
|
||||
|
||||
function searchGoodsUpdate(goodsItem, goodsIndex, isAdd) {
|
||||
console.log(goodsItem.goodsIndex, goodsItem.index, isAdd, goodsIndex, 111111)
|
||||
goodsUpdate(goodsItem.goodsIndex, goodsItem.index, isAdd, goodsIndex)
|
||||
}
|
||||
|
||||
@@ -987,7 +999,8 @@
|
||||
searchResult.value[index].chooseNumber = chooseNumber
|
||||
}
|
||||
}
|
||||
async function goodsUpdate(foodsindex, index, isAdd, searchGoodsIndex) {
|
||||
|
||||
async function goodsUpdate(foodsindex, index, isAdd, searchGoodsIndex, showCurrentInput) { // showCurrentInput 称重才会传的参数
|
||||
// if (!canAddGoods()) {
|
||||
// return infoBox.showToast('请先选择桌台', 0.5).then(res => {
|
||||
// chooseTable()
|
||||
@@ -1001,13 +1014,17 @@
|
||||
});
|
||||
const productId = $goods.id
|
||||
const skuId = $goods.specList[0].id
|
||||
const suit = $goods.specList[0].suit || 1
|
||||
let suit = $goods.specList[0].suit || 1
|
||||
// 不影响之前的代码 称重suit单独处理
|
||||
if ($goods.type == 'weigh' && showCurrentInput) {
|
||||
suit = showCurrentInput
|
||||
}
|
||||
if (goodsInCarIndex !== -1) {
|
||||
//更新
|
||||
const carGoods = cars[goodsInCarIndex]
|
||||
const cartId = carGoods.id
|
||||
const step = isAdd ? 1 : -1
|
||||
const num = carGoods.number * 1 + step
|
||||
let num = carGoods.number * 1 + step
|
||||
if (num === 0 || num < suit) {
|
||||
//移除
|
||||
cars.splice(goodsInCarIndex, 1)
|
||||
@@ -1017,6 +1034,10 @@
|
||||
cartId
|
||||
})
|
||||
}
|
||||
// 不影响之前的代码 称重num单独处理
|
||||
if ($goods.type == 'weigh' && showCurrentInput) {
|
||||
num = carGoods.number * 1 + Number(showCurrentInput)
|
||||
}
|
||||
const {
|
||||
number
|
||||
} = await updateCartGoods({
|
||||
|
||||
Reference in New Issue
Block a user