功能:完善评论测试与优惠券最优选择
This commit is contained in:
@@ -132,7 +132,7 @@
|
||||
</a-radio>
|
||||
</a-radio-group>
|
||||
<div class="coupon-tip">
|
||||
系统只会默认预选最佳 VIP 自动券,普通用户券需要你手动选择后才会在下单时使用。
|
||||
系统会按本次订单金额自动预选减免最高的一张券,也可以手动选择不使用优惠。
|
||||
</div>
|
||||
</a-modal>
|
||||
|
||||
@@ -313,9 +313,8 @@ const calculateCouponDiscount = (coupon: UserCoupon | null, amount: number) => {
|
||||
return 0
|
||||
}
|
||||
|
||||
const findBestSystemVipCoupon = (coupons: UserCoupon[]) => {
|
||||
const findBestCoupon = (coupons: UserCoupon[]) => {
|
||||
return coupons
|
||||
.filter(coupon => coupon.sourceType === 'SYSTEM_VIP')
|
||||
.sort((left, right) => calculateCouponDiscount(right, subtotal.value) - calculateCouponDiscount(left, subtotal.value))[0] || null
|
||||
}
|
||||
|
||||
@@ -455,10 +454,10 @@ const loadAvailableCoupons = async () => {
|
||||
}
|
||||
|
||||
couponSelectionTouched.value = false
|
||||
const defaultVipCoupon = findBestSystemVipCoupon(availableCoupons.value)
|
||||
if (defaultVipCoupon) {
|
||||
selectedCoupon.value = defaultVipCoupon
|
||||
couponSelectionKey.value = getCouponKey(defaultVipCoupon)
|
||||
const defaultCoupon = findBestCoupon(availableCoupons.value)
|
||||
if (defaultCoupon) {
|
||||
selectedCoupon.value = defaultCoupon
|
||||
couponSelectionKey.value = getCouponKey(defaultCoupon)
|
||||
} else {
|
||||
selectedCoupon.value = null
|
||||
couponSelectionKey.value = NO_COUPON_KEY
|
||||
|
||||
Reference in New Issue
Block a user