修复回归安全问题并补充验证

This commit is contained in:
xiaowang
2026-06-05 16:10:58 +08:00
parent 784bb0a965
commit 74f8fa5f4e
46 changed files with 917 additions and 311 deletions
@@ -1,7 +1,18 @@
const planningApi = require('../../api/planning')
const config = require('../../utils/config')
const mock = require('../../utils/mock')
const dateUtil = require('../../utils/date')
const normalizeArtists = artists => (artists || []).map((item, index) => ({
id: item.id || item.userId || item.artistId,
name: item.name || item.nickname || item.artistName || `美甲师${index + 1}`,
shortName: item.shortName || String(item.name || item.nickname || '师').slice(-1),
color: item.color || ['#7BA7C7', '#89A98B', '#A893BC', '#D49A89'][index % 4],
statusText: item.statusText || '可接单',
availableStatus: item.availableStatus || 'free',
availableText: item.availableText || '可接'
}))
Page({
data: {
id: '',
@@ -9,18 +20,35 @@ Page({
selectedArtistId: '',
date: dateUtil.formatDate(new Date()),
time: '13:00',
loading: false
loading: false,
loadError: false,
errorMessage: ''
},
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 ? '已满' : '可接'
}))
})
onLoad(options = {}) {
this.setData({ id: options.id || '' })
this.loadArtists()
},
async loadArtists() {
this.setData({ loadError: false, errorMessage: '' })
try {
const calendar = await planningApi.calendar({
startDate: this.data.date,
endDate: this.data.date
})
this.setData({ artists: normalizeArtists(calendar.artists || []) })
} catch (error) {
if (config.USE_DEV_MOCK_DATA) {
this.setData({ artists: normalizeArtists(mock.artists) })
} else {
this.setData({
artists: [],
loadError: true,
errorMessage: error.message || '美甲师可接状态加载失败,请检查服务连接后重试'
})
}
}
},
selectArtist(event) {
@@ -28,7 +56,8 @@ Page({
},
onDateChange(event) {
this.setData({ date: event.detail.value })
this.setData({ date: event.detail.value, selectedArtistId: '' })
this.loadArtists()
},
onTimeChange(event) {
@@ -36,6 +65,10 @@ Page({
},
async submit() {
if (this.data.loadError) {
wx.showToast({ title: '请先重新加载可接员工', icon: 'none' })
return
}
if (!this.data.selectedArtistId) {
wx.showToast({ title: '请选择美甲师', icon: 'none' })
return