完善注册资料必填校验与驳回重申流程
自动发布开发环境 Nacos 配置 / publish (push) Successful in 21s
环境分支晋级检查 / environment-promotion-source (pull_request_target) Successful in 11s

This commit is contained in:
2026-11-03 21:22:05 +08:00
parent c626a1e6d6
commit 92df97810a
10 changed files with 267 additions and 39 deletions
+4 -2
View File
@@ -178,7 +178,8 @@ Page({
if (result.status === 'NEED_REGISTRATION' && result.registrationTicket) {
const query = [
`registrationTicket=${encodeURIComponent(result.registrationTicket)}`,
result.registrationApplicationId ? `applicationId=${encodeURIComponent(result.registrationApplicationId)}` : ''
result.registrationApplicationId ? `applicationId=${encodeURIComponent(result.registrationApplicationId)}` : '',
result.registrationRole ? `role=${encodeURIComponent(result.registrationRole)}` : ''
].filter(Boolean).join('&')
wx.navigateTo({ url: `/pages/register/index?${query}` })
return
@@ -215,7 +216,8 @@ Page({
navigateToRegistration(result) {
const query = [
`registrationTicket=${encodeURIComponent(result.registrationTicket)}`,
result.registrationApplicationId ? `applicationId=${encodeURIComponent(result.registrationApplicationId)}` : ''
result.registrationApplicationId ? `applicationId=${encodeURIComponent(result.registrationApplicationId)}` : '',
result.registrationRole ? `role=${encodeURIComponent(result.registrationRole)}` : ''
].filter(Boolean).join('&')
wx.navigateTo({ url: `/pages/register/index?${query}` })
},
+2 -1
View File
@@ -95,9 +95,10 @@ async function run() {
modalChoice = { confirm: true, cancel: false }
const rejectedPage = createPage()
rejectedPage.handleResult({ status: 'REJECTED', message: '资料需修改', registrationTicket: 'ticket-1', registrationApplicationId: 23 })
rejectedPage.handleResult({ status: 'REJECTED', message: '资料需修改', registrationTicket: 'ticket-1', registrationApplicationId: 23, registrationRole: 'STAFF' })
assert.match(navigatedTo, /registrationTicket=ticket-1/)
assert.match(navigatedTo, /applicationId=23/)
assert.match(navigatedTo, /role=STAFF/)
const template = fs.readFileSync(path.join(__dirname, 'index.wxml'), 'utf8')
assert.match(template, /用户协议与隐私政策提示/)
+37 -8
View File
@@ -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' }) }
})
+61 -1
View File
@@ -27,6 +27,29 @@ function createPage() {
}
async function run() {
const freshEntry = createPage()
freshEntry.loadShops = async () => {}
await freshEntry.onLoad({ registrationTicket: 'fresh-ticket' })
assert.strictEqual(freshEntry.data.role, '')
assert.strictEqual(freshEntry.data.step, 1)
const identityPage = createPage()
identityPage.data.registrationTicket = 'valid-ticket'
identityPage.continueFromRole()
assert.strictEqual(toast, '请选择工作身份')
assert.strictEqual(identityPage.data.step, 1)
const resubmitEntry = createPage()
resubmitEntry.loadShops = async () => {}
await resubmitEntry.onLoad({ registrationTicket: 'fresh-ticket', applicationId: '41', role: 'STAFF' })
assert.strictEqual(resubmitEntry.data.step, 2)
assert.strictEqual(resubmitEntry.data.role, 'staff')
const managerResubmitEntry = createPage()
managerResubmitEntry.loadShops = async () => {}
await managerResubmitEntry.onLoad({ registrationTicket: 'fresh-ticket', applicationId: '42', role: 'MANAGER' })
assert.strictEqual(managerResubmitEntry.data.role, 'manager')
const locationPage = createPage()
locationPage.chooseShopLocation()
chooseLocationOptions.success({ address: '杭州市西湖区某路', longitude: 120.12, latitude: 30.28 })
@@ -42,6 +65,9 @@ async function run() {
page.data.registrationTicket = 'valid-ticket'
page.data.role = 'staff'
page.data.form.shopId = '20'
page.data.form.applicantNickname = '小周'
page.data.form.applicantAvatarFileId = '1001'
page.data.form.applicantAvatarUrl = '/tmp/avatar.png'
authApi.register = async () => ({
applicationId: '88',
status: 'APPROVED',
@@ -57,8 +83,33 @@ async function run() {
const registerMarkup = require('fs').readFileSync(require('path').join(__dirname, 'index.wxml'), 'utf8')
assert(registerMarkup.includes('可从微信昵称中选择'))
assert(registerMarkup.includes('点击主动选择微信头像'))
assert(registerMarkup.includes('点击选择微信头像'))
assert(registerMarkup.includes('头像会先上传并完成资料登记'))
assert(registerMarkup.includes('昵称和头像为必填资料'))
for (const label of ['选择工作身份', '店铺名称', '选择店铺', '昵称', '头像']) {
assert(registerMarkup.includes(`<text class="required-mark">*</text>${label}`), `${label} should be marked required`)
}
assert(registerMarkup.includes('店铺地址 <text class="optional-mark">选填</text>'))
const missingNickname = createPage()
missingNickname.data.registrationTicket = 'valid-ticket'
missingNickname.data.role = 'staff'
missingNickname.data.form.shopId = '20'
missingNickname.data.form.applicantAvatarFileId = '1001'
let missingProfileSubmitted = false
authApi.register = async () => { missingProfileSubmitted = true }
await missingNickname.submit()
assert.strictEqual(toast, '请输入昵称')
assert.strictEqual(missingProfileSubmitted, false)
const missingAvatar = createPage()
missingAvatar.data.registrationTicket = 'valid-ticket'
missingAvatar.data.role = 'staff'
missingAvatar.data.form.shopId = '20'
missingAvatar.data.form.applicantNickname = '小周'
await missingAvatar.submit()
assert.strictEqual(toast, '请选择头像')
assert.strictEqual(missingProfileSubmitted, false)
const managerPage = createPage()
managerPage.data.registrationTicket = 'manager-ticket'
@@ -73,14 +124,23 @@ async function run() {
assert.strictEqual(registrationPayload.shopLongitude, 120.12)
assert.strictEqual(registrationPayload.shopLatitude, 30.28)
const missingShopName = createPage()
missingShopName.data.registrationTicket = 'manager-ticket'
missingShopName.data.role = 'manager'
await missingShopName.submit()
assert.strictEqual(toast, '请输入店铺名称')
const appConfig = require('../../app.json')
assert.deepStrictEqual(appConfig.requiredPrivateInfos, ['chooseLocation'])
assert.ok(appConfig.permission['scope.userLocation'].desc)
const expired = createPage()
toast = undefined
expired.data.registrationTicket = 'spent-ticket'
expired.data.role = 'staff'
expired.data.form.shopId = '20'
expired.data.form.applicantNickname = '小周'
expired.data.form.applicantAvatarFileId = '1001'
authApi.register = async () => { throw new Error('注册票据已失效,请重新发起快捷登录') }
await expired.submit()
assert.strictEqual(expired.data.ticketInvalid, true)
+4 -4
View File
@@ -1,10 +1,10 @@
<view class="page no-tab auth-page">
<view class="auth-header"><image class="logo" src="/assets/images/app-icon.png" mode="aspectFill"></image><view class="header-copy"><text class="brand-name">Salon</text><text class="brand-sub">用微信身份申请门店工作权限</text></view></view>
<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 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="{{ticketInvalid}}" class="card result-card"><view class="result-icon">!</view><view class="section-title">申请入口已失效</view><view class="section-desc">这次注册凭证已过期或已使用,请返回登录页重新点击微信快捷登录获取新凭证。</view><button class="primary-btn" bindtap="back">重新快捷登录</button></view>
<view wx:elif="{{step === 1}}" class="card form-card"><view class="section-title">选择工作身份</view><view class="section-desc">无需手机号和密码,审核人会根据你的身份处理申请</view><view class="role-list"><view class="role-option {{role === 'manager' ? 'selected' : ''}}" data-role="manager" bindtap="selectRole"><view class="role-icon">店</view><view class="role-copy"><text class="role-title">店长</text><text class="role-desc">创建并负责一家 Salon 门店</text></view><text class="role-mark">{{role === 'manager' ? '✓' : '○'}}</text></view><view class="role-option {{role === 'staff' ? 'selected' : ''}}" data-role="staff" bindtap="selectRole"><view class="role-icon">员</view><view class="role-copy"><text class="role-title">店员</text><text class="role-desc">加入已有门店协同工作</text></view><text class="role-mark">{{role === 'staff' ? '✓' : '○'}}</text></view></view><button class="primary-btn" bindtap="continueFromRole">继续</button></view>
<view wx:elif="{{step === 2}}" class="card form-card"><view class="section-title">{{role === 'manager' ? '完善店铺资料' : '选择要加入的店铺'}}</view><view class="section-desc">{{role === 'manager' ? '提交后由平台管理员审核' : '提交后由对应店长审核,昵称和头像均为可选资料'}}</view><view wx:if="{{role === 'manager'}}" class="field"><text class="field-label">店铺名称</text><input value="{{form.shopName}}" data-field="shopName" bindinput="onInput" placeholder="请输入店铺名称" /></view><view wx:if="{{role === 'manager'}}" class="field"><text class="field-label">店铺地址</text><view class="address-entry"><input value="{{form.shopAddress}}" data-field="shopAddress" bindinput="onInput" placeholder="可手动填写门店地址" /><button class="map-pick-btn" bindtap="chooseShopLocation">地图选点</button></view><text class="field-hint">地图选点为可选项,仅用于门店展示和预约导航,不会在后台静默获取位置。</text></view><view wx:if="{{role === 'staff'}}" class="field"><text class="field-label">选择店铺</text><view class="picker-value {{selectedShopName ? 'filled' : ''}}" bindtap="openShopSheet"><text>{{selectedShopName || '请选择要加入的店铺'}}</text><text class="picker-arrow">›</text></view></view><view wx:if="{{role === 'staff'}}" class="field"><text class="field-label">申请昵称(选填)</text><input type="nickname" value="{{form.applicantNickname}}" data-field="applicantNickname" bindinput="onInput" placeholder="可填写希望展示的昵称" /><text class="field-hint">点击输入框可从微信昵称中选择,也可以手动填写。</text></view><view wx:if="{{role === 'staff'}}" class="field avatar-pick-field"><text class="field-label">申请头像(选填)</text><button class="avatar-pick" open-type="chooseAvatar" bindchooseavatar="chooseApplicantAvatar"><image src="{{form.applicantAvatarUrl || '/assets/images/default-user-avatar.png'}}" mode="aspectFill"></image><text>{{avatarUploading ? '上传中...' : '点击主动选择微信头像'}}</text></button><text class="field-hint">头像会先上传并完成资料登记,提交时只引用已上传的文件。</text></view><view wx:if="{{role === 'staff'}}" class="notice">审核通过前不会获得门店业务权限</view><button class="primary-btn" loading="{{loading}}" disabled="{{avatarUploading}}" bindtap="submit">提交审核</button><view class="back-entry" bindtap="goBackStep">返回上一步</view></view>
<view wx:elif="{{step === 3}}" class="card result-card"><view class="result-icon {{registrationStatusText === '已驳回' ? 'rejected' : registrationStatusText === '已通过' ? 'approved' : ''}}">{{registrationStatusText === '已驳回' ? '!' : registrationStatusText === '已通过' ? '✓' : '…'}}</view><view class="section-title">{{registrationStatusText === '已通过' ? '申请已通过' : registrationStatusText === '已驳回' ? '申请未通过' : '申请已提交'}}</view><view class="section-desc">{{registrationStatusText === '已通过' ? '现在可以返回登录页,使用微信快捷登录。' : registrationStatusText === '已驳回' ? (registrationStatus.rejectReason || '请联系对应审核人了解原因。') : (role === 'manager' ? '申请由平台管理员处理,通过后即可使用快捷登录。' : '申请由门店店长处理,通过后即可使用快捷登录。')}}</view><view class="result-status">当前状态:<text>{{registrationStatusText}}</text></view><view wx:if="{{contentStatusText}}" class="content-review-status"><text>{{contentStatusText}}</text><text wx:if="{{contentStatusReason}}" class="content-review-reason">{{contentStatusReason}}</text></view><button class="primary-btn" bindtap="back">返回登录</button></view>
<view wx:elif="{{step === 1}}" class="card form-card"><view class="section-title"><text class="required-mark">*</text>选择工作身份</view><view class="section-desc">无需手机号和密码,审核人会根据你的身份处理申请</view><view class="role-list"><view class="role-option {{role === 'manager' ? 'selected' : ''}}" data-role="manager" bindtap="selectRole"><view class="role-icon">店</view><view class="role-copy"><text class="role-title">店长</text><text class="role-desc">创建并负责一家 Salon 门店</text></view><text class="role-mark">{{role === 'manager' ? '✓' : '○'}}</text></view><view class="role-option {{role === 'staff' ? 'selected' : ''}}" data-role="staff" bindtap="selectRole"><view class="role-icon">员</view><view class="role-copy"><text class="role-title">店员</text><text class="role-desc">加入已有门店协同工作</text></view><text class="role-mark">{{role === 'staff' ? '✓' : '○'}}</text></view></view><button class="primary-btn" bindtap="continueFromRole">继续</button></view>
<view wx:elif="{{step === 2}}" class="card form-card"><view class="section-title">补充资料</view><view class="section-desc">{{role === 'manager' ? '提交后由平台管理员审核' : '提交后由对应店长审核,昵称和头像为必填资料'}}</view><view wx:if="{{role === 'manager'}}" class="field"><text class="field-label"><text class="required-mark">*</text>店铺名称</text><input value="{{form.shopName}}" data-field="shopName" bindinput="onInput" placeholder="请输入店铺名称" /></view><view wx:if="{{role === 'manager'}}" class="field"><text class="field-label">店铺地址 <text class="optional-mark">选填</text></text><view class="address-entry"><input value="{{form.shopAddress}}" data-field="shopAddress" bindinput="onInput" placeholder="可手动填写门店地址" /><button class="map-pick-btn" bindtap="chooseShopLocation">地图选点</button></view><text class="field-hint">地图选点为可选项,仅用于门店展示和预约导航,不会在后台静默获取位置。</text></view><view wx:if="{{role === 'staff'}}" class="field"><text class="field-label"><text class="required-mark">*</text>选择店铺</text><view class="picker-value {{selectedShopName ? 'filled' : ''}}" bindtap="openShopSheet"><text>{{selectedShopName || '请选择要加入的店铺'}}</text><text class="picker-arrow">›</text></view></view><view wx:if="{{role === 'staff'}}" class="field"><text class="field-label"><text class="required-mark">*</text>昵称</text><input type="nickname" maxlength="20" value="{{form.applicantNickname}}" data-field="applicantNickname" bindinput="onInput" placeholder="点击输入框选择或填写微信昵称" /><text class="field-hint">可从微信昵称中选择,也可以手动填写,最多20个字。</text></view><view wx:if="{{role === 'staff'}}" class="field avatar-pick-field"><text class="field-label"><text class="required-mark">*</text>头像</text><button class="avatar-pick" open-type="chooseAvatar" bindchooseavatar="chooseApplicantAvatar"><image src="{{form.applicantAvatarUrl || '/assets/images/default-user-avatar.png'}}" mode="aspectFill"></image><text>{{avatarUploading ? '上传中...' : '点击选择微信头像'}}</text></button><text class="field-hint">请选择头像,头像会先上传并完成资料登记,提交时只引用已上传的文件。</text></view><view wx:if="{{role === 'staff'}}" class="notice">审核通过前不会获得门店业务权限</view><button class="primary-btn" loading="{{loading}}" disabled="{{avatarUploading}}" bindtap="submit">提交审核</button><view class="back-entry" bindtap="goBackStep">返回上一步</view></view>
<view wx:elif="{{step === 3}}" class="card result-card"><view class="result-icon {{registrationStatusText === '已驳回' ? 'rejected' : registrationStatusText === '已通过' ? 'approved' : ''}}">{{registrationStatusText === '已驳回' ? '!' : registrationStatusText === '已通过' ? '✓' : '…'}}</view><view class="section-title">{{registrationStatusText === '已通过' ? '申请已通过' : registrationStatusText === '已驳回' ? '申请未通过' : '申请已提交'}}</view><view class="section-desc">{{registrationStatusText === '已通过' ? '现在可以返回登录页,使用微信快捷登录。' : registrationStatusText === '已驳回' ? (registrationStatus.rejectReason || '返回登录并重新快捷登录后,可修改资料再次申请。') : (role === 'manager' ? '申请由平台管理员处理,通过后即可使用快捷登录。' : '申请由门店店长处理,通过后即可使用快捷登录。')}}</view><view class="result-status">当前状态:<text>{{registrationStatusText}}</text></view><view class="registration-details"><view class="registration-detail"><text>申请门店</text><text>{{registrationStatus.shopName || selectedShopName || form.shopName || '—'}}</text></view><view class="registration-detail"><text>申请身份</text><text>{{role === 'manager' ? '店长' : '店员'}}</text></view><view wx:if="{{role === 'staff'}}" class="registration-detail"><text>申请昵称</text><text>{{form.applicantNickname || '—'}}</text></view><view wx:if="{{registrationStatus.applicationNo}}" class="registration-detail"><text>申请编号</text><text>{{registrationStatus.applicationNo}}</text></view><view class="registration-detail"><text>提交时间</text><text>{{applicationSubmittedAt || '刚刚'}}</text></view></view><view wx:if="{{contentStatusText}}" class="content-review-status"><text>{{contentStatusText}}</text><text wx:if="{{contentStatusReason}}" class="content-review-reason">{{contentStatusReason}}</text></view><button wx:if="{{registrationStatusText === '已驳回'}}" class="primary-btn" bindtap="reapply">返回登录并重新申请</button><button wx:else class="primary-btn" bindtap="back">返回登录</button></view>
<entity-selector-sheet visible="{{shopSheetVisible}}" title="选择门店" keyword="{{shopKeyword}}" placeholder="搜索门店名称或地址" items="{{shopSelectorItems}}" selected-id="{{form.shopId}}" loading="{{shopLoading}}" error-text="{{shopError}}" empty-text="暂无匹配门店" bind:search="onShopSearch" bind:select="selectShop" bind:retry="loadShops" bind:close="closeShopSheet" />
<view class="safe-note">OpenID 仅用于识别你的微信身份,不会在页面中展示。</view>
</view>
@@ -96,6 +96,9 @@
font-weight: 700;
}
.required-mark { margin-right: 6rpx; color: #c85d52; }
.optional-mark { margin-left: 4rpx; color: #9aa9a0; font-size: 20rpx; font-weight: 500; }
.auth-page .form-card .field input,
.picker-value {
box-sizing: border-box;
@@ -259,6 +262,11 @@
.result-card .section-title { margin-top: 24rpx; }
.result-status { margin-top: 28rpx; padding: 18rpx 28rpx; border-radius: 12rpx; background: #e5f4ed; color: #75887b; font-size: 24rpx; }
.result-status text { color: #c28b47; font-weight: 700; }
.registration-details { width: 100%; box-sizing: border-box; margin-top: 20rpx; padding: 8rpx 18rpx; border-radius: 14rpx; background: #f3f8f3; text-align: left; }
.registration-detail { display: flex; align-items: flex-start; justify-content: space-between; gap: 20rpx; padding: 12rpx 0; border-bottom: 1rpx solid #e2ebe3; font-size: 22rpx; line-height: 1.45; }
.registration-detail:last-child { border-bottom: 0; }
.registration-detail text:first-child { flex: none; color: #8b9a91; }
.registration-detail text:last-child { min-width: 0; color: #425b4c; text-align: right; overflow-wrap: anywhere; }
.safe-note { margin-top: 28rpx; color: #9aa9a0; font-size: 21rpx; line-height: 1.5; text-align: center; }
.avatar-pick-field { margin-top: 26rpx; }
.avatar-pick {