修改活动商品详情页加入购物车数量不实时更新的问题

This commit is contained in:
赵毅 2025-10-24 15:46:37 +08:00
parent 042ce47b28
commit 56e0d60f34

View File

@ -649,9 +649,8 @@ export default {
addCar() { addCar() {
let that = this; let that = this;
this.info.commodity_goods_info_list[this.currentGGIndex].cart_count = { this.info.commodity_goods_info_list[this.currentGGIndex].cart_count = {
count: 1, count: this.itemObj.one_one === 1 ? 2 : 1,
}; };
console.log("🚀 ~ this.info.commodity_goods_info_list[this.currentGGIndex]:", this.info.commodity_goods_info_list[this.currentGGIndex])
// this.info.commodity_goods_info_list.forEach((item) => { // this.info.commodity_goods_info_list.forEach((item) => {
// console.log(item.cart_count); // console.log(item.cart_count);
// goods_id_and_count.push({ // goods_id_and_count.push({
@ -660,7 +659,7 @@ export default {
// }); // });
// }); // });
let countVal = 1 let countVal = this.itemObj.one_one === 1 ? 2 : 1;
const params = { const params = {
goods_id_and_count: [ goods_id_and_count: [
@ -684,7 +683,7 @@ export default {
// 0 // 0
const currentCount = this.info.commodity_goods_info_list[this.currentGGIndex].cart_count?.count; const currentCount = this.info.commodity_goods_info_list[this.currentGGIndex].cart_count?.count;
// //
const newCount = currentCount + 1; const newCount = this.itemObj.one_one === 1 ? currentCount + 2 : currentCount + 1;
const params = { const params = {
user_id: uni.getStorageSync("userId"), user_id: uni.getStorageSync("userId"),
@ -699,7 +698,8 @@ export default {
}; };
request(apiArr.updateCar, "POST", params).then((res) => { request(apiArr.updateCar, "POST", params).then((res) => {
this.getShopCarList(); return this.getShopCarList();
}).then(() => {
uni.showToast({ uni.showToast({
title: "操作成功!", title: "操作成功!",
success() { }, success() { },