feat: 增加店长审核模式与门店经营有效期

This commit is contained in:
2026-10-26 21:12:50 +08:00
parent 0151367333
commit fd9ff73c00
33 changed files with 855 additions and 39 deletions
@@ -14,7 +14,9 @@ Page({
timer: null,
smsExpanded: false,
unbindMode: false,
closureRequest: null
closureRequest: null,
businessExpireDateText: '',
businessExpiryStatusText: ''
},
onShow() { this.loadProfile(); this.loadClosureRequest() },
@@ -62,7 +64,13 @@ Page({
this.setData({ loading: true })
try {
const profile = await profileCache.getProfile(options)
this.setData({ profile, 'smsForm.phone': profile.phone || '' })
const businessExpireDateText = profile.shopBusinessExpireTime ? String(profile.shopBusinessExpireTime).slice(0, 10) : '未设置'
const businessExpiryStatusText = profile.shopBusinessExpired
? '已过期,暂不能新增预约'
: Number.isFinite(Number(profile.shopBusinessRemainingDays))
? `剩余 ${profile.shopBusinessRemainingDays} 天`
: '有效期未设置'
this.setData({ profile, businessExpireDateText, businessExpiryStatusText, 'smsForm.phone': profile.phone || '' })
const app = getApp()
const session = auth.getSession()
app.setSession({ ...session, userInfo: { ...(session.userInfo || {}), ...profile } })
@@ -1,5 +1,10 @@
<view class="page settings-page">
<view class="card identity-card"><view class="identity-mark">微</view><view class="identity-copy"><text class="identity-title">微信身份</text><text class="identity-status">已安全关联当前账号</text></view><text class="linked-badge">已关联</text></view>
<view wx:if="{{profile.type == 2}}" class="card business-expiry-card">
<view class="business-expiry-head"><text class="section-title">门店经营有效期</text><text class="business-expiry-status {{profile.shopBusinessExpired ? 'expired' : ''}}">{{businessExpiryStatusText}}</text></view>
<view class="business-expiry-date"><text>有效期至</text><strong>{{businessExpireDateText}}</strong></view>
<text wx:if="{{profile.shopBusinessExpired}}" class="business-expiry-note">到期后暂不可新增普通预约,历史订单、查询和补录不受影响。请联系平台管理员办理续期。</text>
</view>
<view class="card phone-card">
<view class="section-title">手机号</view>
<view class="phone-status"><text>{{profile.phoneVerified == 1 ? (profile.maskedPhone || profile.phone) : '尚未绑定'}}</text><text class="status-tag {{profile.phoneVerified == 1 ? 'done' : ''}}">{{profile.phoneVerified == 1 ? '已验证' : '待绑定'}}</text></view>
@@ -1,4 +1,5 @@
.settings-page { padding-top:24rpx; }.identity-card { display:flex; align-items:center; padding:26rpx; }.identity-mark { display:flex; align-items:center; justify-content:center; width:68rpx; height:68rpx; border-radius:20rpx; background:#e5f4ed; color:#247b63; font-size:28rpx; font-weight:800; }.identity-copy { display:flex; flex:1; flex-direction:column; margin-left:18rpx; }.identity-title,.section-title { color:#17211f; font-size:28rpx; font-weight:800; }.identity-status { margin-top:6rpx; color:#71807a; font-size:21rpx; }.linked-badge,.status-tag { padding:7rpx 14rpx; border-radius:999rpx; background:#e5f2e8; color:#397055; font-size:20rpx; }
.business-expiry-card { margin-top:20rpx; padding:26rpx; }.business-expiry-head,.business-expiry-date { display:flex; align-items:center; justify-content:space-between; gap:16rpx; }.business-expiry-status { color:#397055; font-size:22rpx; }.business-expiry-status.expired { color:#a24f42; }.business-expiry-date { margin-top:20rpx; padding-top:18rpx; border-top:1rpx solid #e5ebe7; color:#71807a; font-size:23rpx; }.business-expiry-date strong { color:#17211f; font-size:25rpx; }.business-expiry-note { display:block; margin-top:14rpx; color:#a24f42; font-size:21rpx; line-height:1.6; }
.phone-card { margin-top:20rpx; padding:28rpx; }.phone-status { display:flex; align-items:center; justify-content:space-between; margin-top:20rpx; padding:20rpx; border-radius:14rpx; background:#f3f7f4; color:#71807a; font-size:26rpx; }.status-tag { background:#fff0db; color:#9a682e; }.status-tag.done { background:#e5f2e8; color:#397055; }.wechat-phone-btn,.sms-bind-btn { height:80rpx; margin-top:22rpx; border-radius:14rpx; background:#247b63; color:#fff; font-size:26rpx; line-height:80rpx; }.sms-entry { display:flex; min-height:82rpx; align-items:center; margin-top:22rpx; border-top:1rpx solid #e5ebe7; color:#71807a; font-size:23rpx; }.sms-arrow { margin-left:auto; color:#95a198; font-size:36rpx; transition:transform 180ms ease; }.sms-arrow.expanded { transform:rotate(90deg); }.sms-panel { padding-top:2rpx; }.field input,.code-row input { box-sizing:border-box; height:78rpx; padding:0 20rpx; border:1rpx solid #dde8e0; border-radius:12rpx; background:#f8faf8; }.code-row { display:flex; gap:12rpx; margin-top:14rpx; }.code-row input { min-width:0; flex:1; }.code-row button { width:190rpx; height:78rpx; padding:0; border-radius:12rpx; background:#e7f0ea; color:#426c57; font-size:23rpx; line-height:78rpx; }.sms-bind-btn { background:#eef4f0; color:#247b63; }.account-note { margin:24rpx 18rpx; color:#71807a; font-size:21rpx; line-height:1.6; }.logout-btn { margin-top:52rpx; background:transparent; color:#a24f42; font-size:25rpx; }
.privacy-note {
margin: 12rpx 0;
@@ -26,6 +26,22 @@ function canCreateAppointment() {
return Number(userInfo.type) !== 3
}
function isShopBusinessExpired() {
const userInfo = getApp().globalData.userInfo || {}
return Number(userInfo.type) === 2 && userInfo.shopBusinessExpired === true
}
function showBusinessExpiryNotice() {
return new Promise(resolve => wx.showModal({
title: '门店经营有效期已到期',
content: '当前门店暂不能新增普通预约。历史订单、查询和补录不受影响,请联系平台管理员办理续期。',
showCancel: false,
confirmText: '知道了',
success: () => resolve(),
fail: () => resolve()
}))
}
function buildDraftKey() {
const app = getApp()
const userInfo = app.globalData.userInfo || {}
@@ -1399,6 +1415,10 @@ Page({
wx.showToast({ title: '当前账号仅支持查看预约', icon: 'none' })
return
}
if (isShopBusinessExpired()) {
await showBusinessExpiryNotice()
return
}
let form = this.data.form
const manualProductTitle = String(form.manualProductTitle || '').trim()
const manualProductImageFileIds = String(form.manualProductImageFileIds || '').trim()
@@ -1480,7 +1500,11 @@ Page({
markPlanningRefresh()
wx.redirectTo({ url: `/pages/appointment-detail/index?id=${result.orderItemId}` })
} catch (error) {
wx.showToast({ title: error.message || '提交失败', icon: 'none' })
if ((error.message || '').includes('有效期') || (error.message || '').includes('到期')) {
await showBusinessExpiryNotice()
} else {
wx.showToast({ title: error.message || '提交失败', icon: 'none' })
}
} finally {
this.setData({ loading: false })
}
@@ -2,16 +2,18 @@ const assert = require('assert')
const planningApi = require('../../api/planning')
let redirectedTo = ''
let appGlobalData = {}
let lastModal = null
global.wx = {
getAccountInfoSync: () => ({ miniProgram: { envVersion: 'develop' } }),
getDeviceInfo: () => ({ platform: 'devtools' }),
removeStorageSync: () => {},
setStorageSync: () => {},
showToast: () => {},
showModal: ({ success }) => success({ confirm: true }),
showModal: options => { lastModal = options; if (options.success) options.success({ confirm: true }) },
redirectTo: ({ url }) => { redirectedTo = url }
}
global.getApp = () => ({ globalData: {} })
global.getApp = () => ({ globalData: appGlobalData })
global.getCurrentPages = () => []
let definition
@@ -34,6 +36,14 @@ function createPage() {
}
async function run() {
const expiredPage = createPage()
expiredPage.data.canCreateAppointment = true
appGlobalData.userInfo = { type: 2, shopBusinessExpired: true }
await expiredPage.submit()
assert.strictEqual(lastModal.title, '门店经营有效期已到期')
assert.strictEqual(lastModal.showCancel, false)
appGlobalData = {}
const page = createPage()
Object.assign(page.data.form, {
customerUserId: '31',
+46 -2
View File
@@ -57,6 +57,7 @@ Page({
return
}
this.setData({ loginState: state })
this.handleResult(state)
},
async loadAgreements() {
@@ -144,6 +145,7 @@ Page({
async quickLogin() {
if (this.data.loading || !(await this.ensureCanLogin())) return
this._presentedLoginState = ''
const rememberMe = await this.chooseRememberMode()
if (rememberMe === null) return
this.setData({ rememberMe, loading: true })
@@ -152,7 +154,9 @@ Page({
this.setData({ loginState: result })
await this.handleResult(result)
} catch (error) {
this.setData({ loginState: { status: 'ERROR', message: error.message || '快捷登录失败,请重试' } })
const state = { status: 'ERROR', message: error.message || '快捷登录失败,请重试' }
this.setData({ loginState: state })
this.handleResult(state)
} finally {
this.setData({ loading: false })
}
@@ -160,6 +164,11 @@ Page({
async handleResult(result) {
if (result.status === 'SUCCESS' && result.accessToken) return this.finishLogin(result)
if (result.status === 'REJECTED' && this._resumeRegistrationAfterRejected && result.registrationTicket) {
this._resumeRegistrationAfterRejected = false
this.navigateToRegistration(result)
return
}
if (result.status === 'SELECT_SHOP') {
this.setData({ shopOptions: shopOptions(result), loginTicket: result.ticket, shopSelectVisible: true })
return
@@ -172,7 +181,41 @@ Page({
wx.navigateTo({ url: `/pages/register/index?${query}` })
return
}
wx.showToast({ title: result.message || '当前账号暂不能登录', icon: 'none', duration: 2500 })
const status = result.status
if (!['PENDING_REVIEW', 'REJECTED', 'DISABLED', 'ERROR', 'NEED_MANUAL_LOGIN'].includes(status)) return
const stateKey = `${status}:${result.registrationApplicationId || ''}:${result.message || ''}:${result.registrationRejectReason || ''}`
if (this._presentedLoginState === stateKey) return
this._presentedLoginState = stateKey
const title = status === 'PENDING_REVIEW' ? '申请审核中'
: status === 'REJECTED' ? '申请需要修改'
: status === 'DISABLED' ? '账号暂不可用'
: status === 'NEED_MANUAL_LOGIN' ? '需要完成注册' : '登录失败'
const content = result.registrationRejectReason || result.message || '请稍后重试'
const canRetry = status === 'ERROR' || status === 'NEED_MANUAL_LOGIN' || status === 'REJECTED'
wx.showModal({
title,
content,
showCancel: canRetry,
confirmText: status === 'REJECTED' ? '重新提交' : canRetry ? '重新登录' : '知道了',
cancelText: '取消',
success: choice => {
if (!choice.confirm) return
if (status === 'REJECTED' && result.registrationTicket) this.navigateToRegistration(result)
else if (status === 'REJECTED') {
this._resumeRegistrationAfterRejected = true
this.quickLogin()
}
else if (status === 'ERROR' || status === 'NEED_MANUAL_LOGIN') this.quickLogin()
}
})
},
navigateToRegistration(result) {
const query = [
`registrationTicket=${encodeURIComponent(result.registrationTicket)}`,
result.registrationApplicationId ? `applicationId=${encodeURIComponent(result.registrationApplicationId)}` : ''
].filter(Boolean).join('&')
wx.navigateTo({ url: `/pages/register/index?${query}` })
},
async selectShop(event) {
@@ -194,6 +237,7 @@ Page({
},
finishLogin(result) {
this._presentedLoginState = ''
getApp().setSession(result, true)
auth.setLoginPreference(this.data.rememberMe ? {
rememberMe: true,
+32
View File
@@ -5,6 +5,10 @@ const path = require('path')
let definition
let exitOptions
let toastOptions
let modalOptions
let navigatedTo
let modalChoice = { confirm: false, cancel: true }
let modalCount = 0
global.Page = value => { definition = value }
global.wx = {
@@ -13,6 +17,14 @@ global.wx = {
},
showToast(options) {
toastOptions = options
},
showModal(options) {
modalOptions = options
modalCount += 1
if (options.success) options.success(modalChoice)
},
navigateTo(options) {
navigatedTo = options.url
}
}
@@ -54,12 +66,32 @@ async function run() {
exitOptions.fail()
assert.strictEqual(toastOptions.title, '请同意协议后使用')
const statePage = createPage()
statePage.handleResult({ status: 'PENDING_REVIEW', message: '申请审核中' })
assert.strictEqual(modalOptions.title, '申请审核中')
assert.strictEqual(modalOptions.showCancel, false)
assert.strictEqual(statePage._presentedLoginState.startsWith('PENDING_REVIEW:'), true)
const modalCountBeforeError = modalCount
const errorPage = createPage()
errorPage.handleResult({ status: 'ERROR', message: '网络连接失败' })
errorPage.handleResult({ status: 'ERROR', message: '网络连接失败' })
assert.strictEqual(modalOptions.title, '登录失败')
assert.strictEqual(modalCount, modalCountBeforeError + 1)
modalChoice = { confirm: true, cancel: false }
const rejectedPage = createPage()
rejectedPage.handleResult({ status: 'REJECTED', message: '资料需修改', registrationTicket: 'ticket-1', registrationApplicationId: 23 })
assert.match(navigatedTo, /registrationTicket=ticket-1/)
assert.match(navigatedTo, /applicationId=23/)
const template = fs.readFileSync(path.join(__dirname, 'index.wxml'), 'utf8')
assert.match(template, /用户协议与隐私政策提示/)
assert.match(template, /不同意并退出/)
assert.match(template, /同意并继续/)
assert.match(template, /data-type="USER_TERMS" catchtap="openAgreement"/)
assert.match(template, /data-type="PRIVACY_POLICY" catchtap="openAgreement"/)
assert.doesNotMatch(template, /class="state-line"/)
}
run().catch(error => {
-1
View File
@@ -3,7 +3,6 @@
<view class="brand-area">
<image class="login-logo" src="/assets/images/app-icon.png" mode="aspectFill"></image><text class="brand-name">{{appName}}</text><text class="brand-sub">Salon 门店工作台</text>
</view>
<view wx:if="{{loginState && loginState.status !== 'READY' && loginState.status !== 'NEW_USER'}}" class="state-line"><text class="state-title">{{loginState.status === 'PENDING_REVIEW' ? '申请审核中' : loginState.status === 'REJECTED' ? '申请需要修改' : loginState.status === 'DISABLED' ? '账号暂不可用' : loginState.status === 'ERROR' ? '连接失败' : '账号状态'}}</text><text class="state-message">{{loginState.registrationRejectReason || loginState.message}}</text></view>
<view class="action-area">
<button class="quick-btn" loading="{{loading}}" disabled="{{loading || agreementLoading}}" bindtap="quickLogin"><text>快捷登录</text></button>
<view class="remember-row" bindtap="toggleRememberMe">
-20
View File
@@ -112,26 +112,6 @@
background: #247b63;
}
.state-line {
display: flex;
flex-direction: column;
align-items: center;
margin-top: 34rpx;
}
.state-title {
color: #765b32;
font-size: 24rpx;
font-weight: 700;
}
.state-message {
margin-top: 7rpx;
color: #9a8260;
font-size: 20rpx;
text-align: center;
}
.agreement-footer {
padding-top: 50rpx;
}