feat: 增加礼品卡选择功能及相关逻辑

- 在 api/trade.js 中新增 selectGiftCard 函数以支持礼品卡选择
- 更新多个组件以集成礼品卡功能,包括购物车和订单页面
- 优化商品页面和订单详情展示,支持礼品卡抵扣信息
- 调整相关逻辑以确保礼品卡与其他促销活动的兼容性
This commit is contained in:
田香琪
2026-08-02 13:49:02 +08:00
parent a6ba2b3dbe
commit 94e846af6c
10 changed files with 246 additions and 62 deletions

View File

@@ -5,6 +5,7 @@
class="showBox"
v-if="
promotion.__key == 'SECKILL' ||
promotion.__key == 'FLASH_DISCOUNT' ||
promotion.__key == 'GROUPBUY' ||
promotion.__key == 'PINTUAN'
"
@@ -36,6 +37,29 @@
</view>
</view>
<!-- 限时直降 -->
<view class="u-group-flex-left" v-if="promotion.__key == 'FLASH_DISCOUNT'">
<span
class="u-group-flex-left-span"
v-if="detail.promotionPrice != undefined"
>
<span class="flex-price">
{{ goodsFormatPrice(detail.promotionPrice)[0] }}.{{
goodsFormatPrice(detail.promotionPrice)[1]
}}</span
>
</span>
<view class="u-group-flex" v-if="detail.price != undefined">
<span class="old-price"
>¥{{ goodsFormatPrice(detail.price)[0] }}.{{
goodsFormatPrice(detail.price)[1]
}}</span
>
<view class="promotion">限时直降</view>
</view>
</view>
<!-- 团购 -->
<view class="u-group-flex-left" v-if="promotion.__key == 'GROUPBUY'">
<span class="u-group-flex-left-span">

View File

@@ -40,6 +40,26 @@
</view>
</view>
<view v-if="getPromType(prom) == 'FLASH_DISCOUNT'">
<view class="res_prom_item">
<view class="deg_tag">限时直降</view>
<text class="pro-text">{{ props.res[prom].promotionName || props.res[prom].title || '限时直降活动' }}</text>
</view>
</view>
<view v-if="getPromType(prom) == 'NTH_ITEM_DISCOUNT'">
<view class="res_prom_item">
<view class="deg_tag">第N件优惠</view>
<text class="pro-text">
{{ props.res[prom].nthNum || 'N' }}
<text v-if="props.res[prom].discountType === 'FREE'">免费</text>
<text v-else-if="props.res[prom].discountType === 'HALF'">半价</text>
<text v-else-if="props.res[prom].discountValue">{{ props.res[prom].discountValue }}</text>
<text v-else>优惠</text>
</text>
</view>
</view>
<view v-if="getPromType(prom) == 'POINTS_GOODS'">
<view class="res_prom_item">
<view class="deg_tag">积分活动</view>

View File

@@ -2,6 +2,18 @@
<view>
<view v-for="(promotionItem, promotionIndex) in promotion" :key="promotionIndex" class="promotion_row" @click="shutMask(1)">
<view v-if="res != null" v-for="(item, index) in Object.keys(res)" :key="index">
<div class="promotion_col" v-if="item.split('-')[0] == promotionItem.value && item.split('-')[0] == 'FLASH_DISCOUNT'">
<div class="flex">
<view class="deg_tag">{{ promotionItem.title }}</view>
<div class="text proText">{{ res[item].promotionName || res[item].title || '限时直降' }}</div>
</div>
</div>
<div class="promotion_col" v-if="item.split('-')[0] == promotionItem.value && item.split('-')[0] == 'NTH_ITEM_DISCOUNT'">
<div class="flex">
<view class="deg_tag">{{ promotionItem.title }}</view>
<div class="text proText">{{ res[item].promotionName || res[item].title || '第N件优惠' }}</div>
</div>
</div>
<div class="promotion_col" v-if="item.split('-')[0] == promotionItem.value && item.split('-')[0] == 'FULL_DISCOUNT'">
<!-- 满减折扣 -->
<div class="flex">

View File

@@ -8,21 +8,17 @@ const promotion = [
value: "KANJIA",
},
{
title: "单品立减",
value: "MINUS",
title: "限时直降",
value: "FLASH_DISCOUNT",
},
{
title: "第N件优惠",
value: "NTH_ITEM_DISCOUNT",
},
{
title: "团购",
value: "GROUPBUY",
},
{
title: "积分换购",
value: "EXCHANGE",
},
{
title: "第二件半价",
value: "HALF_PRICE",
},
{
title: "满减优惠",
value: "FULL_DISCOUNT",
@@ -50,4 +46,4 @@ export function formatType(val){
}
})
}
}
}