实现预约草稿和资料头像编辑
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
const employeesApi = require('../../api/employees')
|
||||
const { chooseImageFilePath, uploadObjectFile } = require('../../utils/upload')
|
||||
|
||||
const EMPLOYEE_COLORS = ['#7AA9C2', '#8EB99B', '#BDA7D8', '#D7B17D', '#D98D8D']
|
||||
const DEFAULT_EMPLOYEE_PASSWORD = 'Fingertip@123'
|
||||
@@ -20,8 +21,11 @@ Page({
|
||||
phone: '',
|
||||
account: '',
|
||||
password: DEFAULT_EMPLOYEE_PASSWORD,
|
||||
wechatId: ''
|
||||
}
|
||||
wechatId: '',
|
||||
avatar: '',
|
||||
avatarUrl: ''
|
||||
},
|
||||
avatarUploading: false
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
@@ -90,11 +94,43 @@ Page({
|
||||
phone: '',
|
||||
account: '',
|
||||
password: DEFAULT_EMPLOYEE_PASSWORD,
|
||||
wechatId: ''
|
||||
wechatId: '',
|
||||
avatar: '',
|
||||
avatarUrl: ''
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
async chooseEmployeeAvatar() {
|
||||
if (this.data.avatarUploading || this.data.creating) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
const filePath = await chooseImageFilePath()
|
||||
if (!filePath) {
|
||||
return
|
||||
}
|
||||
this.setData({ avatarUploading: true })
|
||||
const uploadResult = await uploadObjectFile(filePath)
|
||||
const avatarUrl = uploadResult.fileUrl || uploadResult.primaryUrl || filePath
|
||||
this.setData({
|
||||
'createForm.avatar': avatarUrl,
|
||||
'createForm.avatarUrl': avatarUrl
|
||||
})
|
||||
} catch (error) {
|
||||
wx.showToast({ title: error.message || '头像上传失败', icon: 'none' })
|
||||
} finally {
|
||||
this.setData({ avatarUploading: false })
|
||||
}
|
||||
},
|
||||
|
||||
removeEmployeeAvatar() {
|
||||
this.setData({
|
||||
'createForm.avatar': '',
|
||||
'createForm.avatarUrl': ''
|
||||
})
|
||||
},
|
||||
|
||||
async submitEmployee() {
|
||||
const form = this.data.createForm
|
||||
const nickname = String(form.nickname || '').trim()
|
||||
@@ -115,6 +151,7 @@ Page({
|
||||
account,
|
||||
password,
|
||||
wechatId,
|
||||
avatar: form.avatar || undefined,
|
||||
type: 3
|
||||
})
|
||||
wx.showToast({ title: '美甲师已新增', icon: 'success' })
|
||||
|
||||
Reference in New Issue
Block a user