From b6dd2ae1ebbd18d400275a98ae2bc2fa91e1ea87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A2=E8=B6=8A?= <552369664@qq.com> Date: Thu, 5 Sep 2024 11:32:30 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E3=80=91=E6=8B=BC=E5=9B=A2=E6=B4=BB=E5=8A=A8=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sheep/api/promotion/combination.js | 6 ++-- .../s-groupon-block/s-groupon-block.vue | 33 ++++++++++++++----- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/sheep/api/promotion/combination.js b/sheep/api/promotion/combination.js index bf1d6c6..62791f0 100644 --- a/sheep/api/promotion/combination.js +++ b/sheep/api/promotion/combination.js @@ -37,7 +37,7 @@ const CombinationApi = { url: '/promotion/combination-activity/detail-list', method: 'GET', params: { - ids, + ids }, }); }, @@ -58,9 +58,9 @@ const CombinationApi = { // 获得我的拼团记录分页 getCombinationRecordPage: (params) => { return request({ - url: '/promotion/combination-record/page', + url: "/promotion/combination-record/page", method: 'GET', - params, + params }); }, diff --git a/sheep/components/s-groupon-block/s-groupon-block.vue b/sheep/components/s-groupon-block/s-groupon-block.vue index be3e650..14f3204 100644 --- a/sheep/components/s-groupon-block/s-groupon-block.vue +++ b/sheep/components/s-groupon-block/s-groupon-block.vue @@ -144,6 +144,7 @@ import sheep from '@/sheep'; import CombinationApi from '@/sheep/api/promotion/combination'; import SpuApi from '@/sheep/api/product/spu'; + import spu from '@/sheep/api/product/spu'; // 布局类型 const LayoutTypeEnum = { @@ -241,21 +242,35 @@ * @param ids 商品编号列表 * @return {Promise} 商品列表 */ - async function getSpuDetail(spuId) { - const { data: spu } = await SpuApi.getSpuDetail(spuId) + async function getSpuDetail(ids) { + const { data: spu } = await SpuApi.getSpuDetail(ids); return spu; } // 初始化 onMounted(async () => { - // 加载商品列表 + // 加载活动列表 const activityList = await getCombinationActivityDetailList(activityIds.join(',')); - // 创建 SPU 请求的 Promise 数组 - const spuPromises = activityList.map(activity => getSpuDetail(activity.spuId)); - // 等待所有 SPU 请求完成 - // 处理 spuList - state.spuList = await Promise.all(spuPromises); + // 循环获取活动商品SPU详情并添加到spuList + for (const activity of activityList) { + state.spuList.push(await getSpuDetail(activity.spuId)); + } + + + // 循环活动列表 + activityList.forEach(activity => { + // 获取活动商品的最低价格 + activity.products.forEach(product => { + const combinationPrice = product.combinationPrice || Infinity; + + // 找到对应的 spu 并更新价格 + const spu = state.spuList.find(spu => activity.spuId === spu.id); + if (spu) { + spu.price = Math.min(combinationPrice, spu.price || Infinity); + } + }); + }); // 只有双列布局时需要 if (layoutType === LayoutTypeEnum.TWO_COL) { @@ -273,11 +288,13 @@ .goods-list-box { width: 50%; box-sizing: border-box; + .left-list { &:nth-last-child(1) { margin-bottom: 0 !important; } } + .right-list { &:nth-last-child(1) { margin-bottom: 0 !important;