fix(private-detail): 退款档位标签按配置动态计算(修复6-12/0-6显示为0-12的问题)

This commit is contained in:
gqt
2026-08-14 16:55:39 +08:00
parent 7765d3dae1
commit e4a05379ce
@@ -82,7 +82,7 @@
<text>说明</text> <text>说明</text>
</view> </view>
<view v-for="(rule, idx) in refundQuote.rules" :key="idx" class="refund-rule-row" :class="{ active: rule.description === refundQuote.applicable_tier_description }"> <view v-for="(rule, idx) in refundQuote.rules" :key="idx" class="refund-rule-row" :class="{ active: rule.description === refundQuote.applicable_tier_description }">
<text>{{ formatHoursBefore(rule.hours_before_start) }}</text> <text>{{ formatHoursBefore(rule.hours_before_start, idx) }}</text>
<text>{{ rule.refund_percentage }}%</text> <text>{{ rule.refund_percentage }}%</text>
<text>{{ rule.description }}</text> <text>{{ rule.description }}</text>
</view> </view>
@@ -165,12 +165,12 @@ const confirmCancelBooking = async () => {
} }
} }
const formatHoursBefore = (hours) => { const formatHoursBefore = (hours, idx) => {
const h = Number(hours) const h = Number(hours)
if (h >= 24) return '>24小时' const rules = refundQuote.value?.rules || []
if (h >= 12) return '12-24小时' if (idx === 0 || h >= 24) return `>${h}小时`
if (h >= 0) return '0-12小时' const prev = Number(rules[idx - 1]?.hours_before_start ?? h)
return `${h}小时` return `${h}-${prev}小时`
} }
</script> </script>