完善店员申请关联与预约页面
自动发布开发环境 Nacos 配置 / publish (push) Successful in 21s
环境分支晋级检查 / environment-promotion-source (pull_request_target) Successful in 8s

This commit is contained in:
2026-11-03 23:29:40 +08:00
parent 1fc46f3835
commit 4b4c1ddef5
18 changed files with 442 additions and 64 deletions
+57 -3
View File
@@ -7,6 +7,7 @@ Page({
data: {
pickerMode: false,
appointmentContext: { date: '', time: '', durationMinutes: '' },
applicationId: '',
employeeColors: EMPLOYEE_COLORS,
onboardingVisible: false,
createdEmployee: null,
@@ -35,7 +36,9 @@ Page({
date: options.date || '',
time: options.time || '',
durationMinutes: options.durationMinutes || ''
}
},
applicationId: options.applicationId || '',
applicationNo: options.applicationNo || ''
})
},
@@ -81,6 +84,12 @@ Page({
},
async submit() {
if (this.data.creating || this.data.avatarUploading) return
if (this.data.createdEmployee) {
if (this.data.applicationId && !this.data.applicationApproved) return this.associateCreatedEmployee()
this.setData({ onboardingVisible: true })
return
}
const form = this.data.form
const nickname = String(form.nickname || '').trim()
const phone = String(form.phone || '').trim()
@@ -106,7 +115,11 @@ Page({
})
const id = result && typeof result === 'object' ? (result.id || result.userId) : result
const employee = { id, name: nickname, title: nickname, avatar: form.avatar || '' }
this.setData({ createdEmployee: employee })
this.setData({ createdEmployee: employee, applicationApproved: false })
if (this.data.applicationId) {
await this.associateCreatedEmployee()
return
}
await this.offerPendingAssociation()
} catch (error) {
wx.showToast({ title: error.message || '新增失败', icon: 'none' })
@@ -115,6 +128,33 @@ Page({
}
},
async associateCreatedEmployee() {
const employee = this.data.createdEmployee
if (!employee || !employee.id || !this.data.applicationId || this.data.associatingApplication) return
this.setData({ associatingApplication: true })
try {
await employeesApi.approveApplication(this.data.applicationId, {
targetArtistUserId: employee.id,
useApplicantNickname: false,
useApplicantAvatar: false
})
this.setData({ applicationApproved: true, associatingApplication: false, onboardingVisible: true })
wx.showToast({ title: '已关联并通过审核', icon: 'success' })
} catch (error) {
this.setData({ associatingApplication: false })
wx.showModal({
title: '关联审核未完成',
content: error.message || '美甲师档案已创建,可重试关联申请。',
confirmText: '重试',
cancelText: '稍后处理',
success: result => {
if (result.confirm) this.associateCreatedEmployee()
else this.setData({ onboardingVisible: true })
}
})
}
},
async offerPendingAssociation() {
try {
const data = await employeesApi.unassociatedApplications()
@@ -180,6 +220,7 @@ Page({
},
setupFirstSchedule() {
if (this.data.applicationId && !this.data.applicationApproved) return
const employee = this.data.createdEmployee
if (!employee || !employee.id) return
const context = this.data.appointmentContext
@@ -202,7 +243,7 @@ Page({
},
skipFirstSchedule() {
if (this.data.savingDefaultSchedule || !this.data.createdEmployee) return
if (this.data.savingDefaultSchedule || !this.data.createdEmployee || (this.data.applicationId && !this.data.applicationApproved)) return
this.setData({ savingDefaultSchedule: true })
employeesApi.saveScheduleRule({
artistId: this.data.createdEmployee.id,
@@ -231,6 +272,10 @@ Page({
},
finishCreated(autoSelect, scheduleSaved) {
if (this.data.applicationId && !this.data.applicationApproved) {
this.setData({ onboardingVisible: true })
return
}
const employee = this.data.createdEmployee
const eventChannel = this.getOpenerEventChannel && this.getOpenerEventChannel()
if (eventChannel && eventChannel.emit) {
@@ -239,5 +284,14 @@ Page({
this.setData({ onboardingVisible: false })
wx.showToast({ title: scheduleSaved ? '排班已保存' : '美甲师已新增', icon: 'success' })
setTimeout(() => wx.navigateBack(), 300)
},
leaveAssociationForLater() {
const employee = this.data.createdEmployee
const eventChannel = this.getOpenerEventChannel && this.getOpenerEventChannel()
if (eventChannel && eventChannel.emit && employee) {
eventChannel.emit('employeeCreated', { ...employee, autoSelect: this.data.pickerMode, scheduleSaved: false })
}
wx.navigateBack()
}
})