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