From 41c389743ef6b3ba7ca6bfe049da79f4264271d2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=B5=B5=E6=AF=85?= <1335909236@qq.com>
Date: Thu, 9 Oct 2025 11:29:24 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=98=93=E8=B4=AD=E5=95=86?=
=?UTF-8?q?=E5=93=81=E5=8A=A0=E5=85=A5=E8=B4=AD=E7=89=A9=E8=BD=A6=E9=94=99?=
=?UTF-8?q?=E8=AF=AF=E7=9A=84=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
packages/shop/goods/index.vue | 106 ++++++++++++++++++----------------
1 file changed, 56 insertions(+), 50 deletions(-)
diff --git a/packages/shop/goods/index.vue b/packages/shop/goods/index.vue
index 581f0f9c..d6ce0c60 100644
--- a/packages/shop/goods/index.vue
+++ b/packages/shop/goods/index.vue
@@ -107,10 +107,12 @@
{{ comment.create_time }}
- 已购 {{ comment.goods_name.goods_name }}{{ comment.goods_name.goods_spec }}
+ 已购 {{ comment.goods_name.goods_name }}{{ comment.goods_name.goods_spec
+ }}
{{ comment.user_review }}
-
+
+
@@ -203,7 +205,7 @@
-
+
@@ -231,9 +233,12 @@
-
+
- {{ currentGG && currentGG.goods_name ? currentGG.goods_name : '' }}
+ {{ currentGG && currentGG.goods_name ?
+ currentGG.goods_name : '' }}
长按识别小程序
数量有限马上抢购
@@ -271,7 +276,8 @@
{{ comment.create_time }}
- 已购 {{ comment.goods_name.goods_name }}{{ comment.goods_name.goods_spec }}
+ 已购 {{ comment.goods_name.goods_name }}{{
+ comment.goods_name.goods_spec }}
{{ comment.user_review }}
@@ -303,7 +309,8 @@
- {{ item.goods_name }} {{ item.goods_spec }} / {{ item.goods_unit }}
+ {{ item.goods_name }}
+ {{ item.goods_spec }} / {{ item.goods_unit }}
@@ -321,36 +328,36 @@ import {
} from "../../../utils";
export default {
data() {
- return {
- picUrl,
- top: "",
- localHeight: "",
- carNum: "",
- prevCarNum: "",
- currentNum: "0", //当前商品的数量
- type: "error",
- boxshadow1: false,
- boxshadow2: false,
- id: "184",
- info: "",
- currentIndex: "1", //当前轮播图
+ return {
+ picUrl,
+ top: "",
+ localHeight: "",
+ carNum: "",
+ prevCarNum: "",
+ currentNum: "0", //当前商品的数量
+ type: "error",
+ boxshadow1: false,
+ boxshadow2: false,
+ id: "184",
+ info: "",
+ currentIndex: "1", //当前轮播图
- currentGG: "", //当前选中规格
- currentGGIndex: "", //当前规格index
+ currentGG: "", //当前选中规格
+ currentGGIndex: "", //当前规格index
- carOrderList: [],
- // 新增评论数据
- showReviewPopup: false,
- comments: [],
- show: false,
- showSize: false,
+ carOrderList: [],
+ // 新增评论数据
+ showReviewPopup: false,
+ comments: [],
+ show: false,
+ showSize: false,
- changeImg: "",
- changeName: "",
- changePrice: "",
- selectedGoods: null, // 保存传入的商品规格信息
- qrcodePath: null, // 存储当前页面的二维码路径
- };
+ changeImg: "",
+ changeName: "",
+ changePrice: "",
+ selectedGoods: null, // 保存传入的商品规格信息
+ qrcodePath: null, // 存储当前页面的二维码路径
+ };
},
methods: {
changeIndex(e) {
@@ -460,7 +467,7 @@ export default {
}
this.info = res;
console.log("this.info", this.info.commodity_goods_info_list);
-
+
// 检查是否有传入的选中商品信息,如果有则设置为默认选中
let selectedIndex = 0;
if (this.selectedGoods) {
@@ -471,7 +478,7 @@ export default {
}
}
}
-
+
this.currentGG = res.commodity_goods_info_list[selectedIndex];
console.log("this.currentGG", this.currentGG);
this.currentGGIndex = selectedIndex;
@@ -533,11 +540,11 @@ export default {
let that = this;
// 获取当前商品
const currentGoods = this.info.commodity_goods_info_list[this.currentGGIndex];
-
+
// 获取当前购物车数量和库存数量
const currentQuantity = currentGoods.cart_count ? currentGoods.cart_count.count : 0;
const stockQuantity = currentGoods.stock_quantity || 0;
-
+
// 检查库存是否充足
if (currentQuantity >= stockQuantity) {
uni.showToast({
@@ -547,23 +554,22 @@ export default {
});
return;
}
-
+
//如果没有当前商品 直接添加一个
- let goods_id_and_count = [];
this.info.commodity_goods_info_list[this.currentGGIndex].cart_count = {
count: currentQuantity + 1,
};
- 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,
- });
- });
+ const params = {
+ goods_id_and_count: [
+ {
+ goods_id: this.info.commodity_goods_info_list[this.currentGGIndex].id,
+ count: this.info.commodity_goods_info_list[this.currentGGIndex].cart_count.count,
+ },
+ ],
+ };
//因为是当前商品没有 调用update就是增加商品。增加商品之后再获取购物车数量
- request(apiArr.updateCar, "POST", {
- goods_id_and_count,
- }).then((res) => {
+ request(apiArr.updateCar, "POST", params).then((res) => {
that.getShopCar();
that.getShopCarList();
});
@@ -638,7 +644,7 @@ export default {
}));
});
}
- },onLoad(options) {
+ }, onLoad(options) {
const itemObj = JSON.parse(decodeURIComponent(options.item));
const meun = menuButtonInfo();
this.top = meun.top;