实现手机号登录自动进入注册审核流程
发布 Nacos 配置 / publish (push) Successful in 27s
Salon 生产发布准备 / prepare (pull_request) Has been skipped

This commit is contained in:
2026-09-08 22:12:29 +08:00
parent c849f44787
commit 8d84cb25d4
11 changed files with 265 additions and 34 deletions
+24
View File
@@ -276,6 +276,26 @@ Page({
return null
},
openRegistrationFlow(data) {
const ticket = String(data.registrationTicket || '').trim()
const status = data.registrationStatus
if (status === 'PENDING_ADMIN' || status === 'PENDING_MANAGER') {
wx.showToast({ title: status === 'PENDING_ADMIN' ? '管理员审核中' : '店长审核中', icon: 'none', duration: 2500 })
return
}
if (!ticket) {
wx.showToast({ title: data.registrationRejectReason || '该手机号需要先完成身份注册', icon: 'none', duration: 2200 })
return
}
wx.showToast({ title: '手机号已验证,请完成身份注册', icon: 'none', duration: 1600 })
const query = [
`registrationTicket=${encodeURIComponent(ticket)}`,
`phone=${encodeURIComponent(data.phone || this.data.form.phone || '')}`,
data.registrationApplicationId ? `applicationId=${encodeURIComponent(data.registrationApplicationId)}` : ''
].filter(Boolean).join('&')
setTimeout(() => wx.navigateTo({ url: `/pages/register/index?${query}` }), 700)
},
buildLoginRequestData(shopId) {
const form = this.data.form
if (this.data.loginMode === 'phone') {
@@ -433,6 +453,10 @@ Page({
try {
const app = getApp()
const data = await this.requestLogin('')
if (this.data.loginMode === 'phone' && data && data.registrationRequired) {
this.openRegistrationFlow(data)
return
}
const session = await this.resolveLoginSession(data)
if (!session) {
return
+13 -3
View File
@@ -9,6 +9,9 @@ Page({
passwordMode: false,
form: { phone: '', code: '', password: '', confirmPassword: '', shopName: '', shopAddress: '', shopId: '' },
wxCode: '',
registrationTicket: '',
applicationId: '',
phoneVerified: false,
shopOptions: [],
shopIndex: 0,
selectedShopName: '',
@@ -19,7 +22,15 @@ Page({
},
async onLoad(options) {
this.setData({ wxCode: options && options.wxCode ? options.wxCode : '' })
const registrationTicket = options && options.registrationTicket ? options.registrationTicket : ''
this.setData({
wxCode: options && options.wxCode ? options.wxCode : '',
registrationTicket,
applicationId: options && options.applicationId ? options.applicationId : '',
phoneVerified: Boolean(registrationTicket),
'form.phone': options && options.phone ? options.phone : '',
step: registrationTicket ? 2 : 1
})
try {
const shopOptions = await authApi.getAvailableRegistrationShops()
this.setData({ shopOptions: Array.isArray(shopOptions) ? shopOptions : [] })
@@ -64,10 +75,9 @@ Page({
const form = this.data.form
if (this.data.role === 'manager' && !String(form.shopName || '').trim()) { wx.showToast({ title: '请输入店铺名称', icon: 'none' }); return }
if (this.data.role === 'staff' && !form.shopId) { wx.showToast({ title: '请选择要加入的店铺', icon: 'none' }); return }
if (this.data.role === 'staff') { wx.showToast({ title: '店员申请功能即将开放', icon: 'none' }); return }
this.setData({ loading: true })
try {
await authApi.register({ phone: form.phone, verificationCode: form.code, password: form.password, confirmPassword: form.confirmPassword, shopName: form.shopName, shopAddress: form.shopAddress, shopId: form.shopId, roleType: this.data.role === 'manager' ? 'MANAGER' : 'STAFF', agreementAccepted: true, wxCode: this.data.wxCode })
await authApi.register({ phone: form.phone, verificationCode: this.data.registrationTicket ? undefined : form.code, registrationTicket: this.data.registrationTicket || undefined, applicationId: this.data.applicationId || undefined, password: form.password, confirmPassword: form.confirmPassword, shopName: form.shopName, shopAddress: form.shopAddress, shopId: form.shopId, roleType: this.data.role === 'manager' ? 'MANAGER' : 'STAFF', agreementAccepted: true, wxCode: this.data.wxCode })
this.setData({ step: 4 })
} catch (error) { wx.showToast({ title: error.message || '提交失败', icon: 'none' }) } finally { this.setData({ loading: false }) }
},
+1 -1
View File
@@ -3,7 +3,7 @@
<view class="progress-row"><view class="progress-step {{step >= 1 ? 'active' : ''}}"><text>1</text><label>验证手机</label></view><view class="progress-line {{step >= 2 ? 'active' : ''}}"></view><view class="progress-step {{step >= 2 ? 'active' : ''}}"><text>2</text><label>选择身份</label></view><view class="progress-line {{step >= 3 ? 'active' : ''}}"></view><view class="progress-step {{step >= 3 ? 'active' : ''}}"><text>3</text><label>提交审核</label></view></view>
<view wx:if="{{step === 1}}" class="card form-card">
<view class="section-title">验证手机号</view><view class="section-desc">手机号将作为你的工作台登录账号</view>
<view class="field"><text class="field-label">手机号</text><input value="{{form.phone}}" data-field="phone" bindinput="onInput" type="number" placeholder="请输入手机号" /></view>
<view class="field"><text class="field-label">手机号</text><input value="{{form.phone}}" data-field="phone" bindinput="onInput" type="number" disabled="{{phoneVerified}}" placeholder="请输入手机号" /><text wx:if="{{phoneVerified}}" class="verified-tip">手机号已验证</text></view>
<view class="field"><text class="field-label">验证码</text><view class="code-row"><input class="code-input" value="{{form.code}}" data-field="code" bindinput="onInput" type="number" placeholder="请输入6位验证码" /><button class="code-btn {{countdown > 0 ? 'counting' : ''}}" loading="{{codeLoading}}" disabled="{{codeLoading || countdown > 0}}" bindtap="sendCode"><text wx:if="{{countdown > 0}}">{{countdown}}s 后重发</text><text wx:else>获取验证码</text></button></view></view>
<view class="secondary-entry" bindtap="togglePasswordMode">使用密码注册 <text>›</text></view>
<view wx:if="{{passwordMode}}" class="password-panel"><view class="field"><text class="field-label">设置密码</text><input value="{{form.password}}" data-field="password" bindinput="onInput" password placeholder="至少8位密码" /></view><view class="field"><text class="field-label">确认密码</text><input value="{{form.confirmPassword}}" data-field="confirmPassword" bindinput="onInput" password placeholder="再次输入密码" /></view></view>