65 lines
1.4 KiB
JavaScript
65 lines
1.4 KiB
JavaScript
const planningApi = require('../../api/planning')
|
|
const mock = require('../../utils/mock')
|
|
|
|
Page({
|
|
data: {
|
|
id: '',
|
|
appointment: {},
|
|
avatarText: '',
|
|
timeText: ''
|
|
},
|
|
|
|
onLoad(options) {
|
|
this.setData({ id: options.id || '' })
|
|
this.loadDetail()
|
|
},
|
|
|
|
async loadDetail() {
|
|
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)
|
|
}
|
|
},
|
|
|
|
applyAppointment(appointment) {
|
|
this.setData({
|
|
appointment,
|
|
avatarText: String(appointment.customerName || '客').slice(0, 1),
|
|
timeText: `${(appointment.startTime || '').slice(0, 16)} - ${(appointment.endTime || '').slice(11, 16)}`
|
|
})
|
|
},
|
|
|
|
async updateStatus(status) {
|
|
try {
|
|
await planningApi.updateStatus(this.data.appointment.orderId, status)
|
|
wx.showToast({ title: '已更新' })
|
|
this.loadDetail()
|
|
} catch (error) {
|
|
wx.showToast({ title: error.message || '操作失败', icon: 'none' })
|
|
}
|
|
},
|
|
|
|
confirm() {
|
|
this.updateStatus(1)
|
|
},
|
|
|
|
complete() {
|
|
this.updateStatus(2)
|
|
},
|
|
|
|
cancel() {
|
|
this.updateStatus(3)
|
|
},
|
|
|
|
goTransfer() {
|
|
wx.navigateTo({ url: `/pages/artist-transfer/index?id=${this.data.id}` })
|
|
},
|
|
|
|
back() {
|
|
wx.navigateBack()
|
|
}
|
|
})
|