提交 | 用户 | 时间
|
820397
|
1 |
import * as CouponTemplateApi from '@/api/mall/promotion/coupon/couponTemplate' |
H |
2 |
import { CouponTemplateValidityTypeEnum, PromotionDiscountTypeEnum } from '@/utils/constants' |
|
3 |
import { floatToFixed2 } from '@/utils' |
|
4 |
import { formatDate } from '@/utils/formatTime' |
|
5 |
import { object } from 'vue-types' |
|
6 |
|
|
7 |
// 优惠值 |
|
8 |
export const CouponDiscount = defineComponent({ |
|
9 |
name: 'CouponDiscount', |
|
10 |
props: { |
|
11 |
coupon: object<CouponTemplateApi.CouponTemplateVO>() |
|
12 |
}, |
|
13 |
setup(props) { |
|
14 |
const coupon = props.coupon as CouponTemplateApi.CouponTemplateVO |
|
15 |
// 折扣 |
|
16 |
let value = coupon.discountPercent + '' |
|
17 |
let suffix = ' 折' |
|
18 |
// 满减 |
|
19 |
if (coupon.discountType === PromotionDiscountTypeEnum.PRICE.type) { |
|
20 |
value = floatToFixed2(coupon.discountPrice) |
|
21 |
suffix = ' 元' |
|
22 |
} |
|
23 |
return () => ( |
|
24 |
<div> |
|
25 |
<span class={'text-20px font-bold'}>{value}</span> |
|
26 |
<span>{suffix}</span> |
|
27 |
</div> |
|
28 |
) |
|
29 |
} |
|
30 |
}) |
|
31 |
|
|
32 |
// 优惠描述 |
|
33 |
export const CouponDiscountDesc = defineComponent({ |
|
34 |
name: 'CouponDiscountDesc', |
|
35 |
props: { |
|
36 |
coupon: object<CouponTemplateApi.CouponTemplateVO>() |
|
37 |
}, |
|
38 |
setup(props) { |
|
39 |
const coupon = props.coupon as CouponTemplateApi.CouponTemplateVO |
|
40 |
// 使用条件 |
|
41 |
const useCondition = coupon.usePrice > 0 ? `满${floatToFixed2(coupon.usePrice)}元,` : '' |
|
42 |
// 优惠描述 |
|
43 |
const discountDesc = |
|
44 |
coupon.discountType === PromotionDiscountTypeEnum.PRICE.type |
|
45 |
? `减${floatToFixed2(coupon.discountPrice)}元` |
|
46 |
: `打${coupon.discountPercent}折` |
|
47 |
return () => ( |
|
48 |
<div> |
|
49 |
<span>{useCondition}</span> |
|
50 |
<span>{discountDesc}</span> |
|
51 |
</div> |
|
52 |
) |
|
53 |
} |
|
54 |
}) |
|
55 |
|
|
56 |
// 有效期 |
|
57 |
export const CouponValidTerm = defineComponent({ |
|
58 |
name: 'CouponValidTerm', |
|
59 |
props: { |
|
60 |
coupon: object<CouponTemplateApi.CouponTemplateVO>() |
|
61 |
}, |
|
62 |
setup(props) { |
|
63 |
const coupon = props.coupon as CouponTemplateApi.CouponTemplateVO |
|
64 |
const text = |
|
65 |
coupon.validityType === CouponTemplateValidityTypeEnum.DATE.type |
|
66 |
? `有效期:${formatDate(coupon.validStartTime, 'YYYY-MM-DD')} 至 ${formatDate( |
|
67 |
coupon.validEndTime, |
|
68 |
'YYYY-MM-DD' |
|
69 |
)}` |
|
70 |
: `领取后第 ${coupon.fixedStartTerm} - ${coupon.fixedEndTerm} 天内可用` |
|
71 |
return () => <div>{text}</div> |
|
72 |
} |
|
73 |
}) |