Salon美甲师注册申请关联微信账号
自动发布开发环境 Nacos 配置 / publish (push) Successful in 26s

This commit is contained in:
2026-10-30 03:46:24 +08:00
parent 5a787a93f3
commit 7b40ee1650
27 changed files with 733 additions and 91 deletions
+74 -13
View File
@@ -1,7 +1,6 @@
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({
@@ -11,11 +10,15 @@ Page({
employeeColors: EMPLOYEE_COLORS,
onboardingVisible: false,
createdEmployee: null,
associationSheetVisible: false,
associationLoading: false,
associationApplications: [],
associationItems: [],
associationKeyword: '',
associationSelectedId: '',
form: {
nickname: '',
phone: '',
account: '',
password: DEFAULT_EMPLOYEE_PASSWORD,
wechatId: '',
color: '#8FB89A',
avatar: '',
@@ -39,10 +42,7 @@ Page({
onInput(event) {
const field = event.currentTarget.dataset.field
const value = event.detail.value
const updates = { [`form.${field}`]: value }
if (field === 'account') this._accountManuallyEdited = true
if (field === 'phone' && !this._accountManuallyEdited) updates['form.account'] = value
this.setData(updates)
this.setData({ [`form.${field}`]: value })
},
selectColor(event) {
@@ -79,10 +79,8 @@ Page({
const form = this.data.form
const nickname = String(form.nickname || '').trim()
const phone = String(form.phone || '').trim()
const account = String(form.account || '').trim()
const password = String(form.password || '').trim()
const wechatId = String(form.wechatId || '').trim()
if (!nickname || !phone || !account || !password) {
if (!nickname || !phone) {
wx.showToast({ title: '请补全美甲师信息', icon: 'none' })
return
}
@@ -96,8 +94,6 @@ Page({
nickname,
phone,
contactPhone: phone,
account,
password,
wechatId,
color: form.color,
avatar: form.avatar || undefined,
@@ -105,7 +101,8 @@ 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, onboardingVisible: true })
this.setData({ createdEmployee: employee })
await this.offerPendingAssociation()
} catch (error) {
wx.showToast({ title: error.message || '新增失败', icon: 'none' })
} finally {
@@ -113,6 +110,70 @@ Page({
}
},
async offerPendingAssociation() {
try {
const data = await employeesApi.unassociatedApplications()
const applications = Array.isArray(data) ? data : []
if (!applications.length) {
this.setData({ onboardingVisible: true })
return
}
const associationItems = applications.map(item => ({
id: item.id,
title: item.applicantNickname || '待审核美甲师申请',
subtitle: [item.applicantMaskedPhone, item.createTime && String(item.createTime).replace('T', ' ').slice(0, 16)].filter(Boolean).join(' · ') || '申请资料尚未审核',
meta: item.applicationNo || ''
}))
this.setData({
associationApplications: applications,
associationItems,
associationKeyword: '',
associationSelectedId: '',
associationSheetVisible: true
})
} catch (error) {
wx.showToast({ title: '申请列表暂时不可用,已继续新增员工', icon: 'none' })
this.setData({ onboardingVisible: true })
}
},
onAssociationSearch(event) {
const associationKeyword = String(event.detail.value || '').trim().toLowerCase()
const applications = this.data.associationApplications
const associationItems = applications
.filter(item => !associationKeyword || [item.applicantNickname, item.applicantMaskedPhone, item.applicationNo]
.some(value => String(value || '').toLowerCase().includes(associationKeyword)))
.map(item => ({
id: item.id,
title: item.applicantNickname || '待审核美甲师申请',
subtitle: [item.applicantMaskedPhone, item.createTime && String(item.createTime).replace('T', ' ').slice(0, 16)].filter(Boolean).join(' · ') || '申请资料尚未审核',
meta: item.applicationNo || ''
}))
this.setData({ associationKeyword, associationItems })
},
async selectAssociation(event) {
const application = event.detail && event.detail.item
const employee = this.data.createdEmployee
if (!application || !employee || !employee.id || this.data.associationLoading) return
this.setData({ associationLoading: true, associationSelectedId: application.id })
try {
await employeesApi.preAssociateApplication(application.id, employee.id)
this.setData({ associationSheetVisible: false, onboardingVisible: true })
wx.showToast({ title: '已预关联申请', icon: 'success' })
} catch (error) {
wx.showToast({ title: error.message || '关联失败,请重新选择', icon: 'none' })
this.setData({ associationSelectedId: '' })
} finally {
this.setData({ associationLoading: false })
}
},
skipAssociation() {
if (this.data.associationLoading) return
this.setData({ associationSheetVisible: false, onboardingVisible: true })
},
setupFirstSchedule() {
const employee = this.data.createdEmployee
if (!employee || !employee.id) return
@@ -1,3 +1,6 @@
{
"navigationBarTitleText": "新增美甲师"
"navigationBarTitleText": "新增美甲师",
"usingComponents": {
"entity-selector-sheet": "/components/entity-selector-sheet/index"
}
}
@@ -33,25 +33,34 @@ 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.phone, '13800138000')
assert.strictEqual(page.data.form.account, undefined)
assert.strictEqual(page.data.form.password, undefined)
assert.strictEqual(page.data.form.color, '#8FB89A')
Object.assign(page.data.form, {
nickname: '小周',
phone: '13800138000',
account: '13800138000',
password: 'Fingertip@123',
wechatId: ''
})
let createPayload
employeesApi.createUser = async payload => {
createPayload = payload
assert.strictEqual(payload.wechatId, '')
assert.strictEqual(payload.color, '#8FB89A')
return 88
}
employeesApi.unassociatedApplications = async () => []
await page.submit()
assert.deepStrictEqual(createPayload, {
nickname: '小周',
phone: '13800138000',
contactPhone: '13800138000',
wechatId: '',
color: '#8FB89A',
avatar: undefined,
type: 3
})
assert.strictEqual(page.data.onboardingVisible, true)
assert.strictEqual(emitted, undefined)
@@ -69,6 +78,25 @@ async function run() {
assert.deepStrictEqual(emitted.value, { id: 88, name: '小周', title: '小周', avatar: '', autoSelect: true, scheduleSaved: true })
assert.strictEqual(navigatedBack, true)
let associatedApplication
employeesApi.unassociatedApplications = async () => [{
id: 42,
applicantNickname: '微信昵称',
applicantMaskedPhone: '138****8000',
applicationNo: 'SALON-042'
}]
employeesApi.preAssociateApplication = async (applicationId, employeeId) => {
associatedApplication = { applicationId, employeeId }
}
page.setData({ onboardingVisible: false, associationSheetVisible: false })
await page.offerPendingAssociation()
assert.strictEqual(page.data.associationSheetVisible, true)
assert.strictEqual(page.data.associationItems[0].title, '微信昵称')
await page.selectAssociation({ detail: { item: { id: 42 } } })
assert.deepStrictEqual(associatedApplication, { applicationId: 42, employeeId: 88 })
assert.strictEqual(page.data.associationSheetVisible, false)
assert.strictEqual(page.data.onboardingVisible, true)
page.data.onboardingVisible = true
page.data.createdEmployee = { id: 88, name: '小周' }
page.data.appointmentContext = { date: '2026-10-12', time: '14:00', durationMinutes: '60' }
@@ -1,6 +1,6 @@
<view class="page no-tab employee-create-page">
<view class="create-intro">
<text class="create-title">录入美甲师账号</text>
<text class="create-title">新增美甲师档案</text>
<text class="create-subtitle">{{pickerMode ? '保存后自动选择该美甲师' : '保存后即可用于预约指定和美甲师管理'}}</text>
</view>
@@ -24,13 +24,10 @@
<text class="field-label required">手机号</text>
<input value="{{form.phone}}" data-field="phone" bindinput="onInput" type="number" maxlength="11" placeholder="请输入手机号" />
</view>
<view class="field">
<text class="field-label required">登录账号</text>
<input value="{{form.account}}" data-field="account" bindinput="onInput" placeholder="默认跟随手机号" />
</view>
<view class="field">
<text class="field-label required">初始密码</text>
<input value="{{form.password}}" data-field="password" bindinput="onInput" password placeholder="请输入初始密码" />
<view class="login-unlinked">
<text class="login-unlinked-label">微信登录</text>
<text class="login-unlinked-status">未关联</text>
<text class="login-unlinked-note">可在店长审核微信注册申请时快速关联</text>
</view>
<view class="field">
<text class="field-label">微信号</text>
@@ -58,4 +55,5 @@
<button class="onboarding-skip" loading="{{savingDefaultSchedule}}" disabled="{{savingDefaultSchedule}}" bindtap="skipFirstSchedule">{{pickerMode ? '暂不设置(默认全天可约)' : '不设置,使用默认全天排班'}}</button>
</view>
</view>
<entity-selector-sheet visible="{{associationSheetVisible}}" title="关联待审核申请" keyword="{{associationKeyword}}" placeholder="搜索申请昵称、手机号或编号" items="{{associationItems}}" selected-id="{{associationSelectedId}}" loading="{{associationLoading}}" empty-text="暂无可关联申请" action-text="暂不关联,继续" bind:search="onAssociationSearch" bind:select="selectAssociation" bind:action="skipAssociation" bind:close="skipAssociation" />
</view>
@@ -25,6 +25,20 @@
font-size: 23rpx;
}
.login-unlinked {
display: flex;
flex-wrap: wrap;
align-items: center;
margin: 24rpx 0 4rpx;
padding: 22rpx 24rpx;
border-radius: 14rpx;
background: #edf6ef;
}
.login-unlinked-label { color: #536b5d; font-size: 24rpx; font-weight: 700; }
.login-unlinked-status { margin-left: 18rpx; color: #247b63; font-size: 24rpx; font-weight: 700; }
.login-unlinked-note { flex-basis: 100%; margin-top: 10rpx; color: #829287; font-size: 21rpx; }
.avatar-card {
display: flex;
align-items: center;