feat(voucher): 优化兑换券整数去除.00展示并支持计划点击穿透明细

这个提交包含在:
chen
2026-09-19 15:41:19 +08:00
父节点 f06538ddf6
当前提交 efab61498d
共有 10 个文件被更改,包括 823 次插入 和 50 次删除

查看文件

@@ -101,7 +101,7 @@
<view class="item-title">兑换券</view>
<view class="ss-flex ss-col-center" @tap="openVoucher">
<text class="item-value text-red" v-if="Number(state.orderInfo.voucher_fee || state.orderPayload.voucher_fee) > 0"
>-{{ state.orderInfo.voucher_fee || state.orderPayload.voucher_fee }} 个</text
>-{{ formatVoucher(state.orderInfo.voucher_fee || state.orderPayload.voucher_fee) }} 个</text
>
<text
class="item-value"
@@ -109,7 +109,7 @@
v-else
>{{
Number(state.orderInfo.voucher_available) > 0
? '可用 ' + (state.orderInfo.voucher_available || '0.00') + ' 个'
? '可用 ' + formatVoucher(state.orderInfo.voucher_available) + ' 个'
: '暂无可用兑换券'
}}</text
>
@@ -169,7 +169,7 @@
<view class="ss-p-x-20 ss-p-y-30">
<view class="ss-m-b-16 ss-m-l-20" style="font-size: 32rpx; font-weight: 600">兑换券抵扣</view>
<view class="ss-m-b-30 ss-m-l-20" style="color: #999; font-size: 24rpx">
可用 {{ state.orderInfo.voucher_available || '0.00' }} 个,先用商城优惠券再用兑换券
可用 {{ formatVoucher(state.orderInfo.voucher_available) }} 个,先用商城优惠券再用兑换券
</view>
<view class="ss-flex ss-col-center ss-m-x-20 ss-m-b-40" style="border-bottom: 1px solid #eee">
<uni-easyinput
@@ -272,12 +272,19 @@
state.showCoupon = false;
}
function formatVoucher(val) {
if (val === '' || val === null || val === undefined || val === '--') return '0';
const num = Number(val);
if (isNaN(num)) return '0';
return num % 1 === 0 ? String(Math.round(num)) : String(Number(num.toFixed(2)));
}
function openVoucher() {
if (!(Number(state.orderInfo.voucher_available) > 0) && !(Number(state.orderPayload.voucher_fee) > 0)) {
sheep.$helper.toast('暂无可用兑换券');
return;
}
state.voucherInput = state.orderPayload.voucher_fee || '';
state.voucherInput = state.orderPayload.voucher_fee ? formatVoucher(state.orderPayload.voucher_fee) : '';
state.showVoucher = true;
}
@@ -314,11 +321,12 @@
if (exchangeNow.value) {
const hasScore = Number(state.orderInfo.score_amount) > 0;
const voucherFee = Number(state.orderInfo.voucher_fee || state.orderPayload.voucher_fee || 0);
const rawVoucherFee = state.orderInfo.voucher_fee || state.orderPayload.voucher_fee || 0;
const voucherFee = formatVoucher(rawVoucherFee);
let confirmContent = '确定立即兑换此商品?';
if (hasScore && voucherFee > 0) {
if (hasScore && Number(rawVoucherFee) > 0) {
confirmContent = `确定使用 ${voucherFee} 个兑换券与 ${state.orderInfo.score_amount} 积分立即兑换?`;
} else if (voucherFee > 0) {
} else if (Number(rawVoucherFee) > 0) {
confirmContent = `确定使用 ${voucherFee} 个兑换券立即兑换(现金实付 0 元)?`;
} else if (hasScore) {
confirmContent = `确定使用 ${state.orderInfo.score_amount} 积分立即兑换?`;