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;
|
||||
}
|
||||
|
||||
+39
-21
@@ -1,5 +1,12 @@
|
||||
<template>
|
||||
<view class="page">
|
||||
<!-- xuchao: 顶部导航(返回+页面名称) -->
|
||||
<view class="nav-bar">
|
||||
<view class="nav-back" @click="goBack">
|
||||
<u-icon name="arrow-left" color="#1a1818" size="40"></u-icon>
|
||||
</view>
|
||||
<text class="nav-title">手机号登录</text>
|
||||
</view>
|
||||
<!-- 标题区 -->
|
||||
<view class="title-area">
|
||||
<text class="title">手机号登录</text>
|
||||
@@ -32,12 +39,6 @@
|
||||
<text class="agreement-text" @click="agreed = !agreed">和</text>
|
||||
<text class="agreement-link" @click.stop="goAgreement('privacy')">《隐私协议》</text>
|
||||
</view>
|
||||
|
||||
<!-- 返回按钮 -->
|
||||
<view class="back-btn" @click="goBack">
|
||||
<image class="back-icon" src="https://zhihuiyou.oss-cn-shenzhen.aliyuncs.com/hhrs/hhrs_back.png" mode="aspectFit"></image>
|
||||
<text class="back-text">返回上一页</text>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@@ -135,7 +136,13 @@ export default {
|
||||
uni.navigateTo({ url })
|
||||
},
|
||||
goBack() {
|
||||
uni.navigateBack()
|
||||
// xuchao: 直接通过链接进入(无历史栈)时回到首页,避免返回无响应
|
||||
const pages = getCurrentPages()
|
||||
if (pages.length > 1) {
|
||||
uni.navigateBack()
|
||||
} else {
|
||||
uni.reLaunch({ url: '/pages/index/index' })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -159,7 +166,7 @@ export default {
|
||||
|
||||
.title {
|
||||
font-size: 44rpx;
|
||||
font-weight: bold;
|
||||
font-weight: 700;
|
||||
color: #1a1a1a;
|
||||
display: block;
|
||||
text-align: center;
|
||||
@@ -264,24 +271,35 @@ export default {
|
||||
color: #0088FF;
|
||||
}
|
||||
|
||||
/* 返回按钮 */
|
||||
.back-btn {
|
||||
position: fixed;
|
||||
left: 24px;
|
||||
bottom: 50px;
|
||||
/* xuchao: 顶部返回导航条(负外边距抵消页面左右 padding,通栏展示) */
|
||||
.nav-bar {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
height: 56px;
|
||||
background-color: #ffffff;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
position: relative;
|
||||
margin: 0 -40rpx;
|
||||
}
|
||||
|
||||
.back-icon {
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
.nav-back {
|
||||
position: absolute;
|
||||
left: 12px;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.back-text {
|
||||
font-size: 12px;
|
||||
color: #666666;
|
||||
.nav-title {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
font-size: 17px;
|
||||
font-weight: 600;
|
||||
color: #1a1818;
|
||||
padding: 0 56px;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user