fix(escort): 预约时间改为整点/半点档位,所有服务可选到 23:30
This commit is contained in:
+10
-26
@@ -1,5 +1,5 @@
|
||||
const API = require('../../utils/api.js')
|
||||
const { formatDate } = require('../../utils/date.js')
|
||||
const { formatDate, LATEST_APPOINTMENT_TIME, buildTimeSlots } = require('../../utils/date.js')
|
||||
|
||||
Page({
|
||||
data: {
|
||||
@@ -25,11 +25,9 @@ Page({
|
||||
appointmentDate: '',
|
||||
appointmentTime: '',
|
||||
minAppointmentDate: '',
|
||||
fixedTime: false,
|
||||
timeOptions: [],
|
||||
sessionIndex: 0,
|
||||
timeStart: '',
|
||||
timeEnd: '',
|
||||
// 预约时间:从服务起始时刻到 23:30,每半小时一档
|
||||
timeSlots: [],
|
||||
timeSlotIndex: 0,
|
||||
remark: '',
|
||||
shippingAddress: '',
|
||||
requiresAddress: false,
|
||||
@@ -106,26 +104,17 @@ Page({
|
||||
applyBookingConfig(service) {
|
||||
const booking = service.booking || {}
|
||||
const sessions = booking.sessions || []
|
||||
const fixedTime = sessions.length > 0 && sessions.every((item) => !item.flexible)
|
||||
const firstSession = sessions[0] || {}
|
||||
const minDate = new Date()
|
||||
minDate.setDate(minDate.getDate() + Number(booking.advanceDays || 0))
|
||||
const minAppointmentDate = formatDate(minDate)
|
||||
let timeEnd = firstSession.end || ''
|
||||
if (!fixedTime && firstSession.end && booking.durationMinutes) {
|
||||
const [hour, minute] = firstSession.end.split(':').map(Number)
|
||||
const latest = hour * 60 + minute - booking.durationMinutes
|
||||
timeEnd = `${String(Math.floor(latest / 60)).padStart(2, '0')}:${String(latest % 60).padStart(2, '0')}`
|
||||
}
|
||||
const provinces = service.areas || []
|
||||
this.selectedHospitalId = ''
|
||||
this.setData({
|
||||
minAppointmentDate,
|
||||
fixedTime,
|
||||
timeOptions: sessions.map((item) => `${item.start} - ${item.end}`),
|
||||
sessionIndex: 0,
|
||||
timeStart: firstSession.start || '',
|
||||
timeEnd,
|
||||
// 所有服务统一提供到 23:30 的开始时间档位(夜间陪诊也需覆盖晚间时段)
|
||||
timeSlots: buildTimeSlots(firstSession.start || '', LATEST_APPOINTMENT_TIME),
|
||||
timeSlotIndex: 0,
|
||||
provinces,
|
||||
province: provinces[0] || '',
|
||||
provinceIndex: 0,
|
||||
@@ -284,13 +273,8 @@ Page({
|
||||
},
|
||||
|
||||
onTimeChange(e) {
|
||||
if (this.data.fixedTime) {
|
||||
const index = Number(e.detail.value)
|
||||
const session = this.data.service.booking.sessions[index]
|
||||
this.setData({ sessionIndex: index, appointmentTime: session.start })
|
||||
return
|
||||
}
|
||||
this.setData({ appointmentTime: e.detail.value })
|
||||
const index = Number(e.detail.value)
|
||||
this.setData({ timeSlotIndex: index, appointmentTime: this.data.timeSlots[index] || '' })
|
||||
},
|
||||
|
||||
onGenderChange(e) {
|
||||
@@ -470,7 +454,7 @@ Page({
|
||||
hospitalCustom: false,
|
||||
appointmentDate: '',
|
||||
appointmentTime: '',
|
||||
sessionIndex: 0,
|
||||
timeSlotIndex: 0,
|
||||
gender: '不限',
|
||||
genderIndex: 0,
|
||||
remark: '',
|
||||
|
||||
Reference in New Issue
Block a user