feat: 权益详情页到期时间/总权益价值/可用权益数改为接口数据展示
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
1521129d87
commit
80838143fb
+31
-12
@@ -63,9 +63,9 @@
|
||||
<view style="background: #fff;">
|
||||
<view class="banner-area">
|
||||
<text class="banner-title">恭喜您!获得怀化市社保卡权益包</text>
|
||||
<view class="banner-expire">
|
||||
<view class="banner-expire" v-if="expiresTime">
|
||||
<text class="expire-icon">!</text>
|
||||
<text class="expire-text">2026年12月31日</text>
|
||||
<text class="expire-text">{{ expiresTime }}</text>
|
||||
<text class="expire-label">到期</text>
|
||||
</view>
|
||||
</view>
|
||||
@@ -76,7 +76,7 @@
|
||||
<text class="stats-label">总权益价值</text>
|
||||
<view class="stats-value-row">
|
||||
<text class="stats-currency">¥</text>
|
||||
<text class="stats-number">1500</text>
|
||||
<text class="stats-number">{{ totalValueText }}</text>
|
||||
<text class="stats-unit">元</text>
|
||||
</view>
|
||||
</view>
|
||||
@@ -84,7 +84,7 @@
|
||||
<view class="stats-item">
|
||||
<text class="stats-label">可用权益数</text>
|
||||
<view class="stats-value-row">
|
||||
<text class="stats-number-large">10</text>
|
||||
<text class="stats-number-large">{{ rightsCount }}</text>
|
||||
<text class="stats-unit">个</text>
|
||||
</view>
|
||||
</view>
|
||||
@@ -172,6 +172,10 @@
|
||||
data() {
|
||||
return {
|
||||
status: 'auth',
|
||||
// xuchao: 权益概览三字段,首屏用缓存兜底,随后由服务端复查刷新
|
||||
expiresTime: uni.getStorageSync('expiresTime') || '',
|
||||
rightsCount: uni.getStorageSync('rightsCount') || 0,
|
||||
totalValueFen: uni.getStorageSync('totalValueFen') || 0,
|
||||
form: {
|
||||
realName: '',
|
||||
phone: '',
|
||||
@@ -199,6 +203,13 @@
|
||||
checkLoading: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
// xuchao: 总权益价值分转元,整除去小数,否则保留两位
|
||||
totalValueText() {
|
||||
const yuan = this.totalValueFen / 100
|
||||
return Number.isInteger(yuan) ? String(yuan) : yuan.toFixed(2)
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
if (options.status) {
|
||||
this.status = options.status
|
||||
@@ -238,10 +249,7 @@
|
||||
phone: phone
|
||||
}).then(res => {
|
||||
if (res.errcode !== 0 || !res.data) return
|
||||
uni.setStorageSync('isAuth', res.data.isAuth)
|
||||
uni.setStorageSync('hasWin', res.data.hasWin)
|
||||
uni.setStorageSync('cardNumber', res.data.cardNumber)
|
||||
uni.setStorageSync('expiresTime', res.data.expiresTime)
|
||||
this.applyEligibility(res.data)
|
||||
// xuchao: 服务端已认证则清除取消标记,后续按真实状态展示
|
||||
if (res.data.isAuth) uni.removeStorageSync('authFlowStarted')
|
||||
const newStatus = res.data.isAuth ? (res.data.hasWin ? 'info' : 'noWin') : 'auth'
|
||||
@@ -253,12 +261,26 @@
|
||||
}
|
||||
})
|
||||
},
|
||||
// xuchao: 资格查询结果统一写入缓存并回填页面(到期时间/总权益价值/可用权益数)
|
||||
applyEligibility(data) {
|
||||
uni.setStorageSync('isAuth', data.isAuth)
|
||||
uni.setStorageSync('hasWin', data.hasWin)
|
||||
uni.setStorageSync('cardNumber', data.cardNumber)
|
||||
uni.setStorageSync('expiresTime', data.expiresTime)
|
||||
uni.setStorageSync('rightsCount', data.rightsCount || 0)
|
||||
uni.setStorageSync('totalValueFen', data.totalValueFen || 0)
|
||||
this.expiresTime = data.expiresTime || ''
|
||||
this.rightsCount = data.rightsCount || 0
|
||||
this.totalValueFen = data.totalValueFen || 0
|
||||
},
|
||||
// xuchao: 认证取消/未通过:清理旧认证缓存并标记流程已发起,取消后应停留认证页
|
||||
markAuthCanceled() {
|
||||
uni.removeStorageSync('isAuth')
|
||||
uni.removeStorageSync('hasWin')
|
||||
uni.removeStorageSync('cardNumber')
|
||||
uni.removeStorageSync('expiresTime')
|
||||
uni.removeStorageSync('rightsCount')
|
||||
uni.removeStorageSync('totalValueFen')
|
||||
uni.setStorageSync('authFlowStarted', true)
|
||||
},
|
||||
checkAuthResult() {
|
||||
@@ -301,10 +323,7 @@
|
||||
}).then(eRes => {
|
||||
console.log('eligibility res:', eRes)
|
||||
if (eRes.errcode === 0) {
|
||||
uni.setStorageSync('isAuth', eRes.data.isAuth)
|
||||
uni.setStorageSync('hasWin', eRes.data.hasWin)
|
||||
uni.setStorageSync('cardNumber', eRes.data.cardNumber)
|
||||
uni.setStorageSync('expiresTime', eRes.data.expiresTime)
|
||||
this.applyEligibility(eRes.data)
|
||||
// xuchao: 认证成功,清除流程标记
|
||||
uni.removeStorageSync('authFlowStarted')
|
||||
if (eRes.data.isAuth) {
|
||||
|
||||
Reference in New Issue
Block a user