完善小程序登录排班与个人资料流程
This commit is contained in:
@@ -254,8 +254,16 @@ function hasBusyConflict(startMinute, endMinute, ranges) {
|
||||
return ranges.some(range => startMinute < range.endMinute && endMinute > range.startMinute)
|
||||
}
|
||||
|
||||
function resolveBusinessHours(calendar) {
|
||||
function resolveBusinessHours(calendar, targetDate) {
|
||||
const source = calendar || {}
|
||||
const day = targetDate && (source.daySummaries || []).find(item => item.date === targetDate)
|
||||
if (day) {
|
||||
if (day.shopOpen === false) return { start: '', end: '', closed: true }
|
||||
const dayStart = String(day.shopStartTime || '').trim()
|
||||
const dayEnd = String(day.shopEndTime || '').trim()
|
||||
if (/^\d{1,2}:[0-5]\d$/.test(dayStart) && /^\d{1,2}:[0-5]\d$/.test(dayEnd)
|
||||
&& dateUtil.minutesOfDay(dayEnd) > dateUtil.minutesOfDay(dayStart)) return { start: dayStart, end: dayEnd }
|
||||
}
|
||||
const parts = String(source.businessHours || '').split('-')
|
||||
const start = String(source.businessStartTime || parts[0] || '').trim()
|
||||
const end = String(source.businessEndTime || parts[1] || '').trim()
|
||||
@@ -279,7 +287,7 @@ function buildAvailableTimeGroups(calendar, form, durationMinutes) {
|
||||
const today = dateUtil.formatDate(new Date())
|
||||
const now = new Date()
|
||||
const currentMinute = now.getHours() * 60 + now.getMinutes()
|
||||
const businessHours = resolveBusinessHours(calendar)
|
||||
const businessHours = resolveBusinessHours(calendar, form.appointmentDate)
|
||||
if (!businessHours.start) return []
|
||||
const businessStart = dateUtil.minutesOfDay(businessHours.start)
|
||||
const businessEnd = dateUtil.minutesOfDay(businessHours.end)
|
||||
@@ -361,7 +369,7 @@ function buildTimeValues(durationMinutes, businessStart, businessEnd, appointmen
|
||||
function buildTimePickerSlots(calendar, form, durationMinutes) {
|
||||
const schedules = calendar.schedules || []
|
||||
const busyRanges = form.artistId ? buildBusyRanges(calendar.appointments || [], form) : []
|
||||
const businessHours = resolveBusinessHours(calendar)
|
||||
const businessHours = resolveBusinessHours(calendar, form.appointmentDate)
|
||||
if (!businessHours.start) return []
|
||||
const businessStart = businessHours.start
|
||||
const businessEnd = businessHours.end
|
||||
@@ -783,7 +791,7 @@ Page({
|
||||
endDate: this.data.form.appointmentDate || dateUtil.formatDate(new Date())
|
||||
})
|
||||
let artists = getCalendarArtists(calendar)
|
||||
const businessHours = resolveBusinessHours(calendar)
|
||||
const businessHours = resolveBusinessHours(calendar, this.data.form.appointmentDate)
|
||||
const defaultDuration = Number(calendar.defaultAppointmentDurationMinutes) || 60
|
||||
const requestedId = preferredArtistId || this.data.form.artistId
|
||||
if (fallbackEmployee && requestedId && !findArtist(artists, requestedId).id) {
|
||||
@@ -1551,10 +1559,12 @@ Page({
|
||||
try {
|
||||
const calendar = await planningApi.calendar({ startDate: form.appointmentDate, endDate: form.appointmentDate })
|
||||
if (requestSeq !== this._availableTimeRequestSeq) return
|
||||
const businessHours = resolveBusinessHours(calendar)
|
||||
const businessHours = resolveBusinessHours(calendar, form.appointmentDate)
|
||||
const businessStartTime = businessHours.start
|
||||
const businessEndTime = businessHours.end
|
||||
if (!businessStartTime) {
|
||||
const closed = businessHours.closed === true
|
||||
const message = closed ? '预约日期门店休息,不能新建普通预约' : '门店营业时间尚未设置,请先完成设置'
|
||||
this.setData({
|
||||
businessStartTime: '',
|
||||
businessEndTime: '',
|
||||
@@ -1565,10 +1575,10 @@ Page({
|
||||
timePickerMinutes: [],
|
||||
selectedTimeCandidate: '',
|
||||
'form.appointmentTime': '',
|
||||
timeError: '门店营业时间尚未设置,请先完成设置',
|
||||
businessHoursMissing: true,
|
||||
timeError: message,
|
||||
businessHoursMissing: !closed,
|
||||
timeLoading: false,
|
||||
timeSelectTip: '请先设置门店营业时间'
|
||||
timeSelectTip: closed ? '门店休息日不可预约' : '请先设置门店营业时间'
|
||||
})
|
||||
return
|
||||
}
|
||||
@@ -1621,8 +1631,10 @@ Page({
|
||||
if (requestSeq !== this._availableTimeRequestSeq) {
|
||||
return
|
||||
}
|
||||
const businessHours = resolveBusinessHours(calendar)
|
||||
const businessHours = resolveBusinessHours(calendar, form.appointmentDate)
|
||||
if (!businessHours.start) {
|
||||
const closed = businessHours.closed === true
|
||||
const message = closed ? '预约日期门店休息,不能新建普通预约' : '门店营业时间尚未设置,请先完成设置'
|
||||
this.setData({
|
||||
businessStartTime: '',
|
||||
businessEndTime: '',
|
||||
@@ -1633,10 +1645,10 @@ Page({
|
||||
timePickerMinutes: [],
|
||||
selectedTimeCandidate: '',
|
||||
'form.appointmentTime': '',
|
||||
timeError: '门店营业时间尚未设置,请先完成设置',
|
||||
businessHoursMissing: true,
|
||||
timeError: message,
|
||||
businessHoursMissing: !closed,
|
||||
timeLoading: false,
|
||||
timeSelectTip: '请先设置门店营业时间'
|
||||
timeSelectTip: closed ? '门店休息日不可预约' : '请先设置门店营业时间'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user