Compare commits

...
2 Commits
Author SHA1 Message Date
jacobxu666 5bba52ae1f feat: 商铺详情页商户优惠上方新增原价模块,内容取门票信息字段 2026-08-28 10:42:42 +08:00
jacobxu666andClaude Fable 5 cda36ddc1e fix: 权益页每次进入向服务端复查最新状态,避免缓存导致权益变化不可见
用户权益包/中奖状态会变化,原逻辑仅在无认证缓存时才查询后端,
导致本地缓存过期时用户始终看到旧的「未中奖」。改为进入权益页一律
凭手机号复查服务端资格并覆盖缓存,认证回调场景仍交由 checkAuthResult 处理。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-28 10:24:58 +08:00
2 changed files with 34 additions and 13 deletions
+20 -13
View File
@@ -212,18 +212,24 @@
this.lat = loc.lat this.lat = loc.lat
} }
this.checkAuthResult() this.checkAuthResult()
// xuchao: 本地无认证缓存时自动查询后端恢复已认证状态 // xuchao: 权益状态会变化,缓存只作首屏展示,进入页面一律向服务端复查最新状态
this.autoRecoverStatus() this.refreshStatus()
if (this.status === 'info') { if (this.status === 'info') {
this.loadRightsList() this.loadRightsList()
} }
}, },
methods: { methods: {
// xuchao: 已登录但本地无认证缓存时,仅传手机号查询资格以恢复状态(不带证件号,避免触发被动认证) // xuchao: 缓存的权益状态可能过期(中奖/权益包会变化),每次进页面仅凭手机号向服务端
autoRecoverStatus() { // 复查最新状态并覆盖缓存(不带证件号,避免触发被动认证)
if (this.status !== 'auth') return refreshStatus() {
// xuchao: 人脸认证回调场景由 checkAuthResult 负责查询,跳过避免重复请求
try {
if (new URL(window.location.href).searchParams.get('response')) return
} catch (e) {
return
}
// xuchao: 用户主动发起过认证流程时,取消后应停留在认证页,不自动恢复 // xuchao: 用户主动发起过认证流程时,取消后应停留在认证页,不自动恢复
if (uni.getStorageSync('authFlowStarted')) return if (this.status === 'auth' && uni.getStorageSync('authFlowStarted')) return
const phone = uni.getStorageSync('phone') const phone = uni.getStorageSync('phone')
if (!phone) return if (!phone) return
this.$u.api.getEligibility({ this.$u.api.getEligibility({
@@ -234,13 +240,14 @@
uni.setStorageSync('hasWin', res.data.hasWin) uni.setStorageSync('hasWin', res.data.hasWin)
uni.setStorageSync('cardNumber', res.data.cardNumber) uni.setStorageSync('cardNumber', res.data.cardNumber)
uni.setStorageSync('expiresTime', res.data.expiresTime) uni.setStorageSync('expiresTime', res.data.expiresTime)
// xuchao: 自动恢复成功,清除流程标记 // xuchao: 服务端已认证则清除取消标记,后续按真实状态展示
uni.removeStorageSync('authFlowStarted') if (res.data.isAuth) uni.removeStorageSync('authFlowStarted')
if (res.data.isAuth) { const newStatus = res.data.isAuth ? (res.data.hasWin ? 'info' : 'noWin') : 'auth'
this.status = res.data.hasWin ? 'info' : 'noWin' const prevStatus = this.status
if (this.status === 'info') { this.status = newStatus
this.loadRightsList() // xuchao: 状态刷新为权益页时补拉权益列表,避免与首屏加载重复
} if (newStatus === 'info' && prevStatus !== 'info') {
this.loadRightsList()
} }
}) })
}, },
+14
View File
@@ -20,6 +20,16 @@
</view> </view>
</view> </view>
<!-- 原价(内容取商铺门票信息字段) -->
<view class="discount-section" v-if="ticketInfoList.length">
<view class="section-title">
<text class="discount-title">原价</text>
</view>
<view class="discount-list">
<text class="discount-item" v-for="(item, index) in ticketInfoList" :key="index">{{ item }}</text>
</view>
</view>
<!-- 商户优惠 --> <!-- 商户优惠 -->
<view class="discount-section"> <view class="discount-section">
<view class="section-title"> <view class="section-title">
@@ -47,6 +57,10 @@ export default {
} }
}, },
computed: { computed: {
ticketInfoList() {
if (!this.store || !this.store.ticketInfo) return []
return this.store.ticketInfo.split('\n')
},
discountList() { discountList() {
if (!this.store || !this.store.merchantDiscount) return [] if (!this.store || !this.store.merchantDiscount) return []
return this.store.merchantDiscount.split('\n') return this.store.merchantDiscount.split('\n')