fix : 修改商城首页商品加入购物车时的购物车的数量显示问题

This commit is contained in:
赵毅 2025-07-18 10:16:02 +08:00
parent fdd5bbfb3b
commit dfbfb0440e

View File

@ -176,7 +176,7 @@
<u-number-box <u-number-box
:min="0" :min="0"
v-model="items.quantity" v-model="items.quantity"
@change="handleQuantityChange(items)" @change="(value) => handleQuantityChange(value,items)"
> >
<view slot="minus" class="minus"> <view slot="minus" class="minus">
<u-icon name="minus" size="20"></u-icon> <u-icon name="minus" size="20"></u-icon>
@ -244,7 +244,7 @@
<u-number-box <u-number-box
v-model="ite.quantity" v-model="ite.quantity"
:min="0" :min="0"
@change="handleQuantityChange(ite)" @change="(value) => handleQuantityChange(value,ite)"
> >
<view slot="minus" class="minus"> <view slot="minus" class="minus">
<u-icon name="minus" size="20"></u-icon> <u-icon name="minus" size="20"></u-icon>
@ -452,9 +452,7 @@ export default {
this.getGoodsList(); this.getGoodsList();
}, },
// //
handleQuantityChange(item) { handleQuantityChange(val,item) {
console.log("🚀 ~ handleQuantityChange ~ value:", item);
const goodsId = "";
if (item.commodity_goods_info_list.length) { if (item.commodity_goods_info_list.length) {
this.goodsId = item.commodity_goods_info_list[0].id; this.goodsId = item.commodity_goods_info_list[0].id;
} else { } else {
@ -465,19 +463,16 @@ export default {
goods_id_and_count: [ goods_id_and_count: [
{ {
goods_id: this.goodsId, goods_id: this.goodsId,
count: item.quantity ? item.quantity + 1 : 1, count: val.value,
}, },
], ],
}; };
console.log("🚀 ~ handleQuantityChange ~ params:", params);
request(apiArr.updateCar, "POST", params).then((res) => { request(apiArr.updateCar, "POST", params).then((res) => {
console.log(res); console.log(res);
this.getShopCarList();
uni.showToast({ uni.showToast({
title: "操作成功!", title: "操作成功!",
success() { success() {
// setTimeout(() => {
// that.getBanlance()
// }, 1500)
}, },
}); });
}); });
@ -488,6 +483,9 @@ export default {
this.top = meun.top; this.top = meun.top;
this.localHeight = meun.height; this.localHeight = meun.height;
this.getCateList(); this.getCateList();
// this.getShopCarList();
},
onShow() {
this.getShopCarList(); this.getShopCarList();
}, },
onReachBottom() { onReachBottom() {