修复回归安全问题并补充验证
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
const employeesApi = require('../../api/employees')
|
||||
const mock = require('../../utils/mock')
|
||||
|
||||
const EMPLOYEE_COLORS = ['#7BA7C7', '#89A98B', '#A893BC', '#D49A89', '#C9A66B', '#7E9A9A']
|
||||
|
||||
Page({
|
||||
data: {
|
||||
employees: []
|
||||
employees: [],
|
||||
loadError: false,
|
||||
errorMessage: ''
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
@@ -11,11 +14,7 @@ Page({
|
||||
},
|
||||
|
||||
async loadEmployees() {
|
||||
const fallback = mock.artists.map((item, index) => ({
|
||||
...item,
|
||||
monthOrders: 32 - index * 5,
|
||||
monthAmount: 5800 - index * 760
|
||||
}))
|
||||
this.setData({ loadError: false, errorMessage: '' })
|
||||
try {
|
||||
const data = await employeesApi.list({ page: 1, size: 50 })
|
||||
const list = data.list || data || []
|
||||
@@ -24,13 +23,17 @@ Page({
|
||||
id: item.userId || item.id,
|
||||
name: item.nickname || item.name || item.artistName || `美甲师${index + 1}`,
|
||||
shortName: (item.nickname || item.name || '师').slice(-1),
|
||||
color: mock.artists[index % mock.artists.length].color,
|
||||
color: item.color || EMPLOYEE_COLORS[index % EMPLOYEE_COLORS.length],
|
||||
monthOrders: item.monthOrders || item.orderCount || 0,
|
||||
monthAmount: item.monthAmount || item.turnover || 0
|
||||
}))
|
||||
})
|
||||
} catch (error) {
|
||||
this.setData({ employees: fallback })
|
||||
this.setData({
|
||||
employees: [],
|
||||
loadError: true,
|
||||
errorMessage: error.message || '员工数据加载失败,请检查服务连接后重试'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user