feat:【商城】店铺装修-优惠劵:展示优惠、剩余信息

This commit is contained in:
YunaiV
2025-05-01 08:51:50 +08:00
parent c95f621144
commit ad7de47a47
2 changed files with 15 additions and 3 deletions
@@ -21,10 +21,11 @@
:textColor="data.textColor"
background=""
:couponId="item.id"
:title="item.name"
:title="formatCouponTitle(item)"
:type="formatCouponDiscountType(item)"
:value="formatCouponDiscountValue(item)"
:sellBy="formatValidityType(item)"
:surplus="item.totalCount === -1 ? -1 : item.totalCount - item.takeCount"
>
<template v-slot:btn>
<!-- 两列时领取按钮坚排 -->
@@ -57,6 +58,7 @@
import { ref, onMounted, computed } from 'vue';
import { CouponTemplateValidityTypeEnum, PromotionDiscountTypeEnum } from '@/sheep/helper/const';
import { floatToFixed2, formatDate } from '@/sheep/helper/utils';
import { formatDiscountPercent, fen2yuanSimple } from '@/sheep/hooks/useGoods';
const props = defineProps({
data: {
@@ -114,7 +116,7 @@
return floatToFixed2(coupon.discountPrice);
}
if (coupon.discountType === PromotionDiscountTypeEnum.PERCENT.type) {
return coupon.discountPercent;
return formatDiscountPercent(coupon.discountPercent);
}
return `未知【${coupon.discountType}`;
};
@@ -130,6 +132,15 @@
return '未知【' + row.validityType + '】';
};
// 格式化【优惠券标题】
const formatCouponTitle = (coupon) => {
return `${floatToFixed2(coupon.usePrice)}${
coupon.discountType === PromotionDiscountTypeEnum.PRICE.type
? ',减' + floatToFixed2(coupon.discountPrice) + '元'
: ',打' + formatDiscountPercent(coupon.discountPercent) + '折'
}`;
};
const couponList = ref([]);
// 立即领取优惠券
async function onGetCoupon(id) {