优化详情页进入购物车页面的逻辑

This commit is contained in:
赵毅 2025-10-27 09:43:53 +08:00
parent 0cac04e0db
commit 4df3526466

View File

@ -40,7 +40,8 @@
</view>
</view>
<view class="GG_rigth" @click="showSizePopup">
{{ info.commodity_goods_info_list ? info.commodity_goods_info_list.length : 0 }}<u-icon size="26rpx" name="arrow-right"></u-icon>
{{ info.commodity_goods_info_list ? info.commodity_goods_info_list.length : 0 }}<u-icon size="26rpx"
name="arrow-right"></u-icon>
</view>
</view>
@ -177,7 +178,7 @@
<view class="car_right" v-if="
info.commodity_goods_info_list[currentGGIndex].stock_quantity > 0 &&
(!info.commodity_goods_info_list[currentGGIndex].cart_count ||
info.commodity_goods_info_list[currentGGIndex].cart_count.count == 0)
info.commodity_goods_info_list[currentGGIndex].cart_count.count == 0)
" @click="addCar">
加入购物车
</view>
@ -188,8 +189,9 @@
">
加入购物车
</view>
<view class="car_right car_right_disabled" v-if="info.commodity_goods_info_list[currentGGIndex].stock_quantity < 1">
<view class="car_right car_right_disabled"
v-if="info.commodity_goods_info_list[currentGGIndex].stock_quantity < 1">
已售罄
</view>
</view>
@ -435,7 +437,6 @@ export default {
request(apiArr.getGoodsInfo, "POST", {
id: this.id,
}).then((res) => {
console.log(res);
//
res.commodity_goods_info_list.forEach((item) => {
@ -458,7 +459,6 @@ export default {
});
}
this.info = res;
console.log("this.info", this.info.commodity_goods_info_list);
//
let selectedIndex = 0;
@ -517,14 +517,17 @@ export default {
//
getShopCar() {
request(apiArr.getCarCount, "POST", {}).then((res) => {
this.carNum = res.total;
this.prevCarNum = res.total;
});
},
getShopCarList() {
request(apiArr.getCar, "POST", {}).then((res) => {
this.carOrderList = res.commodity_cart_list;
return request(apiArr.getCar, "POST", {}).then((res) => {
//
this.carOrderList = [].concat(res.same_day_cart_list, res.normal_cart_list)
.flatMap(supplier => supplier.commodity_cart_and_goods_model);
this.carNum = res.total;
return res;
});
},
@ -655,20 +658,23 @@ export default {
},
onReachBottom() { },
onShow() {
this.getShopCarList();
this.getGoodsInfo();
this.getShopCar();
this.getComment();
this.getShopCarList().then(() => {
this.getGoodsInfo();
this.getShopCar();
this.getComment();
});
},
//( id count 0 )
onHide() {
let goods_id_and_count = [];
this.info.commodity_goods_info_list.forEach((item) => {
goods_id_and_count.push({
goods_id: item.id,
count: item.cart_count ? item.cart_count.count : 0,
});
if (item.cart_count) {
goods_id_and_count.push({
goods_id: item.id,
count: item.cart_count.count,
});
}
});
request(apiArr.updateCar, "POST", {