From 7f628233343e18f0667ab011e9d80755c7f862b2 Mon Sep 17 00:00:00 2001 From: linda Date: Wed, 28 Oct 2026 18:02:59 +0800 Subject: [PATCH] =?UTF-8?q?fix(order):=20=E9=BB=98=E8=AE=A4=E9=A2=84?= =?UTF-8?q?=E7=BA=A6=E6=97=B6=E9=97=B4=E8=87=AA=E5=8A=A8=E9=81=BF=E5=BC=80?= =?UTF-8?q?=E8=BF=87=E5=8E=BB=E6=97=B6=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 立即下单页与确认订单页根据当前时间生成可用预约时段,避免默认 14:00 已过期导致后端拒绝下单 --- pages/order/create.vue | 15 +++++++++++++-- pages/order/quick.vue | 15 +++++++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/pages/order/create.vue b/pages/order/create.vue index 7e67868..8ec6fde 100644 --- a/pages/order/create.vue +++ b/pages/order/create.vue @@ -153,8 +153,19 @@ const now = new Date(); const pad = (n) => (n < 10 ? '0' + n : '' + n); const today = `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}`; - const date = ref(today); - const time = ref('14:00'); + // 默认预约时间取当前时间之后的可用时段,避免默认值落在过去导致下单失败 + function defaultAppointment() { + const h = now.getHours(); + if (h >= 18) { + const t = new Date(now.getTime() + 86400000); + return { date: `${t.getFullYear()}-${pad(t.getMonth() + 1)}-${pad(t.getDate())}`, time: '09:00' }; + } + if (h >= 14) return { date: today, time: pad(h + 1) + ':00' }; + return { date: today, time: '14:00' }; + } + const defAppointment = defaultAppointment(); + const date = ref(defAppointment.date); + const time = ref(defAppointment.time); const form = reactive({ contact: '', mobile: '', address: '', floor: 1, has_elevator: 1, diff --git a/pages/order/quick.vue b/pages/order/quick.vue index d43bb33..2ceb19e 100644 --- a/pages/order/quick.vue +++ b/pages/order/quick.vue @@ -216,8 +216,19 @@ const now = new Date(); const pad = (n) => (n < 10 ? '0' + n : '' + n); const today = `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}`; - const date = ref(today); - const time = ref('14:00'); + // 默认预约时间取当前时间之后的可用时段,避免默认值落在过去导致下单失败 + function defaultAppointment() { + const h = now.getHours(); + if (h >= 18) { + const t = new Date(now.getTime() + 86400000); + return { date: `${t.getFullYear()}-${pad(t.getMonth() + 1)}-${pad(t.getDate())}`, time: '09:00' }; + } + if (h >= 14) return { date: today, time: pad(h + 1) + ':00' }; + return { date: today, time: '14:00' }; + } + const defAppointment = defaultAppointment(); + const date = ref(defAppointment.date); + const time = ref(defAppointment.time); const form = reactive({ goods_model: '', goods_num: 1, remark: '' }); let calcTimer = null;