From 3b445d031fc7ce2764745f58bf73b74d219f3af1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A2=E8=B6=8A?= <552369664@qq.com> Date: Fri, 16 Aug 2024 13:49:08 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E3=80=90=E5=8A=9F=E8=83=BD=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E3=80=91=E4=BF=AE=E5=A4=8D=E8=A3=85=E4=BF=AE=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E7=9A=84=E6=8B=BC=E5=9B=A2=E4=BB=B7=E6=A0=BC=E5=92=8C?= =?UTF-8?q?=E7=A7=92=E6=9D=80=E4=BB=B7=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/mall/product/spu.ts | 2 ++ .../mall/promotion/seckill/seckillActivity.ts | 1 + .../mobile/PromotionCombination/index.vue | 15 ++++++++++++++- .../components/mobile/PromotionSeckill/index.vue | 16 +++++++++++++++- 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/api/mall/product/spu.ts b/src/api/mall/product/spu.ts index eee632d5..d44c0f64 100644 --- a/src/api/mall/product/spu.ts +++ b/src/api/mall/product/spu.ts @@ -50,6 +50,8 @@ export interface Spu { giveIntegral?: number // 赠送积分 virtualSalesCount?: number // 虚拟销量 price?: number // 商品价格 + combinationPrice?: number // 商品拼团价格 + seckillPrice?: number // 商品秒杀价格 salesCount?: number // 商品销量 marketPrice?: number // 市场价 costPrice?: number // 成本价 diff --git a/src/api/mall/promotion/seckill/seckillActivity.ts b/src/api/mall/promotion/seckill/seckillActivity.ts index e8346410..4bb0e8b1 100644 --- a/src/api/mall/promotion/seckill/seckillActivity.ts +++ b/src/api/mall/promotion/seckill/seckillActivity.ts @@ -24,6 +24,7 @@ export interface SeckillActivityVO { // 秒杀活动所需属性 export interface SeckillProductVO { skuId: number + spuId: number seckillPrice: number stock: number } diff --git a/src/components/DiyEditor/components/mobile/PromotionCombination/index.vue b/src/components/DiyEditor/components/mobile/PromotionCombination/index.vue index fe6f3a83..ee4061de 100644 --- a/src/components/DiyEditor/components/mobile/PromotionCombination/index.vue +++ b/src/components/DiyEditor/components/mobile/PromotionCombination/index.vue @@ -54,7 +54,7 @@ class="text-12px" :style="{ color: property.fields.price.color }" > - ¥{{ spu.price }} + ¥{{ fenToYuan(spu.combinationPrice || spu.price || 0) }} @@ -66,6 +66,9 @@ import { PromotionCombinationProperty } from './config' import * as ProductSpuApi from '@/api/mall/product/spu' import * as CombinationActivityApi from '@/api/mall/promotion/combination/combinationActivity' +import {Spu} from "@/api/mall/product/spu"; +import {CombinationProductVO} from "@/api/mall/promotion/combination/combinationActivity"; +import {fenToYuan} from "@/utils"; /** 拼团 */ defineOptions({ name: 'PromotionCombination' }) @@ -80,6 +83,16 @@ watch( const activity = await CombinationActivityApi.getCombinationActivity(props.property.activityId) if (!activity?.spuId) return spuList.value = [await ProductSpuApi.getSpu(activity.spuId)] + // 循环活动信息,赋值拼团价格 + activity.products.forEach((product: CombinationProductVO) => { + spuList.value.forEach((spu: Spu) => { + // 如果商品 SpuId 匹配 + if (spu.id === product.spuId) { + // 商品原售价和拼团价,哪个便宜就赋值哪个 + spu.combinationPrice = Math.min(spu.price || 0, product.combinationPrice); // 设置 SPU 的最低价格 + } + }) + }); }, { immediate: true, diff --git a/src/components/DiyEditor/components/mobile/PromotionSeckill/index.vue b/src/components/DiyEditor/components/mobile/PromotionSeckill/index.vue index 1b4113b6..139bf61b 100644 --- a/src/components/DiyEditor/components/mobile/PromotionSeckill/index.vue +++ b/src/components/DiyEditor/components/mobile/PromotionSeckill/index.vue @@ -54,7 +54,7 @@ class="text-12px" :style="{ color: property.fields.price.color }" > - ¥{{ spu.price }} + ¥{{ fenToYuan(spu.seckillPrice || spu.price || 0) }} @@ -66,6 +66,9 @@ import { PromotionSeckillProperty } from './config' import * as ProductSpuApi from '@/api/mall/product/spu' import * as SeckillActivityApi from '@/api/mall/promotion/seckill/seckillActivity' +import {Spu} from "@/api/mall/product/spu"; +import {SeckillProductVO} from "@/api/mall/promotion/seckill/seckillActivity"; +import {fenToYuan} from "@/utils"; /** 秒杀 */ defineOptions({ name: 'PromotionSeckill' }) @@ -80,6 +83,17 @@ watch( const activity = await SeckillActivityApi.getSeckillActivity(props.property.activityId) if (!activity?.spuId) return spuList.value = [await ProductSpuApi.getSpu(activity.spuId)] + spuList.value = [await ProductSpuApi.getSpu(activity.spuId)] + // 循环活动信息,赋值拼团价格 + activity.products.forEach((product: SeckillProductVO) => { + spuList.value.forEach((spu: Spu) => { + // 如果商品 SpuId 匹配 + if (spu.id === product.spuId) { + // 商品原售价和拼团价,哪个便宜就赋值哪个 + spu.seckillPrice = Math.min(spu.price || 0, product.seckillPrice); // 设置 SPU 的最低价格 + } + }) + }); }, { immediate: true, From 4130b2fec52b4676eea3a2a54abde1e3564cb577 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A2=E8=B6=8A?= <552369664@qq.com> Date: Fri, 16 Aug 2024 14:42:43 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E3=80=90=E5=8A=9F=E8=83=BD=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E3=80=91=E4=BF=AE=E5=A4=8D=E8=A3=85=E4=BF=AE=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E7=9A=84=E6=8B=BC=E5=9B=A2=E4=BB=B7=E6=A0=BC=E5=92=8C?= =?UTF-8?q?=E7=A7=92=E6=9D=80=E4=BB=B7=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/mobile/PromotionCombination/index.vue | 7 ++----- .../components/mobile/PromotionSeckill/index.vue | 8 ++------ 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/components/DiyEditor/components/mobile/PromotionCombination/index.vue b/src/components/DiyEditor/components/mobile/PromotionCombination/index.vue index ee4061de..7bb7176a 100644 --- a/src/components/DiyEditor/components/mobile/PromotionCombination/index.vue +++ b/src/components/DiyEditor/components/mobile/PromotionCombination/index.vue @@ -86,11 +86,8 @@ watch( // 循环活动信息,赋值拼团价格 activity.products.forEach((product: CombinationProductVO) => { spuList.value.forEach((spu: Spu) => { - // 如果商品 SpuId 匹配 - if (spu.id === product.spuId) { - // 商品原售价和拼团价,哪个便宜就赋值哪个 - spu.combinationPrice = Math.min(spu.price || 0, product.combinationPrice); // 设置 SPU 的最低价格 - } + // 商品原售价和拼团价,哪个便宜就赋值哪个 + spu.combinationPrice = Math.min(spu.combinationPrice || Infinity, product.combinationPrice); // 设置 SPU 的最低价格 }) }); }, diff --git a/src/components/DiyEditor/components/mobile/PromotionSeckill/index.vue b/src/components/DiyEditor/components/mobile/PromotionSeckill/index.vue index 139bf61b..63bee8eb 100644 --- a/src/components/DiyEditor/components/mobile/PromotionSeckill/index.vue +++ b/src/components/DiyEditor/components/mobile/PromotionSeckill/index.vue @@ -84,14 +84,10 @@ watch( if (!activity?.spuId) return spuList.value = [await ProductSpuApi.getSpu(activity.spuId)] spuList.value = [await ProductSpuApi.getSpu(activity.spuId)] - // 循环活动信息,赋值拼团价格 + // 循环活动信息,赋值秒杀最低价格 activity.products.forEach((product: SeckillProductVO) => { spuList.value.forEach((spu: Spu) => { - // 如果商品 SpuId 匹配 - if (spu.id === product.spuId) { - // 商品原售价和拼团价,哪个便宜就赋值哪个 - spu.seckillPrice = Math.min(spu.price || 0, product.seckillPrice); // 设置 SPU 的最低价格 - } + spu.seckillPrice = Math.min(spu.seckillPrice || Infinity, product.seckillPrice); // 设置 SPU 的最低价格 }) }); },