完善管理师预约项目与美甲师创建

This commit is contained in:
2026-06-24 20:54:41 +08:00
parent 03c972d90c
commit eda109cb62
28 changed files with 911 additions and 32 deletions
+78 -2
View File
@@ -3,7 +3,16 @@ const mock = require('../../utils/mock')
Page({
data: {
employees: []
employees: [],
createModalVisible: false,
creating: false,
createForm: {
nickname: '',
phone: '',
account: '',
password: '888888',
wechatId: ''
}
},
onLoad() {
@@ -39,6 +48,73 @@ Page({
},
addEmployee() {
wx.showToast({ title: '员工创建沿用后台账号', icon: 'none' })
this.setData({ createModalVisible: true })
},
closeCreateModal() {
if (this.data.creating) {
return
}
this.setData({ createModalVisible: false })
},
stopTap() {
},
onCreateInput(event) {
const field = event.currentTarget.dataset.field
const value = event.detail.value
const updates = {
[`createForm.${field}`]: value
}
if (field === 'phone' && !this.data.createForm.account) {
updates['createForm.account'] = value
}
this.setData(updates)
},
resetCreateForm() {
this.setData({
createForm: {
nickname: '',
phone: '',
account: '',
password: '888888',
wechatId: ''
}
})
},
async submitEmployee() {
const form = this.data.createForm
const nickname = String(form.nickname || '').trim()
const phone = String(form.phone || '').trim()
const account = String(form.account || '').trim()
const password = String(form.password || '').trim()
const wechatId = String(form.wechatId || '').trim()
if (!nickname || !phone || !account || !password || !wechatId) {
wx.showToast({ title: '请补全美甲师信息', icon: 'none' })
return
}
this.setData({ creating: true })
try {
await employeesApi.createUser({
nickname,
phone,
contactPhone: phone,
account,
password,
wechatId,
type: 3
})
wx.showToast({ title: '美甲师已新增', icon: 'success' })
this.resetCreateForm()
this.setData({ createModalVisible: false })
await this.loadEmployees()
} catch (error) {
wx.showToast({ title: error.message || '新增失败', icon: 'none' })
} finally {
this.setData({ creating: false })
}
}
})