修复管理师端预约与登录体验
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
const planningApi = require('../../api/planning')
|
||||
const mock = require('../../utils/mock')
|
||||
const dateUtil = require('../../utils/date')
|
||||
|
||||
Page({
|
||||
@@ -9,26 +8,49 @@ Page({
|
||||
selectedArtistId: '',
|
||||
date: dateUtil.formatDate(new Date()),
|
||||
time: '13:00',
|
||||
loadError: '',
|
||||
loading: false
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
this.setData({
|
||||
id: options.id || '',
|
||||
artists: mock.artists.map((item, index) => ({
|
||||
...item,
|
||||
availableStatus: index === 1 ? 'busy' : index === 2 ? 'full' : 'free',
|
||||
availableText: index === 1 ? '有冲突' : index === 2 ? '已满' : '可接'
|
||||
}))
|
||||
id: options.id || ''
|
||||
})
|
||||
this.loadArtists()
|
||||
},
|
||||
|
||||
async loadArtists() {
|
||||
try {
|
||||
const calendar = await planningApi.calendar({
|
||||
startDate: this.data.date,
|
||||
endDate: this.data.date
|
||||
})
|
||||
const artists = Array.isArray(calendar.artists) ? calendar.artists : []
|
||||
this.setData({
|
||||
artists: artists.map(item => ({
|
||||
...item,
|
||||
availableStatus: 'free',
|
||||
availableText: '可选择'
|
||||
})),
|
||||
selectedArtistId: '',
|
||||
loadError: ''
|
||||
})
|
||||
} catch (error) {
|
||||
this.setData({
|
||||
artists: [],
|
||||
selectedArtistId: '',
|
||||
loadError: error.message || '美甲师列表加载失败'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
selectArtist(event) {
|
||||
this.setData({ selectedArtistId: event.currentTarget.dataset.id })
|
||||
},
|
||||
|
||||
onDateChange(event) {
|
||||
async onDateChange(event) {
|
||||
this.setData({ date: event.detail.value })
|
||||
await this.loadArtists()
|
||||
},
|
||||
|
||||
onTimeChange(event) {
|
||||
|
||||
Reference in New Issue
Block a user