优化店务小程序规划视图与表单加载

This commit is contained in:
2026-07-23 15:57:39 +08:00
parent 7d6929bcf6
commit 3d10affea3
8 changed files with 273 additions and 78 deletions
+54 -5
View File
@@ -266,6 +266,9 @@ Page({
pendingCount: 0,
canCreateAppointment: true,
loading: false,
loadingText: '',
pageMaskVisible: false,
pageMaskText: '',
calendarError: '',
emptyDateActionVisible: false,
pendingEmptyDate: '',
@@ -287,6 +290,7 @@ Page({
onShow() {
const app = getApp()
this.hidePageMask()
try {
const returnTarget = readPlanningReturnTarget()
if (returnTarget) {
@@ -413,6 +417,20 @@ Page({
stopTap() {},
showPageMask(text) {
this.setData({
pageMaskVisible: true,
pageMaskText: text
})
},
hidePageMask() {
this.setData({
pageMaskVisible: false,
pageMaskText: ''
})
},
selectEmptyDateSpecialType(event) {
const value = String(event.currentTarget.dataset.value || 'REST')
const option = resolveSpecialDateType(value)
@@ -469,7 +487,10 @@ Page({
const range = this.resolveRange()
const requestSeq = (this._calendarRequestSeq || 0) + 1
this._calendarRequestSeq = requestSeq
this.setData({ loading: true })
this.setData({
loading: true,
loadingText: '正在加载规划'
})
try {
const data = await planningApi.calendar({
startDate: range.start,
@@ -498,7 +519,10 @@ Page({
})
} finally {
if (requestSeq === this._calendarRequestSeq) {
this.setData({ loading: false })
this.setData({
loading: false,
loadingText: ''
})
}
}
},
@@ -610,6 +634,7 @@ Page({
: this.normalizeArtistCounts(summary.artistCounts || artistTemplate)
return {
...day,
isToday: day.date === todayText,
isPast: day.date < todayText,
totalCount: summary.totalCount || 0,
dayStatus: summary.dayStatus || 'free',
@@ -823,16 +848,27 @@ Page({
},
createAppointment() {
if (this.data.loading || this.data.pageMaskVisible) {
return
}
if (!this.data.canCreateAppointment) {
wx.showToast({ title: '美甲师账号只能查看预约', icon: 'none' })
return
}
this.showPageMask('正在打开预约表单')
wx.navigateTo({
url: buildAppointmentFormUrl(this.data.currentDateText, this.data.selectedArtistId)
url: buildAppointmentFormUrl(this.data.currentDateText, this.data.selectedArtistId),
fail: error => {
this.hidePageMask()
wx.showToast({ title: `打开预约表单失败:${error.errMsg || error.message || error}`, icon: 'none' })
}
})
},
createAppointmentFromEmptyDate() {
if (this.data.loading || this.data.pageMaskVisible) {
return
}
if (!this.data.pendingEmptyDate) {
wx.showToast({ title: '请选择预约日期', icon: 'none' })
return
@@ -842,8 +878,13 @@ Page({
return
}
this.setData({ emptyDateActionVisible: false })
this.showPageMask('正在打开预约表单')
wx.navigateTo({
url: buildAppointmentFormUrl(this.data.pendingEmptyDate, this.data.selectedArtistId)
url: buildAppointmentFormUrl(this.data.pendingEmptyDate, this.data.selectedArtistId),
fail: error => {
this.hidePageMask()
wx.showToast({ title: `打开预约表单失败:${error.errMsg || error.message || error}`, icon: 'none' })
}
})
},
@@ -893,13 +934,21 @@ Page({
},
openAppointment(event) {
if (this.data.loading || this.data.pageMaskVisible) {
return
}
const id = resolveAppointmentEventId(event)
if (!id) {
wx.showToast({ title: '缺少预约详情ID', icon: 'none' })
return
}
this.showPageMask('正在打开预约详情')
wx.navigateTo({
url: `/pages/appointment-detail/index?id=${encodeURIComponent(id)}`
url: `/pages/appointment-detail/index?id=${encodeURIComponent(id)}`,
fail: error => {
this.hidePageMask()
wx.showToast({ title: `打开预约详情失败:${error.errMsg || error.message || error}`, icon: 'none' })
}
})
}
})