Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
19156ae35e |
@@ -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 })
|
||||
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: '',
|
||||
|
||||
@@ -180,15 +180,10 @@
|
||||
</picker>
|
||||
</view>
|
||||
|
||||
<!-- 预约时间 -->
|
||||
<!-- 预约时间:整点/半点一档,所有服务统一可选到 23:30 -->
|
||||
<view class="order-row">
|
||||
<text class="order-label">预约时间</text>
|
||||
<picker wx:if="{{fixedTime}}" class="order-picker" mode="selector" range="{{timeOptions}}" value="{{sessionIndex}}" bindchange="onTimeChange">
|
||||
<view class="picker-value {{appointmentTime ? '' : 'placeholder'}}">
|
||||
{{appointmentTime ? timeOptions[sessionIndex] : '请选择服务班次'}}
|
||||
</view>
|
||||
</picker>
|
||||
<picker wx:else class="order-picker" mode="time" value="{{appointmentTime}}" start="{{timeStart}}" end="{{timeEnd}}" bindchange="onTimeChange">
|
||||
<picker class="order-picker" mode="selector" range="{{timeSlots}}" value="{{timeSlotIndex}}" bindchange="onTimeChange">
|
||||
<view class="picker-value {{appointmentTime ? '' : 'placeholder'}}">
|
||||
{{appointmentTime || '请选择预约时间'}}
|
||||
</view>
|
||||
|
||||
@@ -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')
|
||||
|
||||
// 陪诊项目下拉单行高度:图标 72rpx + 单行文字 + 上下留白
|
||||
const SERVICE_OPTION_HEIGHT = 108
|
||||
@@ -32,11 +32,9 @@ Page({
|
||||
appointmentDate: '',
|
||||
appointmentTime: '',
|
||||
minAppointmentDate: '',
|
||||
fixedTime: false,
|
||||
timeOptions: [],
|
||||
sessionIndex: 0,
|
||||
timeStart: '',
|
||||
timeEnd: '',
|
||||
// 预约时间:从服务起始时刻到 23:30,每半小时一档
|
||||
timeSlots: [],
|
||||
timeSlotIndex: 0,
|
||||
remark: '',
|
||||
shippingAddress: '',
|
||||
requiresAddress: false,
|
||||
@@ -110,16 +108,9 @@ Page({
|
||||
applyService(service, serviceIndex) {
|
||||
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))
|
||||
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 = ''
|
||||
@@ -130,11 +121,9 @@ Page({
|
||||
servicePanelOpen: false,
|
||||
totalPrice: service.price,
|
||||
minAppointmentDate: formatDate(minDate),
|
||||
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,
|
||||
@@ -306,13 +295,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 })
|
||||
this.setData({ timeSlotIndex: index, appointmentTime: this.data.timeSlots[index] || '' })
|
||||
},
|
||||
|
||||
onGenderChange(e) {
|
||||
@@ -501,7 +485,7 @@ Page({
|
||||
hospitalCustom: false,
|
||||
appointmentDate: '',
|
||||
appointmentTime: '',
|
||||
sessionIndex: 0,
|
||||
timeSlotIndex: 0,
|
||||
gender: '不限',
|
||||
genderIndex: 0,
|
||||
remark: '',
|
||||
|
||||
@@ -108,14 +108,10 @@
|
||||
</picker>
|
||||
</view>
|
||||
|
||||
<!-- 预约时间:整点/半点一档,所有服务统一可选到 23:30 -->
|
||||
<view class="order-row">
|
||||
<text class="order-label">预约时间</text>
|
||||
<picker wx:if="{{fixedTime}}" class="order-picker" mode="selector" range="{{timeOptions}}" value="{{sessionIndex}}" bindchange="onTimeChange">
|
||||
<view class="picker-value {{appointmentTime ? '' : 'placeholder'}}">
|
||||
{{appointmentTime ? timeOptions[sessionIndex] : '请选择服务班次'}}
|
||||
</view>
|
||||
</picker>
|
||||
<picker wx:else class="order-picker" mode="time" value="{{appointmentTime}}" start="{{timeStart}}" end="{{timeEnd}}" bindchange="onTimeChange">
|
||||
<picker class="order-picker" mode="selector" range="{{timeSlots}}" value="{{timeSlotIndex}}" bindchange="onTimeChange">
|
||||
<view class="picker-value {{appointmentTime ? '' : 'placeholder'}}">{{appointmentTime || '请选择预约时间'}}</view>
|
||||
</picker>
|
||||
</view>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const API = require('../../utils/api.js')
|
||||
|
||||
const { parseDate, formatDate, formatDateTime, calcAge } = require('../../utils/date.js')
|
||||
const { parseDate, formatDate, formatDateTime, calcAge, LATEST_APPOINTMENT_TIME, buildTimeSlots } = require('../../utils/date.js')
|
||||
const { STATUS_MAP, PAYMENT_STATUS_MAP, resolveOrderStatus } = require('../../utils/order.js')
|
||||
const { maskIdNumber, maskOrderId } = require('../../utils/privacy.js')
|
||||
|
||||
@@ -41,10 +41,8 @@ Page({
|
||||
provinces: [],
|
||||
hospitalOptions: [],
|
||||
minAppointmentDate: '',
|
||||
fixedTime: false,
|
||||
timeOptions: [],
|
||||
timeStart: '',
|
||||
timeEnd: '',
|
||||
// 预约时间:从服务起始时刻到 23:30,每半小时一档
|
||||
timeSlots: [],
|
||||
editHospital: {},
|
||||
showCancelPopup: false,
|
||||
cancelReason: '',
|
||||
@@ -121,24 +119,14 @@ 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')}`
|
||||
}
|
||||
this.setData({
|
||||
provinces: service.areas || [],
|
||||
minAppointmentDate,
|
||||
fixedTime,
|
||||
timeOptions: sessions.map(item => `${item.start} - ${item.end}`),
|
||||
timeStart: firstSession.start || '',
|
||||
timeEnd
|
||||
minAppointmentDate: formatDate(minDate),
|
||||
// 所有服务统一提供到 23:30 的开始时间档位(夜间陪诊也需覆盖晚间时段)
|
||||
timeSlots: buildTimeSlots(firstSession.start || '', LATEST_APPOINTMENT_TIME)
|
||||
})
|
||||
},
|
||||
|
||||
@@ -514,8 +502,7 @@ Page({
|
||||
? this.data.provinces[matchedProvinceIndex]
|
||||
: (r.hospitalProvince || this.data.provinces[0] || '')
|
||||
const provinceIndex = Math.max(0, matchedProvinceIndex)
|
||||
const sessions = this.data.service?.booking?.sessions || []
|
||||
const sessionIndex = Math.max(0, sessions.findIndex(item => item.start === r.scheduleStartTime))
|
||||
const timeSlotIndex = Math.max(0, this.data.timeSlots.indexOf(r.scheduleStartTime))
|
||||
|
||||
const hospitalOptions = getApp().getHospitalsByProvince(province)
|
||||
const name = r.hospitalName || ''
|
||||
@@ -533,7 +520,7 @@ Page({
|
||||
medicalRecordNo: r.medicalRecordNo || '',
|
||||
scheduleDate: r.scheduleDate || '',
|
||||
startTime: r.scheduleStartTime || '',
|
||||
sessionIndex
|
||||
timeSlotIndex
|
||||
}
|
||||
})
|
||||
},
|
||||
@@ -570,16 +557,11 @@ Page({
|
||||
},
|
||||
|
||||
onStartTimeChange(e) {
|
||||
if (this.data.fixedTime) {
|
||||
const sessionIndex = Number(e.detail.value)
|
||||
const session = this.data.service.booking.sessions[sessionIndex]
|
||||
const index = Number(e.detail.value)
|
||||
this.setData({
|
||||
'editHospital.sessionIndex': sessionIndex,
|
||||
'editHospital.startTime': session.start
|
||||
'editHospital.timeSlotIndex': index,
|
||||
'editHospital.startTime': this.data.timeSlots[index] || ''
|
||||
})
|
||||
return
|
||||
}
|
||||
this.setData({ 'editHospital.startTime': e.detail.value })
|
||||
},
|
||||
|
||||
onCancelHospitalEdit() {
|
||||
|
||||
@@ -419,22 +419,10 @@
|
||||
<view class="form-row">
|
||||
<text class="form-label">预约时间</text>
|
||||
<picker
|
||||
wx:if="{{fixedTime}}"
|
||||
class="form-picker"
|
||||
mode="selector"
|
||||
range="{{timeOptions}}"
|
||||
value="{{editHospital.sessionIndex}}"
|
||||
bindchange="onStartTimeChange"
|
||||
>
|
||||
<view class="form-picker-value">{{timeOptions[editHospital.sessionIndex] || '请选择服务班次'}}</view>
|
||||
</picker>
|
||||
<picker
|
||||
wx:else
|
||||
class="form-picker"
|
||||
mode="time"
|
||||
value="{{editHospital.startTime}}"
|
||||
start="{{timeStart}}"
|
||||
end="{{timeEnd}}"
|
||||
range="{{timeSlots}}"
|
||||
value="{{editHospital.timeSlotIndex}}"
|
||||
bindchange="onStartTimeChange"
|
||||
>
|
||||
<view class="form-picker-value">{{editHospital.startTime || '请选择时间'}}</view>
|
||||
|
||||
+32
-1
@@ -54,10 +54,41 @@ function toISOString(value) {
|
||||
return date ? date.toISOString() : null
|
||||
}
|
||||
|
||||
// 预约开始时间的最晚档位:所有服务统一可约到 23:30(整点/半点)
|
||||
const LATEST_APPOINTMENT_TIME = '23:30'
|
||||
|
||||
// 预约时间只取整点和半点:按 30 分钟步长生成 start~end 内可选的 HH:mm 列表
|
||||
function buildTimeSlots(start, end, stepMinutes = 30) {
|
||||
const startMinutes = parseTimeToMinutes(start)
|
||||
const endMinutes = parseTimeToMinutes(end)
|
||||
if (startMinutes === null || endMinutes === null || endMinutes < startMinutes) return []
|
||||
|
||||
const slots = []
|
||||
// 起点若不在整/半点上,从之后最近的整/半点开始
|
||||
let minutes = Math.ceil(startMinutes / stepMinutes) * stepMinutes
|
||||
while (minutes <= endMinutes) {
|
||||
slots.push(`${pad(Math.floor(minutes / 60))}:${pad(minutes % 60)}`)
|
||||
minutes += stepMinutes
|
||||
}
|
||||
return slots
|
||||
}
|
||||
|
||||
function parseTimeToMinutes(value) {
|
||||
if (!value) return null
|
||||
const match = /^(\d{1,2}):(\d{2})$/.exec(String(value))
|
||||
if (!match) return null
|
||||
const hour = Number(match[1])
|
||||
const minute = Number(match[2])
|
||||
if (hour > 23 || minute > 59) return null
|
||||
return hour * 60 + minute
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
parseDate,
|
||||
formatDate,
|
||||
formatDateTime,
|
||||
calcAge,
|
||||
toISOString
|
||||
toISOString,
|
||||
LATEST_APPOINTMENT_TIME,
|
||||
buildTimeSlots
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user