Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
19156ae35e |
+10
-26
@@ -1,5 +1,5 @@
|
|||||||
const API = require('../../utils/api.js')
|
const API = require('../../utils/api.js')
|
||||||
const { formatDate } = require('../../utils/date.js')
|
const { formatDate, LATEST_APPOINTMENT_TIME, buildTimeSlots } = require('../../utils/date.js')
|
||||||
|
|
||||||
Page({
|
Page({
|
||||||
data: {
|
data: {
|
||||||
@@ -25,11 +25,9 @@ Page({
|
|||||||
appointmentDate: '',
|
appointmentDate: '',
|
||||||
appointmentTime: '',
|
appointmentTime: '',
|
||||||
minAppointmentDate: '',
|
minAppointmentDate: '',
|
||||||
fixedTime: false,
|
// 预约时间:从服务起始时刻到 23:30,每半小时一档
|
||||||
timeOptions: [],
|
timeSlots: [],
|
||||||
sessionIndex: 0,
|
timeSlotIndex: 0,
|
||||||
timeStart: '',
|
|
||||||
timeEnd: '',
|
|
||||||
remark: '',
|
remark: '',
|
||||||
shippingAddress: '',
|
shippingAddress: '',
|
||||||
requiresAddress: false,
|
requiresAddress: false,
|
||||||
@@ -106,26 +104,17 @@ Page({
|
|||||||
applyBookingConfig(service) {
|
applyBookingConfig(service) {
|
||||||
const booking = service.booking || {}
|
const booking = service.booking || {}
|
||||||
const sessions = booking.sessions || []
|
const sessions = booking.sessions || []
|
||||||
const fixedTime = sessions.length > 0 && sessions.every((item) => !item.flexible)
|
|
||||||
const firstSession = sessions[0] || {}
|
const firstSession = sessions[0] || {}
|
||||||
const minDate = new Date()
|
const minDate = new Date()
|
||||||
minDate.setDate(minDate.getDate() + Number(booking.advanceDays || 0))
|
minDate.setDate(minDate.getDate() + Number(booking.advanceDays || 0))
|
||||||
const minAppointmentDate = formatDate(minDate)
|
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 || []
|
const provinces = service.areas || []
|
||||||
this.selectedHospitalId = ''
|
this.selectedHospitalId = ''
|
||||||
this.setData({
|
this.setData({
|
||||||
minAppointmentDate,
|
minAppointmentDate,
|
||||||
fixedTime,
|
// 所有服务统一提供到 23:30 的开始时间档位(夜间陪诊也需覆盖晚间时段)
|
||||||
timeOptions: sessions.map((item) => `${item.start} - ${item.end}`),
|
timeSlots: buildTimeSlots(firstSession.start || '', LATEST_APPOINTMENT_TIME),
|
||||||
sessionIndex: 0,
|
timeSlotIndex: 0,
|
||||||
timeStart: firstSession.start || '',
|
|
||||||
timeEnd,
|
|
||||||
provinces,
|
provinces,
|
||||||
province: provinces[0] || '',
|
province: provinces[0] || '',
|
||||||
provinceIndex: 0,
|
provinceIndex: 0,
|
||||||
@@ -284,13 +273,8 @@ Page({
|
|||||||
},
|
},
|
||||||
|
|
||||||
onTimeChange(e) {
|
onTimeChange(e) {
|
||||||
if (this.data.fixedTime) {
|
const index = Number(e.detail.value)
|
||||||
const index = Number(e.detail.value)
|
this.setData({ timeSlotIndex: index, appointmentTime: this.data.timeSlots[index] || '' })
|
||||||
const session = this.data.service.booking.sessions[index]
|
|
||||||
this.setData({ sessionIndex: index, appointmentTime: session.start })
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.setData({ appointmentTime: e.detail.value })
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onGenderChange(e) {
|
onGenderChange(e) {
|
||||||
@@ -470,7 +454,7 @@ Page({
|
|||||||
hospitalCustom: false,
|
hospitalCustom: false,
|
||||||
appointmentDate: '',
|
appointmentDate: '',
|
||||||
appointmentTime: '',
|
appointmentTime: '',
|
||||||
sessionIndex: 0,
|
timeSlotIndex: 0,
|
||||||
gender: '不限',
|
gender: '不限',
|
||||||
genderIndex: 0,
|
genderIndex: 0,
|
||||||
remark: '',
|
remark: '',
|
||||||
|
|||||||
@@ -180,15 +180,10 @@
|
|||||||
</picker>
|
</picker>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 预约时间 -->
|
<!-- 预约时间:整点/半点一档,所有服务统一可选到 23:30 -->
|
||||||
<view class="order-row">
|
<view class="order-row">
|
||||||
<text class="order-label">预约时间</text>
|
<text class="order-label">预约时间</text>
|
||||||
<picker wx:if="{{fixedTime}}" class="order-picker" mode="selector" range="{{timeOptions}}" value="{{sessionIndex}}" bindchange="onTimeChange">
|
<picker class="order-picker" mode="selector" range="{{timeSlots}}" value="{{timeSlotIndex}}" 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">
|
|
||||||
<view class="picker-value {{appointmentTime ? '' : 'placeholder'}}">
|
<view class="picker-value {{appointmentTime ? '' : 'placeholder'}}">
|
||||||
{{appointmentTime || '请选择预约时间'}}
|
{{appointmentTime || '请选择预约时间'}}
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
+10
-26
@@ -1,5 +1,5 @@
|
|||||||
const API = require('../../utils/api.js')
|
const API = require('../../utils/api.js')
|
||||||
const { formatDate } = require('../../utils/date.js')
|
const { formatDate, LATEST_APPOINTMENT_TIME, buildTimeSlots } = require('../../utils/date.js')
|
||||||
|
|
||||||
// 陪诊项目下拉单行高度:图标 72rpx + 单行文字 + 上下留白
|
// 陪诊项目下拉单行高度:图标 72rpx + 单行文字 + 上下留白
|
||||||
const SERVICE_OPTION_HEIGHT = 108
|
const SERVICE_OPTION_HEIGHT = 108
|
||||||
@@ -32,11 +32,9 @@ Page({
|
|||||||
appointmentDate: '',
|
appointmentDate: '',
|
||||||
appointmentTime: '',
|
appointmentTime: '',
|
||||||
minAppointmentDate: '',
|
minAppointmentDate: '',
|
||||||
fixedTime: false,
|
// 预约时间:从服务起始时刻到 23:30,每半小时一档
|
||||||
timeOptions: [],
|
timeSlots: [],
|
||||||
sessionIndex: 0,
|
timeSlotIndex: 0,
|
||||||
timeStart: '',
|
|
||||||
timeEnd: '',
|
|
||||||
remark: '',
|
remark: '',
|
||||||
shippingAddress: '',
|
shippingAddress: '',
|
||||||
requiresAddress: false,
|
requiresAddress: false,
|
||||||
@@ -110,16 +108,9 @@ Page({
|
|||||||
applyService(service, serviceIndex) {
|
applyService(service, serviceIndex) {
|
||||||
const booking = service.booking || {}
|
const booking = service.booking || {}
|
||||||
const sessions = booking.sessions || []
|
const sessions = booking.sessions || []
|
||||||
const fixedTime = sessions.length > 0 && sessions.every((item) => !item.flexible)
|
|
||||||
const firstSession = sessions[0] || {}
|
const firstSession = sessions[0] || {}
|
||||||
const minDate = new Date()
|
const minDate = new Date()
|
||||||
minDate.setDate(minDate.getDate() + Number(booking.advanceDays || 0))
|
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 || []
|
const provinces = service.areas || []
|
||||||
|
|
||||||
this.selectedHospitalId = ''
|
this.selectedHospitalId = ''
|
||||||
@@ -130,11 +121,9 @@ Page({
|
|||||||
servicePanelOpen: false,
|
servicePanelOpen: false,
|
||||||
totalPrice: service.price,
|
totalPrice: service.price,
|
||||||
minAppointmentDate: formatDate(minDate),
|
minAppointmentDate: formatDate(minDate),
|
||||||
fixedTime,
|
// 所有服务统一提供到 23:30 的开始时间档位(夜间陪诊也需覆盖晚间时段)
|
||||||
timeOptions: sessions.map((item) => `${item.start} - ${item.end}`),
|
timeSlots: buildTimeSlots(firstSession.start || '', LATEST_APPOINTMENT_TIME),
|
||||||
sessionIndex: 0,
|
timeSlotIndex: 0,
|
||||||
timeStart: firstSession.start || '',
|
|
||||||
timeEnd,
|
|
||||||
provinces,
|
provinces,
|
||||||
province: provinces[0] || '',
|
province: provinces[0] || '',
|
||||||
provinceIndex: 0,
|
provinceIndex: 0,
|
||||||
@@ -306,13 +295,8 @@ Page({
|
|||||||
},
|
},
|
||||||
|
|
||||||
onTimeChange(e) {
|
onTimeChange(e) {
|
||||||
if (this.data.fixedTime) {
|
const index = Number(e.detail.value)
|
||||||
const index = Number(e.detail.value)
|
this.setData({ timeSlotIndex: index, appointmentTime: this.data.timeSlots[index] || '' })
|
||||||
const session = this.data.service.booking.sessions[index]
|
|
||||||
this.setData({ sessionIndex: index, appointmentTime: session.start })
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.setData({ appointmentTime: e.detail.value })
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onGenderChange(e) {
|
onGenderChange(e) {
|
||||||
@@ -501,7 +485,7 @@ Page({
|
|||||||
hospitalCustom: false,
|
hospitalCustom: false,
|
||||||
appointmentDate: '',
|
appointmentDate: '',
|
||||||
appointmentTime: '',
|
appointmentTime: '',
|
||||||
sessionIndex: 0,
|
timeSlotIndex: 0,
|
||||||
gender: '不限',
|
gender: '不限',
|
||||||
genderIndex: 0,
|
genderIndex: 0,
|
||||||
remark: '',
|
remark: '',
|
||||||
|
|||||||
@@ -108,14 +108,10 @@
|
|||||||
</picker>
|
</picker>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<!-- 预约时间:整点/半点一档,所有服务统一可选到 23:30 -->
|
||||||
<view class="order-row">
|
<view class="order-row">
|
||||||
<text class="order-label">预约时间</text>
|
<text class="order-label">预约时间</text>
|
||||||
<picker wx:if="{{fixedTime}}" class="order-picker" mode="selector" range="{{timeOptions}}" value="{{sessionIndex}}" bindchange="onTimeChange">
|
<picker class="order-picker" mode="selector" range="{{timeSlots}}" value="{{timeSlotIndex}}" 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">
|
|
||||||
<view class="picker-value {{appointmentTime ? '' : 'placeholder'}}">{{appointmentTime || '请选择预约时间'}}</view>
|
<view class="picker-value {{appointmentTime ? '' : 'placeholder'}}">{{appointmentTime || '请选择预约时间'}}</view>
|
||||||
</picker>
|
</picker>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
const API = require('../../utils/api.js')
|
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 { STATUS_MAP, PAYMENT_STATUS_MAP, resolveOrderStatus } = require('../../utils/order.js')
|
||||||
const { maskIdNumber, maskOrderId } = require('../../utils/privacy.js')
|
const { maskIdNumber, maskOrderId } = require('../../utils/privacy.js')
|
||||||
|
|
||||||
@@ -41,10 +41,8 @@ Page({
|
|||||||
provinces: [],
|
provinces: [],
|
||||||
hospitalOptions: [],
|
hospitalOptions: [],
|
||||||
minAppointmentDate: '',
|
minAppointmentDate: '',
|
||||||
fixedTime: false,
|
// 预约时间:从服务起始时刻到 23:30,每半小时一档
|
||||||
timeOptions: [],
|
timeSlots: [],
|
||||||
timeStart: '',
|
|
||||||
timeEnd: '',
|
|
||||||
editHospital: {},
|
editHospital: {},
|
||||||
showCancelPopup: false,
|
showCancelPopup: false,
|
||||||
cancelReason: '',
|
cancelReason: '',
|
||||||
@@ -121,24 +119,14 @@ Page({
|
|||||||
applyBookingConfig(service) {
|
applyBookingConfig(service) {
|
||||||
const booking = service.booking || {}
|
const booking = service.booking || {}
|
||||||
const sessions = booking.sessions || []
|
const sessions = booking.sessions || []
|
||||||
const fixedTime = sessions.length > 0 && sessions.every(item => !item.flexible)
|
|
||||||
const firstSession = sessions[0] || {}
|
const firstSession = sessions[0] || {}
|
||||||
const minDate = new Date()
|
const minDate = new Date()
|
||||||
minDate.setDate(minDate.getDate() + Number(booking.advanceDays || 0))
|
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({
|
this.setData({
|
||||||
provinces: service.areas || [],
|
provinces: service.areas || [],
|
||||||
minAppointmentDate,
|
minAppointmentDate: formatDate(minDate),
|
||||||
fixedTime,
|
// 所有服务统一提供到 23:30 的开始时间档位(夜间陪诊也需覆盖晚间时段)
|
||||||
timeOptions: sessions.map(item => `${item.start} - ${item.end}`),
|
timeSlots: buildTimeSlots(firstSession.start || '', LATEST_APPOINTMENT_TIME)
|
||||||
timeStart: firstSession.start || '',
|
|
||||||
timeEnd
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -514,8 +502,7 @@ Page({
|
|||||||
? this.data.provinces[matchedProvinceIndex]
|
? this.data.provinces[matchedProvinceIndex]
|
||||||
: (r.hospitalProvince || this.data.provinces[0] || '')
|
: (r.hospitalProvince || this.data.provinces[0] || '')
|
||||||
const provinceIndex = Math.max(0, matchedProvinceIndex)
|
const provinceIndex = Math.max(0, matchedProvinceIndex)
|
||||||
const sessions = this.data.service?.booking?.sessions || []
|
const timeSlotIndex = Math.max(0, this.data.timeSlots.indexOf(r.scheduleStartTime))
|
||||||
const sessionIndex = Math.max(0, sessions.findIndex(item => item.start === r.scheduleStartTime))
|
|
||||||
|
|
||||||
const hospitalOptions = getApp().getHospitalsByProvince(province)
|
const hospitalOptions = getApp().getHospitalsByProvince(province)
|
||||||
const name = r.hospitalName || ''
|
const name = r.hospitalName || ''
|
||||||
@@ -533,7 +520,7 @@ Page({
|
|||||||
medicalRecordNo: r.medicalRecordNo || '',
|
medicalRecordNo: r.medicalRecordNo || '',
|
||||||
scheduleDate: r.scheduleDate || '',
|
scheduleDate: r.scheduleDate || '',
|
||||||
startTime: r.scheduleStartTime || '',
|
startTime: r.scheduleStartTime || '',
|
||||||
sessionIndex
|
timeSlotIndex
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@@ -570,16 +557,11 @@ Page({
|
|||||||
},
|
},
|
||||||
|
|
||||||
onStartTimeChange(e) {
|
onStartTimeChange(e) {
|
||||||
if (this.data.fixedTime) {
|
const index = Number(e.detail.value)
|
||||||
const sessionIndex = Number(e.detail.value)
|
this.setData({
|
||||||
const session = this.data.service.booking.sessions[sessionIndex]
|
'editHospital.timeSlotIndex': index,
|
||||||
this.setData({
|
'editHospital.startTime': this.data.timeSlots[index] || ''
|
||||||
'editHospital.sessionIndex': sessionIndex,
|
})
|
||||||
'editHospital.startTime': session.start
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.setData({ 'editHospital.startTime': e.detail.value })
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onCancelHospitalEdit() {
|
onCancelHospitalEdit() {
|
||||||
|
|||||||
@@ -419,22 +419,10 @@
|
|||||||
<view class="form-row">
|
<view class="form-row">
|
||||||
<text class="form-label">预约时间</text>
|
<text class="form-label">预约时间</text>
|
||||||
<picker
|
<picker
|
||||||
wx:if="{{fixedTime}}"
|
|
||||||
class="form-picker"
|
class="form-picker"
|
||||||
mode="selector"
|
mode="selector"
|
||||||
range="{{timeOptions}}"
|
range="{{timeSlots}}"
|
||||||
value="{{editHospital.sessionIndex}}"
|
value="{{editHospital.timeSlotIndex}}"
|
||||||
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}}"
|
|
||||||
bindchange="onStartTimeChange"
|
bindchange="onStartTimeChange"
|
||||||
>
|
>
|
||||||
<view class="form-picker-value">{{editHospital.startTime || '请选择时间'}}</view>
|
<view class="form-picker-value">{{editHospital.startTime || '请选择时间'}}</view>
|
||||||
|
|||||||
+32
-1
@@ -54,10 +54,41 @@ function toISOString(value) {
|
|||||||
return date ? date.toISOString() : null
|
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 = {
|
module.exports = {
|
||||||
parseDate,
|
parseDate,
|
||||||
formatDate,
|
formatDate,
|
||||||
formatDateTime,
|
formatDateTime,
|
||||||
calcAge,
|
calcAge,
|
||||||
toISOString
|
toISOString,
|
||||||
|
LATEST_APPOINTMENT_TIME,
|
||||||
|
buildTimeSlots
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user