修复回归安全问题并补充验证
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
const planningApi = require('../../api/planning')
|
||||
const config = require('../../utils/config')
|
||||
const mock = require('../../utils/mock')
|
||||
|
||||
Page({
|
||||
@@ -6,21 +7,34 @@ Page({
|
||||
id: '',
|
||||
appointment: {},
|
||||
avatarText: '',
|
||||
timeText: ''
|
||||
timeText: '',
|
||||
loadError: false,
|
||||
errorMessage: ''
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
onLoad(options = {}) {
|
||||
this.setData({ id: options.id || '' })
|
||||
this.loadDetail()
|
||||
},
|
||||
|
||||
async loadDetail() {
|
||||
this.setData({ loadError: false, errorMessage: '' })
|
||||
try {
|
||||
const appointment = await planningApi.appointment(this.data.id)
|
||||
this.applyAppointment(appointment)
|
||||
} catch (error) {
|
||||
const demo = mock.buildCalendar(new Date()).appointments[0]
|
||||
this.applyAppointment(demo)
|
||||
if (config.USE_DEV_MOCK_DATA) {
|
||||
const demo = mock.buildCalendar(new Date()).appointments[0]
|
||||
this.applyAppointment(demo)
|
||||
} else {
|
||||
this.setData({
|
||||
appointment: {},
|
||||
avatarText: '',
|
||||
timeText: '',
|
||||
loadError: true,
|
||||
errorMessage: error.message || '预约详情加载失败,请检查服务连接后重试'
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -28,11 +42,17 @@ Page({
|
||||
this.setData({
|
||||
appointment,
|
||||
avatarText: String(appointment.customerName || '客').slice(0, 1),
|
||||
timeText: `${(appointment.startTime || '').slice(0, 16)} - ${(appointment.endTime || '').slice(11, 16)}`
|
||||
timeText: `${(appointment.startTime || '').slice(0, 16)} - ${(appointment.endTime || '').slice(11, 16)}`,
|
||||
loadError: false,
|
||||
errorMessage: ''
|
||||
})
|
||||
},
|
||||
|
||||
async updateStatus(status) {
|
||||
if (!this.data.appointment.orderId) {
|
||||
wx.showToast({ title: '预约数据未加载', icon: 'none' })
|
||||
return
|
||||
}
|
||||
try {
|
||||
await planningApi.updateStatus(this.data.appointment.orderId, status)
|
||||
wx.showToast({ title: '已更新' })
|
||||
|
||||
Reference in New Issue
Block a user