完善注册资料必填校验与驳回重申流程
This commit is contained in:
@@ -3,7 +3,7 @@ const authApi = require('../../api/auth')
|
||||
Page({
|
||||
data: {
|
||||
step: 1,
|
||||
role: 'manager',
|
||||
role: '',
|
||||
form: { shopName: '', shopAddress: '', shopId: '', shopLongitude: '', shopLatitude: '', applicantNickname: '', applicantAvatarFileId: '', applicantAvatarUrl: '' },
|
||||
registrationTicket: '',
|
||||
applicationId: '',
|
||||
@@ -20,15 +20,21 @@ Page({
|
||||
registrationStatus: null,
|
||||
registrationStatusText: '',
|
||||
contentStatusText: '',
|
||||
contentStatusReason: ''
|
||||
contentStatusReason: '',
|
||||
applicationSubmittedAt: ''
|
||||
},
|
||||
|
||||
async onLoad(options) {
|
||||
const registrationTicket = options && options.registrationTicket ? options.registrationTicket : ''
|
||||
const roleCode = String(options && options.role || '').toUpperCase()
|
||||
const role = roleCode === 'STAFF' ? 'staff' : roleCode === 'MANAGER' ? 'manager' : ''
|
||||
const applicationId = options && options.applicationId ? options.applicationId : ''
|
||||
this.setData({
|
||||
registrationTicket,
|
||||
applicationId: options && options.applicationId ? options.applicationId : '',
|
||||
ticketInvalid: !registrationTicket
|
||||
applicationId,
|
||||
ticketInvalid: !registrationTicket,
|
||||
role,
|
||||
step: applicationId ? 2 : 1
|
||||
})
|
||||
await this.loadShops()
|
||||
},
|
||||
@@ -93,8 +99,18 @@ Page({
|
||||
this.setData({ avatarUploading: false })
|
||||
}
|
||||
},
|
||||
selectRole(event) { this.setData({ role: event.currentTarget.dataset.role }) },
|
||||
continueFromRole() { if (!this.data.ticketInvalid) this.setData({ step: 2 }) },
|
||||
selectRole(event) {
|
||||
const role = event.currentTarget.dataset.role
|
||||
if (role === 'manager' || role === 'staff') this.setData({ role })
|
||||
},
|
||||
continueFromRole() {
|
||||
if (this.data.ticketInvalid) return
|
||||
if (!this.data.role) {
|
||||
wx.showToast({ title: '请选择工作身份', icon: 'none' })
|
||||
return
|
||||
}
|
||||
this.setData({ step: 2 })
|
||||
},
|
||||
|
||||
filterShops(shops, keywordValue) {
|
||||
const keyword = String(keywordValue || '').trim().toLowerCase()
|
||||
@@ -147,6 +163,11 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
formatSubmissionTime(date = new Date()) {
|
||||
const pad = value => String(value).padStart(2, '0')
|
||||
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}`
|
||||
},
|
||||
|
||||
async submit() {
|
||||
const form = this.data.form
|
||||
if (!this.data.registrationTicket) {
|
||||
@@ -159,6 +180,12 @@ Page({
|
||||
if (this.data.role === 'staff' && !form.shopId) {
|
||||
wx.showToast({ title: '请选择要加入的店铺', icon: 'none' }); return
|
||||
}
|
||||
if (this.data.role === 'staff' && !String(form.applicantNickname || '').trim()) {
|
||||
wx.showToast({ title: '请输入昵称', icon: 'none' }); return
|
||||
}
|
||||
if (this.data.role === 'staff' && !form.applicantAvatarFileId) {
|
||||
wx.showToast({ title: '请选择头像', icon: 'none' }); return
|
||||
}
|
||||
this.setData({ loading: true })
|
||||
try {
|
||||
const result = await authApi.register({
|
||||
@@ -174,7 +201,7 @@ Page({
|
||||
applicantAvatarFileId: this.data.role === 'staff' ? form.applicantAvatarFileId || undefined : undefined,
|
||||
agreementAccepted: true
|
||||
})
|
||||
this.setData({ step: 3, registrationTicket: '', ...this.mapRegistrationStatus(result) })
|
||||
this.setData({ step: 3, registrationTicket: '', applicationSubmittedAt: this.formatSubmissionTime(), ...this.mapRegistrationStatus(result) })
|
||||
} catch (error) {
|
||||
const message = String(error.message || '提交失败')
|
||||
if (/注册票据|注册凭证|一次性.*(失效|消费)|票据.*(失效|过期|已使用)/.test(message)) {
|
||||
@@ -187,5 +214,7 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
back() { wx.reLaunch({ url: '/pages/login/index' }) }
|
||||
back() { wx.reLaunch({ url: '/pages/login/index' }) },
|
||||
|
||||
reapply() { wx.reLaunch({ url: '/pages/login/index' }) }
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user