diff --git a/pages/rights/rights.vue b/pages/rights/rights.vue index e4ebb61..8284a6b 100644 --- a/pages/rights/rights.vue +++ b/pages/rights/rights.vue @@ -212,18 +212,24 @@ this.lat = loc.lat } this.checkAuthResult() - // xuchao: 本地无认证缓存时自动查询后端恢复已认证状态 - this.autoRecoverStatus() + // xuchao: 权益状态会变化,缓存只作首屏展示,进入页面一律向服务端复查最新状态 + this.refreshStatus() if (this.status === 'info') { this.loadRightsList() } }, methods: { - // xuchao: 已登录但本地无认证缓存时,仅传手机号查询资格以恢复状态(不带证件号,避免触发被动认证) - autoRecoverStatus() { - if (this.status !== 'auth') return + // xuchao: 缓存的权益状态可能过期(中奖/权益包会变化),每次进页面仅凭手机号向服务端 + // 复查最新状态并覆盖缓存(不带证件号,避免触发被动认证) + refreshStatus() { + // xuchao: 人脸认证回调场景由 checkAuthResult 负责查询,跳过避免重复请求 + try { + if (new URL(window.location.href).searchParams.get('response')) return + } catch (e) { + return + } // xuchao: 用户主动发起过认证流程时,取消后应停留在认证页,不自动恢复 - if (uni.getStorageSync('authFlowStarted')) return + if (this.status === 'auth' && uni.getStorageSync('authFlowStarted')) return const phone = uni.getStorageSync('phone') if (!phone) return this.$u.api.getEligibility({ @@ -234,13 +240,14 @@ uni.setStorageSync('hasWin', res.data.hasWin) uni.setStorageSync('cardNumber', res.data.cardNumber) uni.setStorageSync('expiresTime', res.data.expiresTime) - // xuchao: 自动恢复成功,清除流程标记 - uni.removeStorageSync('authFlowStarted') - if (res.data.isAuth) { - this.status = res.data.hasWin ? 'info' : 'noWin' - if (this.status === 'info') { - this.loadRightsList() - } + // xuchao: 服务端已认证则清除取消标记,后续按真实状态展示 + if (res.data.isAuth) uni.removeStorageSync('authFlowStarted') + const newStatus = res.data.isAuth ? (res.data.hasWin ? 'info' : 'noWin') : 'auth' + const prevStatus = this.status + this.status = newStatus + // xuchao: 状态刷新为权益页时补拉权益列表,避免与首屏加载重复 + if (newStatus === 'info' && prevStatus !== 'info') { + this.loadRightsList() } }) },