feat: 增加店长审核模式与门店经营有效期
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user