保存客户与美甲师表单改造检查点

This commit is contained in:
2026-10-29 17:02:57 +08:00
parent bb3d00c51e
commit b3a8c7e01c
24 changed files with 425 additions and 60 deletions
+37 -3
View File
@@ -2,11 +2,13 @@ const employeesApi = require('../../api/employees')
const { chooseImageFilePath, uploadObjectFile } = require('../../utils/upload')
const DEFAULT_EMPLOYEE_PASSWORD = 'Fingertip@123'
const EMPLOYEE_COLORS = ['#7BA7C7', '#8FB89A', '#A894C7', '#D7A86E', '#D98DA5', '#79A6A3', '#B9A16B', '#9BA9C8']
Page({
data: {
pickerMode: false,
appointmentContext: { date: '', time: '', durationMinutes: '' },
employeeColors: EMPLOYEE_COLORS,
onboardingVisible: false,
createdEmployee: null,
form: {
@@ -15,6 +17,7 @@ Page({
account: '',
password: DEFAULT_EMPLOYEE_PASSWORD,
wechatId: '',
color: '#8FB89A',
avatar: '',
avatarUrl: ''
},
@@ -37,10 +40,15 @@ Page({
const field = event.currentTarget.dataset.field
const value = event.detail.value
const updates = { [`form.${field}`]: value }
if (field === 'phone' && !this.data.form.account) updates['form.account'] = value
if (field === 'account') this._accountManuallyEdited = true
if (field === 'phone' && !this._accountManuallyEdited) updates['form.account'] = value
this.setData(updates)
},
selectColor(event) {
this.setData({ 'form.color': event.currentTarget.dataset.color })
},
async chooseAvatar() {
if (this.data.avatarUploading || this.data.creating) return
try {
@@ -74,7 +82,7 @@ Page({
const account = String(form.account || '').trim()
const password = String(form.password || '').trim()
const wechatId = String(form.wechatId || '').trim()
if (!nickname || !phone || !account || !password || !wechatId) {
if (!nickname || !phone || !account || !password) {
wx.showToast({ title: '请补全美甲师信息', icon: 'none' })
return
}
@@ -91,6 +99,7 @@ Page({
account,
password,
wechatId,
color: form.color,
avatar: form.avatar || undefined,
type: 3
})
@@ -127,7 +136,32 @@ Page({
},
skipFirstSchedule() {
this.finishCreated(!this.data.pickerMode, false)
if (this.data.savingDefaultSchedule || !this.data.createdEmployee) return
this.setData({ savingDefaultSchedule: true })
employeesApi.saveScheduleRule({
artistId: this.data.createdEmployee.id,
presetType: 'CUSTOM',
workDays: [1, 2, 3, 4, 5, 6, 7],
startTime: '00:00',
endTime: '23:59',
status: 1,
remark: '新建美甲师默认全天可预约,可在排班设置中调整'
}).then(() => {
this.finishCreated(!this.data.pickerMode, false)
}).catch(error => {
wx.showModal({
title: '默认排班设置失败',
content: error.message || '未设置排班前,该美甲师暂不可预约。请重试或返回排班设置。',
confirmText: '重试',
cancelText: '稍后设置',
success: result => {
if (result.confirm) this.skipFirstSchedule()
else this.setData({ savingDefaultSchedule: false })
}
})
}).finally(() => {
if (this.data.onboardingVisible) this.setData({ savingDefaultSchedule: false })
})
},
finishCreated(autoSelect, scheduleSaved) {