wangfukang 2 months ago
parent
commit
e63c8ed05b
  1. 22
      common/ieRealNameAuth.js

22
common/ieRealNameAuth.js

@ -15,6 +15,19 @@ function showLongToast(title, duration = 2000) {
uni.showToast({ title: content, icon: 'none', duration }) uni.showToast({ title: content, icon: 'none', duration })
} }
function showInfoModal(title, content, confirmText = '知道了') {
return new Promise(resolve => {
uni.showModal({
title,
content,
showCancel: false,
confirmText,
success: () => resolve(),
fail: () => resolve()
})
})
}
function showAuthDialog(options = {}) { function showAuthDialog(options = {}) {
return new Promise(resolve => { return new Promise(resolve => {
let handled = false let handled = false
@ -321,7 +334,7 @@ async function ensureAliyunRealNameVerified(profile) {
showLongToast((result && result.message) || '实名认证未完成,请稍后重试', 2000) showLongToast((result && result.message) || '实名认证未完成,请稍后重试', 2000)
return false return false
} }
showLongToast('实名认证通过', 2200) await showInfoModal('实名认证通过', '认证已通过,可以继续使用发布、评论、聊天等功能。')
return true return true
} }
@ -352,15 +365,16 @@ function goProfileSetup() {
export async function ensureIeVerifiedBeforeAction(options = {}) { export async function ensureIeVerifiedBeforeAction(options = {}) {
const profile = options.profile || {} const profile = options.profile || {}
const requireProfileSetup = options.requireProfileSetup !== false
if (STUDENT_CARD_AUTH_DISABLED && profile.realNameVerified) { if (STUDENT_CARD_AUTH_DISABLED && profile.realNameVerified) {
if (needsProfileSetup(profile)) { if (requireProfileSetup && needsProfileSetup(profile)) {
goProfileSetup() goProfileSetup()
return false return false
} }
return true return true
} }
if (!STUDENT_CARD_AUTH_DISABLED && profile.realNameVerified && profile.studentCardVerified) { if (!STUDENT_CARD_AUTH_DISABLED && profile.realNameVerified && profile.studentCardVerified) {
if (needsProfileSetup(profile)) { if (requireProfileSetup && needsProfileSetup(profile)) {
goProfileSetup() goProfileSetup()
return false return false
} }
@ -389,7 +403,7 @@ export async function ensureIeVerifiedBeforeAction(options = {}) {
if (typeof options.reload === 'function') { if (typeof options.reload === 'function') {
latestProfile = await options.reload() latestProfile = await options.reload()
} }
if (needsProfileSetup(latestProfile || profile)) { if (requireProfileSetup && needsProfileSetup(latestProfile || profile)) {
goProfileSetup() goProfileSetup()
return false return false
} }

Loading…
Cancel
Save