From 4df3526466699b047fabba562d070e19bb4e0269 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=B5=B5=E6=AF=85?= <1335909236@qq.com>
Date: Mon, 27 Oct 2025 09:43:53 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=AF=A6=E6=83=85=E9=A1=B5?=
=?UTF-8?q?=E8=BF=9B=E5=85=A5=E8=B4=AD=E7=89=A9=E8=BD=A6=E9=A1=B5=E9=9D=A2?=
=?UTF-8?q?=E7=9A=84=E9=80=BB=E8=BE=91?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
packages/shop/goods/index.vue | 40 ++++++++++++++++++++---------------
1 file changed, 23 insertions(+), 17 deletions(-)
diff --git a/packages/shop/goods/index.vue b/packages/shop/goods/index.vue
index 4a9eccfd..46d7edcf 100644
--- a/packages/shop/goods/index.vue
+++ b/packages/shop/goods/index.vue
@@ -40,7 +40,8 @@
- 共{{ info.commodity_goods_info_list ? info.commodity_goods_info_list.length : 0 }}款
+ 共{{ info.commodity_goods_info_list ? info.commodity_goods_info_list.length : 0 }}款
@@ -177,7 +178,7 @@
加入购物车
@@ -188,8 +189,9 @@
">
加入购物车
-
-
+
+
已售罄
@@ -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", {