From 7765d3dae116fe3f9f6237325a97a35ccd2a4e94 Mon Sep 17 00:00:00 2001 From: gqt <3217233537@qq.com> Date: Fri, 14 Aug 2026 16:39:34 +0800 Subject: [PATCH] =?UTF-8?q?feat(private-detail):=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=8F=96=E6=B6=88=E9=A2=84=E8=AE=A2=E6=8C=89=E9=92=AE+?= =?UTF-8?q?=E9=98=B6=E6=A2=AF=E9=80=80=E6=AC=BE=E5=BC=B9=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../comprehensive/bookings/private-detail.vue | 216 +++++++++++++++++- 1 file changed, 214 insertions(+), 2 deletions(-) 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}小时` +}