diff --git a/miniprogram/src/pages/comprehensive/bookings/private-detail.vue b/miniprogram/src/pages/comprehensive/bookings/private-detail.vue index ec9452d..ed39994 100644 --- a/miniprogram/src/pages/comprehensive/bookings/private-detail.vue +++ b/miniprogram/src/pages/comprehensive/bookings/private-detail.vue @@ -63,8 +63,43 @@ - - + + + + + + + + + 取消预订 + × + + + + + 距开始时间 + 退款比例 + 说明 + + + {{ formatHoursBefore(rule.hours_before_start) }} + {{ rule.refund_percentage }}% + {{ rule.description }} + + + + 本次退款金额 + ¥{{ refundQuote.refund_amount }} + + + {{ refundQuote.applicable_tier_description || '当前不可取消' }} + + + + + + + @@ -94,6 +129,49 @@ onLoad(async (query) => { const goPay = () => { uni.navigateTo({ url: `/pages/comprehensive/pay/index?order_id=${booking.value.order_id}` }) } + +const refundPopupVisible = ref(false) +const refundQuote = ref(null) +const refundLoading = ref(false) + +const onCancelBooking = async () => { + try { + const data = await bookingApi.getPrivateBookingRefundQuote(bookingId.value) + refundQuote.value = data + refundPopupVisible.value = true + } catch { + uni.showToast({ title: '获取退款信息失败', icon: 'none' }) + } +} + +const closeRefundPopup = () => { + refundPopupVisible.value = false + refundQuote.value = null +} + +const confirmCancelBooking = async () => { + if (refundLoading.value) return + refundLoading.value = true + try { + await bookingApi.cancelPrivateBooking(bookingId.value) + refundPopupVisible.value = false + const amount = refundQuote.value?.refund_amount || '0' + uni.showToast({ title: `取消成功,退款¥${amount}`, icon: 'none' }) + booking.value = await bookingApi.getPrivateBookingDetail(bookingId.value) + } catch { + uni.showToast({ title: '取消失败,请稍后重试', icon: 'none' }) + } finally { + refundLoading.value = false + } +} + +const formatHoursBefore = (hours) => { + const h = Number(hours) + if (h >= 24) return '>24小时' + if (h >= 12) return '12-24小时' + if (h >= 0) return '0-12小时' + return `${h}小时` +}