保存客户与美甲师表单改造检查点
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -34,19 +34,33 @@ const page = {
|
||||
async function run() {
|
||||
page.onInput({ currentTarget: { dataset: { field: 'phone' } }, detail: { value: '13800138000' } })
|
||||
assert.strictEqual(page.data.form.account, '13800138000')
|
||||
page.onInput({ currentTarget: { dataset: { field: 'account' } }, detail: { value: 'staff_zhou' } })
|
||||
page.onInput({ currentTarget: { dataset: { field: 'phone' } }, detail: { value: '13900139000' } })
|
||||
assert.strictEqual(page.data.form.account, 'staff_zhou')
|
||||
assert.strictEqual(page.data.form.color, '#8FB89A')
|
||||
Object.assign(page.data.form, {
|
||||
nickname: '小周',
|
||||
phone: '13800138000',
|
||||
account: '13800138000',
|
||||
password: 'Fingertip@123',
|
||||
wechatId: 'wx_zhou'
|
||||
wechatId: ''
|
||||
})
|
||||
employeesApi.createUser = async () => 88
|
||||
employeesApi.createUser = async payload => {
|
||||
assert.strictEqual(payload.wechatId, '')
|
||||
assert.strictEqual(payload.color, '#8FB89A')
|
||||
return 88
|
||||
}
|
||||
await page.submit()
|
||||
assert.strictEqual(page.data.onboardingVisible, true)
|
||||
assert.strictEqual(emitted, undefined)
|
||||
page.data.pickerMode = true
|
||||
employeesApi.saveScheduleRule = async payload => {
|
||||
assert.deepStrictEqual(payload.workDays, [1, 2, 3, 4, 5, 6, 7])
|
||||
assert.strictEqual(payload.startTime, '00:00')
|
||||
assert.strictEqual(payload.endTime, '23:59')
|
||||
}
|
||||
page.skipFirstSchedule()
|
||||
await new Promise(resolve => setImmediate(resolve))
|
||||
assert.strictEqual(emitted.name, 'employeeCreated')
|
||||
assert.deepStrictEqual(emitted.value, { id: 88, name: '小周', title: '小周', avatar: '', autoSelect: false, scheduleSaved: false })
|
||||
assert.strictEqual(navigatedBack, true)
|
||||
|
||||
@@ -33,8 +33,14 @@
|
||||
<input value="{{form.password}}" data-field="password" bindinput="onInput" password placeholder="请输入初始密码" />
|
||||
</view>
|
||||
<view class="field">
|
||||
<text class="field-label required">微信号</text>
|
||||
<input value="{{form.wechatId}}" data-field="wechatId" bindinput="onInput" placeholder="请输入微信号" />
|
||||
<text class="field-label">微信号</text>
|
||||
<input value="{{form.wechatId}}" data-field="wechatId" bindinput="onInput" placeholder="选填" />
|
||||
</view>
|
||||
<view class="field color-field">
|
||||
<text class="field-label required">专属颜色</text>
|
||||
<view class="color-options">
|
||||
<view wx:for="{{employeeColors}}" wx:key="*this" class="color-option {{form.color === item ? 'selected' : ''}}" style="background: {{item}};" data-color="{{item}}" bindtap="selectColor"></view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -47,8 +53,8 @@
|
||||
<view class="onboarding-icon">✓</view>
|
||||
<text class="onboarding-title">美甲师已创建</text>
|
||||
<text class="onboarding-desc">{{pickerMode ? '设置常规排班后,可继续把当前预约分配给该美甲师。' : '为新美甲师设置首个常规排班,之后即可正常承接预约。'}}</text>
|
||||
<button class="primary-btn onboarding-primary" bindtap="setupFirstSchedule">{{pickerMode ? '设置排班并分配' : '立即设置排班'}}</button>
|
||||
<button class="onboarding-skip" bindtap="skipFirstSchedule">{{pickerMode ? '暂不设置' : '稍后设置'}}</button>
|
||||
<button class="primary-btn onboarding-primary" loading="{{savingDefaultSchedule}}" disabled="{{savingDefaultSchedule}}" bindtap="setupFirstSchedule">{{pickerMode ? '设置排班并分配' : '立即设置排班'}}</button>
|
||||
<button class="onboarding-skip" loading="{{savingDefaultSchedule}}" disabled="{{savingDefaultSchedule}}" bindtap="skipFirstSchedule">{{pickerMode ? '暂不设置' : '稍后设置(默认全天可约)'}}</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -80,6 +80,25 @@
|
||||
width: 176rpx;
|
||||
}
|
||||
|
||||
.color-options {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 18rpx;
|
||||
padding: 10rpx 0;
|
||||
}
|
||||
|
||||
.color-option {
|
||||
width: 44rpx;
|
||||
height: 44rpx;
|
||||
border: 4rpx solid #fff;
|
||||
border-radius: 50%;
|
||||
box-shadow: 0 0 0 1rpx #d9e3dd;
|
||||
}
|
||||
|
||||
.color-option.selected {
|
||||
box-shadow: 0 0 0 4rpx #287a62;
|
||||
}
|
||||
|
||||
.onboarding-mask {
|
||||
position: fixed;
|
||||
z-index: 50;
|
||||
|
||||
Reference in New Issue
Block a user