小程序页面视觉对齐二期:预约图片轮播、订单数据预览、微信用户关联与请假管理
新增预约详情作品图片轮播字段与组装;新增订单预览与未关联微信用户候选接口;补齐请假记录查询接口;订单数据预览改为四列;请假管理接入真实排班例外并支持新增;日程、我的、美甲师详情与改派选择器按设计稿微调;注册结果页与申请提交时间对齐设计稿。
This commit is contained in:
@@ -12,6 +12,13 @@ Page({
|
||||
employeeColors: EMPLOYEE_COLORS,
|
||||
onboardingVisible: false,
|
||||
createdEmployee: null,
|
||||
userPickerVisible: false,
|
||||
userLoading: false,
|
||||
userKeyword: '',
|
||||
userCandidates: [],
|
||||
userItems: [],
|
||||
selectedWechatUserId: '',
|
||||
selectedWechatUser: null,
|
||||
associationSheetVisible: false,
|
||||
associationLoading: false,
|
||||
associationApplications: [],
|
||||
@@ -53,6 +60,68 @@ Page({
|
||||
this.setData({ 'form.color': event.currentTarget.dataset.color })
|
||||
},
|
||||
|
||||
async openUserPicker() {
|
||||
if (this.data.creating || this.data.avatarUploading) return
|
||||
this.setData({ userPickerVisible: true, userLoading: true, userKeyword: '' })
|
||||
try {
|
||||
const list = await employeesApi.unlinkedCandidates()
|
||||
this.applyUserCandidates(Array.isArray(list) ? list : (list && list.list) || [])
|
||||
} catch (error) {
|
||||
showErrorToast(error, '微信用户加载失败')
|
||||
} finally {
|
||||
this.setData({ userLoading: false })
|
||||
}
|
||||
},
|
||||
|
||||
applyUserCandidates(candidates) {
|
||||
this.setData({
|
||||
userCandidates: candidates,
|
||||
userItems: candidates.map(item => ({
|
||||
id: String(item.id),
|
||||
title: item.nickname || '微信用户',
|
||||
subtitle: [item.maskedPhone || item.phone, item.createTime && String(item.createTime).replace('T', ' ').slice(0, 10)].filter(Boolean).join(' · ') || '已登录小程序',
|
||||
meta: item.wechatId || '',
|
||||
avatar: item.avatar || ''
|
||||
}))
|
||||
})
|
||||
},
|
||||
|
||||
onUserSearch(event) {
|
||||
const userKeyword = String(event.detail.value || '').trim().toLowerCase()
|
||||
const candidates = this.data.userCandidates
|
||||
const userItems = candidates
|
||||
.filter(item => !userKeyword || [item.nickname, item.maskedPhone, item.phone, item.wechatId]
|
||||
.some(value => String(value || '').toLowerCase().includes(userKeyword)))
|
||||
.map(item => ({
|
||||
id: String(item.id),
|
||||
title: item.nickname || '微信用户',
|
||||
subtitle: [item.maskedPhone || item.phone, item.createTime && String(item.createTime).replace('T', ' ').slice(0, 10)].filter(Boolean).join(' · ') || '已登录小程序',
|
||||
meta: item.wechatId || '',
|
||||
avatar: item.avatar || ''
|
||||
}))
|
||||
this.setData({ userKeyword, userItems })
|
||||
},
|
||||
|
||||
selectWechatUser(event) {
|
||||
const item = event.detail && event.detail.item
|
||||
if (!item) return
|
||||
const candidate = this.data.userCandidates.find(user => String(user.id) === String(item.id))
|
||||
if (!candidate) return
|
||||
this.setData({
|
||||
userPickerVisible: false,
|
||||
selectedWechatUserId: String(candidate.id),
|
||||
selectedWechatUser: item,
|
||||
'form.nickname': candidate.nickname || '',
|
||||
'form.avatar': candidate.avatar || '',
|
||||
'form.avatarUrl': candidate.avatar || ''
|
||||
})
|
||||
},
|
||||
|
||||
closeUserPicker() {
|
||||
if (this.data.userLoading) return
|
||||
this.setData({ userPickerVisible: false })
|
||||
},
|
||||
|
||||
async chooseAvatar() {
|
||||
if (this.data.avatarUploading || this.data.creating) return
|
||||
try {
|
||||
@@ -95,6 +164,32 @@ Page({
|
||||
const nickname = String(form.nickname || '').trim()
|
||||
const phone = String(form.phone || '').trim()
|
||||
const wechatId = String(form.wechatId || '').trim()
|
||||
if (this.data.selectedWechatUserId) {
|
||||
if (!nickname) {
|
||||
wx.showToast({ title: '请填写美甲师姓名', icon: 'none' })
|
||||
return
|
||||
}
|
||||
this.setData({ creating: true })
|
||||
try {
|
||||
const saved = await employeesApi.save({
|
||||
userId: this.data.selectedWechatUserId,
|
||||
nickname,
|
||||
color: form.color,
|
||||
avatar: form.avatar || undefined
|
||||
})
|
||||
const id = saved && typeof saved === 'object' ? (saved.userId || saved.id) : this.data.selectedWechatUserId
|
||||
this.setData({
|
||||
createdEmployee: { id, name: nickname, title: nickname, avatar: form.avatar || '' },
|
||||
applicationApproved: false
|
||||
})
|
||||
await this.offerPendingAssociation()
|
||||
} catch (error) {
|
||||
showErrorToast(error, '新增失败')
|
||||
} finally {
|
||||
this.setData({ creating: false })
|
||||
}
|
||||
return
|
||||
}
|
||||
if (!nickname || !phone) {
|
||||
wx.showToast({ title: '请补全美甲师信息', icon: 'none' })
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user