From 5feab41b3df75397619ead3635fa04bac3093197 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 10 Aug 2024 11:36:02 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=8A=9F=E8=83=BD=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E3=80=91=E6=8B=BC=E5=9B=A2=EF=BC=9A=E6=9C=AA=E5=BC=80=E5=90=AF?= =?UTF-8?q?=E6=8B=BC=E5=9B=A2=E7=9A=84=20SKU=20=E9=9C=80=E8=A6=81=E7=A6=81?= =?UTF-8?q?=E7=94=A8=E9=80=89=E6=8B=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/goods/groupon.vue | 14 +++++++++++++- pages/goods/seckill.vue | 3 ++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/pages/goods/groupon.vue b/pages/goods/groupon.vue index 354d6ed9..3f464ed9 100644 --- a/pages/goods/groupon.vue +++ b/pages/goods/groupon.vue @@ -199,6 +199,7 @@ /** * 去参团 + * * @param record 团长的团购记录 */ function onJoinGroupon(record) { @@ -227,7 +228,6 @@ } // 分享信息 - // TODO @芋艿:分享的接入 const shareInfo = computed(() => { if (isEmpty(state.activity)) return {}; return sheep.$platform.share.getShareInfo( @@ -262,9 +262,21 @@ // 加载商品信息 const { data: spu } = await SpuApi.getSpuDetail(activity.spuId); state.goodsId = spu.id; + // 默认显示最低价 activity.products.forEach((product) => { spu.price = Math.min(spu.price, product.combinationPrice); // 设置 SPU 的最低价格 }); + // 价格、库存使用活动的 + spu.skus.forEach((sku) => { + const product = activity.products.find((product) => product.skuId === sku.id); + if (product) { + sku.price = product.combinationPrice; + } else { + // 找不到可能是没配置,则不能发起秒杀 + sku.stock = 0; + } + }); + // 关闭骨架屏 state.skeletonLoading = false; if (code === 0) { diff --git a/pages/goods/seckill.vue b/pages/goods/seckill.vue index 30a64305..34708d62 100644 --- a/pages/goods/seckill.vue +++ b/pages/goods/seckill.vue @@ -220,6 +220,7 @@ const activity = ref(); const timeStatusEnum = ref(''); + // 查询活动 const getActivity = async (id) => { const { data } = await SeckillApi.getSeckillActivity(id); @@ -230,9 +231,9 @@ await getSpu(data.spuId); }; + // 查询商品 const getSpu = async (id) => { const { data } = await SpuApi.getSpuDetail(id); - // 模拟 data.activity_type = 'seckill'; state.goodsInfo = data; // 处理轮播图