Merge branch 'master' into xuchao
This commit is contained in:
+52
-5
@@ -59,10 +59,56 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
onLoad(options) {
|
||||
if (options.token) {
|
||||
this.handleTokenLogin(options.token)
|
||||
}
|
||||
this.getLocation()
|
||||
},
|
||||
methods: {
|
||||
// xuchao: 云闪付入口 token 自动登录
|
||||
handleTokenLogin(token) {
|
||||
this.$u.api.tokenDecode({ token }).then(res => {
|
||||
if (res.errcode === 0 && res.data && res.data.mobile) {
|
||||
uni.setStorageSync('phone', res.data.mobile)
|
||||
this.$u.api.getEligibility({ phone: res.data.mobile, identityNo: res.data.idNo || '', name: res.data.name || '' }).then(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)
|
||||
}
|
||||
})
|
||||
// xuchao: 清除地址栏 token,防止分享泄露
|
||||
this.clearUrlToken()
|
||||
} else {
|
||||
this.degradeToPhoneLogin()
|
||||
}
|
||||
}).catch(() => {
|
||||
this.degradeToPhoneLogin()
|
||||
})
|
||||
},
|
||||
// xuchao: 解码失败兜底,提示并跳手机号登录
|
||||
degradeToPhoneLogin() {
|
||||
uni.showToast({ title: '登录凭证已失效,请使用手机号登录', icon: 'none' })
|
||||
setTimeout(() => {
|
||||
uni.navigateTo({ url: '/pages/index/login' })
|
||||
}, 800)
|
||||
},
|
||||
// xuchao: 从 URL hash 中移除 token 参数
|
||||
clearUrlToken() {
|
||||
try {
|
||||
const hash = window.location.hash || ''
|
||||
const qIndex = hash.indexOf('?')
|
||||
if (qIndex === -1) return
|
||||
const params = new URLSearchParams(hash.substring(qIndex + 1))
|
||||
if (!params.has('token')) return
|
||||
params.delete('token')
|
||||
const rest = params.toString()
|
||||
const base = hash.substring(0, qIndex)
|
||||
window.history.replaceState(null, '', rest ? `${base}?${rest}` : base)
|
||||
} catch (e) {}
|
||||
},
|
||||
getLocation() {
|
||||
import('@/common/location.js').then(module => {
|
||||
module.default.getLocation().then(({ lng, lat }) => {
|
||||
@@ -83,8 +129,10 @@
|
||||
}
|
||||
const isAuth = uni.getStorageSync('isAuth')
|
||||
const hasWin = uni.getStorageSync('hasWin')
|
||||
// xuchao: 最近发起过认证流程(含取消)时忽略旧认证缓存,一律回认证页
|
||||
const authFlowStarted = uni.getStorageSync('authFlowStarted')
|
||||
let status = 'auth'
|
||||
if (isAuth) {
|
||||
if (isAuth && !authFlowStarted) {
|
||||
status = hasWin ? 'info' : 'noWin'
|
||||
}
|
||||
uni.navigateTo({ url: `/pages/rights/rights?status=${status}` })
|
||||
@@ -144,7 +192,6 @@
|
||||
}
|
||||
|
||||
.king-text {
|
||||
font-family: 'Source Han Sans SC', 'Source Han Sans CN', 'Noto Sans CJK SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
|
||||
font-size: 24rpx;
|
||||
color: #333333;
|
||||
text-align: center;
|
||||
@@ -177,7 +224,7 @@
|
||||
|
||||
.title-text {
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
font-weight: 600;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
@@ -216,7 +263,7 @@
|
||||
|
||||
.guide-title {
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
font-weight: 600;
|
||||
color: #0088FF;
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user