fix(order): 默认预约时间自动避开过去时段
立即下单页与确认订单页根据当前时间生成可用预约时段,避免默认 14:00 已过期导致后端拒绝下单
这个提交包含在:
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
在新工单中引用
屏蔽一个用户