选择商品弹窗修改

This commit is contained in:
2025-12-25 09:43:02 +08:00
parent f75f90d34f
commit b5ecab0a03
2 changed files with 27 additions and 27 deletions

View File

@@ -158,17 +158,17 @@
<template v-if="isSkuGoods"> <template v-if="isSkuGoods">
<view v-if="goods.type == 'package'" class="addShopping" <view v-if="goods.type == 'package'" class="addShopping"
:class="shopCartNumber > 0 && allConditionsSatisfied ? 'active' : ''" :class="shopCartNumber > 0 && allConditionsSatisfied ? 'active' : ''"
@click="submitSelection()"> @click="submitSelection(goods)">
添加到购物车 添加到购物车
</view> </view>
<view v-else class="addShopping" :class="shopCartNumber > 0 && canSubmit ? 'active' : ''" <view v-else class="addShopping" :class="shopCartNumber > 0 && canSubmit ? 'active' : ''"
@click="submitSelection()"> @click="submitSelection(goods)">
添加到购物车 添加到购物车
</view> </view>
</template> </template>
<template v-else> <template v-else>
<view class="addShopping" :class="shopCartNumber > 0 ? 'active' : ''" <view class="addShopping" :class="shopCartNumber > 0 ? 'active' : ''"
@click="submitSelection()"> @click="submitSelection(goods)">
添加到购物车 添加到购物车
</view> </view>
</template> </template>
@@ -356,9 +356,9 @@
return isInRange; return isInRange;
}; };
// 提交选择并执行下一步操作的方法 // 提交选择并执行下一步操作的方法
const submitSelection = async () => { const submitSelection = async (goods) => {
if (!isProductAvailable(props.goods.days, props.goods.startTime, if (!isProductAvailable(goods.days, goods.startTime,
props.goods.endTime)) { goods.endTime)) {
uni.showToast({ uni.showToast({
title: '不在可售时间内' title: '不在可售时间内'
}); });
@@ -369,60 +369,60 @@
if (shopCartNumber.value <= 0) { if (shopCartNumber.value <= 0) {
return; return;
} }
let res = null
if ((props.goods.type == 'package' && allConditionsSatisfied.value) || (props.goods.type ==
if ((goods.type == 'package' && allConditionsSatisfied.value) || (goods.type ==
'sku' && canSubmit.value)) { 'sku' && canSubmit.value)) {
let res = cartStore.carts.find(cart => cart.product_id == goods.id && cart.sku_id == selSku.value.id)
// 是否是套餐 有就传 // 是否是套餐 有就传
if (props.goods.type == 'package') { if (goods.type == 'package') {
// 需求更改:所所有商品套餐都是add,没有修改 // 需求更改:所所有商品套餐都是add,没有修改
res = null; res = null;
} else { } else {
selectedGroupSnap.value = []; selectedGroupSnap.value = [];
} }
console.log('props.goods', props.goods); console.log('goods', goods);
emits('websocketsendMessage', { emits('websocketsendMessage', {
id: res ? res.cartListId : '', id: res ? res.cartListId : '',
type: 'shopping', type: 'shopping',
suitNum: props.goods.productListitem.suitNum, suitNum: selSku.value.suitNum,
table_code: uni.cache.get('tableCode'), table_code: uni.cache.get('tableCode'),
shop_id: uni.cache.get('shopId'), shop_id: uni.cache.get('shopId'),
operate_type: res ? 'edit' : 'add', operate_type: res ? 'edit' : 'add',
product_id: props.goods.product_id, product_id: goods.id,
sku_id: props.goods.sku_id, sku_id: selSku.value.id,
number: res ? await calculateValue(res.cartNumber, '+', shopCartNumber.value) : number: res ? await calculateValue(res.cartNumber, '+', shopCartNumber.value) :
shopCartNumber.value, shopCartNumber.value,
pro_group_info: selectedGroupSnap.value, pro_group_info: selectedGroupSnap.value,
goods_type: props.goods.type == 'package' ? 'package' : '', goods_type: goods.type == 'package' ? 'package' : '',
memberPrice: props.goods.memberPrice, memberPrice: goods.memberPrice,
is_print: 1, is_print: 1,
product_type: props.goods.type, product_type: goods.type,
is_time_discount: showLimitDiscount(props.goods) is_time_discount: showLimitDiscount(goods)
}) })
// 清空套餐选中 // 清空套餐选中
selectedGroupSnap.value = []; selectedGroupSnap.value = [];
showShopsku.value = false; showShopsku.value = false;
} else { } else {
let res = cartStore.carts.find(cart => cart.product_id == goods.id && goods.skuList[0].id)
emits('websocketsendMessage', { emits('websocketsendMessage', {
id: res ? res.cartListId : '', id: res ? res.cartListId : '',
type: 'shopping', type: 'shopping',
suitNum: props.goods.productListitem.suitNum, suitNum: goods.suitNum,
table_code: uni.cache.get('tableCode'), table_code: uni.cache.get('tableCode'),
shop_id: uni.cache.get('shopId'), shop_id: uni.cache.get('shopId'),
operate_type: res ? 'edit' : 'add', operate_type: res ? 'edit' : 'add',
product_id: props.goods.product_id, product_id: goods.id,
sku_id: props.goods.sku_id, sku_id: goods.skuList[0].id,
number: res ? await calculateValue(res.cartNumber, '+', shopCartNumber.value) : number: res ? await calculateValue(res.cartNumber, '+', shopCartNumber.value) :
shopCartNumber.value, shopCartNumber.value,
memberPrice: props.goods.memberPrice, memberPrice: goods.memberPrice,
is_print: 1, is_print: 1,
product_type: props.goods.type, product_type: goods.type,
is_time_discount: showLimitDiscount(props.goods) is_time_discount: showLimitDiscount(goods)
}) })
showShopsku.value = false;
return; return;
} }
}; };

View File

@@ -571,7 +571,7 @@
<Loading :isLoading="!useSocket.isConnected" /> <Loading :isLoading="!useSocket.isConnected" />
<ModalList></ModalList> <ModalList></ModalList>
<recommendGoodsModal v-if="isDataLoaded" @onBuyClick="onBuyClick"></recommendGoodsModal> <recommendGoodsModal v-if="isDataLoaded" @onBuyClick="onBuyClick"></recommendGoodsModal>
<goodsModal v-model="showGoodsModal" :goods="specifications.item" @prveImgs="prveImgs"></goodsModal> <goodsModal v-model="showGoodsModal" :goods="specifications.item" @prveImgs="prveImgs" @websocketsendMessage="websocketsendMessage"></goodsModal>
<xbSwiperPreview :visable="showPrveImg" :imgs="prveImgsList" @update:visable="updateShowPrveImg"> <xbSwiperPreview :visable="showPrveImg" :imgs="prveImgsList" @update:visable="updateShowPrveImg">
</xbSwiperPreview> </xbSwiperPreview>
<!-- 显示选择人数popup --> <!-- 显示选择人数popup -->