From 7d6cff8a622b6a6f2ba1f0fb168f22f1e85e017e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E6=AF=85?= <1335909236@qq.com> Date: Tue, 21 Oct 2025 16:40:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=95=86=E5=93=81=E4=B9=B0?= =?UTF-8?q?=E4=B8=80=E8=B5=A0=E4=B8=80=E7=9A=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/advertising/goodsSubmit/index.vue | 18 ++++++------ packages/advertising/index/index.vue | 34 ++++++++++++---------- packages/advertising/shopCar/index.vue | 31 +++++++++++--------- 3 files changed, 45 insertions(+), 38 deletions(-) diff --git a/packages/advertising/goodsSubmit/index.vue b/packages/advertising/goodsSubmit/index.vue index 67cc253b..5159a643 100644 --- a/packages/advertising/goodsSubmit/index.vue +++ b/packages/advertising/goodsSubmit/index.vue @@ -462,10 +462,10 @@ export default { }); item.count = 0 } else { - item.count-- + item.count -= item.is_one_one === 1 ? 2 : 1; } } else { - item.count-- + item.count -= item.is_one_one === 1 ? 2 : 1; } // 当数量减到0时,从carList中删除该商品 @@ -496,11 +496,11 @@ export default { if (currentTime >= startTime && currentTime <= endTime) { if (item.count == 0) { - item.count += item.commodity_goods_info.min_order_quantity + item.count += item.is_one_one === 1 ? 2 : 1; } else { - if (item.count >= item.commodity_goods_info.stock_quantity) { + if (item.count >= item.purchase_limit) { uni.showToast({ - title: '库存不足', + title: '您选择的数量已达到最大限购量', icon: 'none' }); return @@ -514,7 +514,7 @@ export default { } } } - item.count++; + item.count += item.is_one_one === 1 ? 2 : 1; this.changeCart(item); }, // 更改购物车 @@ -543,15 +543,15 @@ export default { let total = 0; this.orderList1.forEach(goods => { // 直接使用item.price进行计算 - total += goods.price * goods.count; + total += goods.price * (goods.is_one_one === 1 ? goods.count / 2 : goods.count); }); // 加运费 return total.toFixed(2); } else { let total = 0; this.orderList2.forEach(goods => { - // 直接使用item.price进行计算 - total += goods.price * goods.count; + // 直接使用item.price进行计算 + total += goods.price * (goods.is_one_one === 1 ? goods.count / 2 : goods.count); this.totalPrice = total.toFixed(2); }); // 加运费 diff --git a/packages/advertising/index/index.vue b/packages/advertising/index/index.vue index 81f2bbc0..c75365f4 100644 --- a/packages/advertising/index/index.vue +++ b/packages/advertising/index/index.vue @@ -147,25 +147,23 @@ export default { increaseQuantity(index) { const item = this.goodsList[index] if (item.quantity == 0) { - item.quantity += item.min_order_quantity || 1 - this.carNum += item.min_order_quantity || 1 + if (item.one_one === 1) { + item.quantity += 2 + this.carNum += 2 + } else { + item.quantity += 1 + this.carNum += 1 + } } else { - if (item.quantity == item.total_stock) { + if (item.quantity == (item.one_one === 1 ? item.purchase_limit * 2 : item.purchase_limit)) { uni.showToast({ - title: '库存不足', + title: '您选择的数量已达到最大限购量', icon: 'none' }); return } - if (item.quantity == item.max_limit_quantity) { - uni.showToast({ - title: '一次最多购买' + item.max_limit_quantity + '件', - icon: 'none' - }); - return - } - item.quantity++; - this.carNum++; + item.quantity = item.one_one === 1 ? item.quantity + 2 : item.quantity + 1; + this.carNum = item.one_one === 1 ? this.carNum + 2 : this.carNum + 1; } const params = { goods_id_and_count: [ @@ -173,6 +171,8 @@ export default { goods_id: item.goods_id, count: item.quantity, price: item.promotional_price, + is_one_one: item.one_one, + purchase_limit: item.purchase_limit, }, ], adver_id: item.adver_id @@ -183,9 +183,9 @@ export default { decreaseQuantity(index) { const item = this.goodsList[index] if (item.quantity > 0) { - if (item.quantity == (item.min_order_quantity || 1)) { - item.quantity = 0 - this.carNum = 0 + if (item.one_one === 1) { + item.quantity = item.quantity - 2 + this.carNum = this.carNum - 2 } else { item.quantity--; this.carNum--; @@ -197,6 +197,8 @@ export default { goods_id: item.goods_id, count: item.quantity, price: item.promotional_price, + is_one_one: item.one_one, + purchase_limit: item.purchase_limit, }, ], adver_id: item.adver_id diff --git a/packages/advertising/shopCar/index.vue b/packages/advertising/shopCar/index.vue index d5dd3bb6..c4a13fc6 100644 --- a/packages/advertising/shopCar/index.vue +++ b/packages/advertising/shopCar/index.vue @@ -516,7 +516,12 @@ export default { // } else { // total += goods.commodity_goods_info.sales_price * goods.count; // } - total += goods.price * goods.count + + if(goods.is_one_one === 1) { + total += goods.price * (goods.count / 2) + } else { + total += goods.price * goods.count + } } }); }); @@ -593,8 +598,8 @@ export default { that.deleteCarItem(carItem, goodsIndex, item); } else { // 正常减少数量 - this.shopCarTotal = Math.max(0, this.shopCarTotal - 1); - carItem.count = carItem.count - 1; + this.shopCarTotal = carItem.is_one_one === 1 ? Math.max(0, that.shopCarTotal - 2) : Math.max(0, that.shopCarTotal - 1); + carItem.count = carItem.is_one_one === 1 ? carItem.count - 2 : carItem.count - 1; this.handleQuantityChange(carItem.count, carItem); // 如果数量减为0,删除商品 @@ -617,12 +622,12 @@ export default { currentTime <= new Date(carItem.commodity_goods_info.group_buy_activity_info?.end_time).getTime(); if (isGroupBuyActive) { if (carItem.count == 0) { - carItem.count = carItem.commodity_goods_info.min_order_quantity - this.shopCarTotal += carItem.commodity_goods_info.min_order_quantity; + carItem.count = carItem.is_one_one === 1 ? 2 : 1 + this.shopCarTotal += carItem.is_one_one === 1 ? 2 : 1; } else { - if (carItem.count == carItem.commodity_goods_info.total_stock) { + if (carItem.count == carItem.purchase_limit) { uni.showToast({ - title: '库存不足', + title: '您选择的数量已达到最大限购量', icon: 'none' }); return @@ -634,19 +639,19 @@ export default { }); return } - carItem.count++; - this.shopCarTotal++; + carItem.count += carItem.is_one_one === 1 ? 2 : 1; + this.shopCarTotal += carItem.is_one_one === 1 ? 2 : 1; } } else { - if (carItem.count >= carItem.commodity_goods_info.stock_quantity) { + if (carItem.count >= carItem.purchase_limit) { uni.showToast({ - title: '库存不足', + title: '您选择的数量已达到最大限购量', icon: 'none' }); return } - carItem.count++; - this.shopCarTotal++; + carItem.count += carItem.is_one_one === 1 ? 2 : 1; + this.shopCarTotal += carItem.is_one_one === 1 ? 2 : 1; } const item = carItem.commodity_cart_and_goods_model;