fix: 退出登录与云闪付入口统一清理账号缓存,避免串号与脏数据
1. 新增 common/account.js,集中维护账号级本地缓存 key(token/phone/isAuth/hasWin/cardNumber/expiresTime/rightsCount/totalValueFen/authFlowStarted/authName/authIdNo),定位 lng/lat 属设备信息不清 2. 我的页退出登录原来只清 token/phone,权益缓存残留会被下一个账号当成自己的数据展示(权益页首屏读这些 key 兜底,且无手机号时 refreshStatus 不会刷新) 3. 首页云闪付入口是免密换人,进入前先清上一个账号的会话与权益缓存,否则请求仍带旧 accessToken,后端会话优先会把上一个账号的数据返回给新用户
This commit is contained in:
@@ -34,6 +34,8 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import account from '@/common/account.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
@@ -70,6 +72,9 @@
|
||||
handleTokenLogin(token) {
|
||||
this.$u.api.tokenDecode({ token }).then(res => {
|
||||
if (res.errcode === 0 && res.data && res.data.mobile) {
|
||||
// xuchao: 云闪付入口是“免密换人”,先丢弃本机上一个账号的会话与权益缓存,
|
||||
// 否则请求仍带旧 accessToken,后端“会话优先”会把上一个账号的数据返回给这位用户
|
||||
account.clearAccountCache()
|
||||
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) {
|
||||
|
||||
+4
-2
@@ -43,6 +43,7 @@
|
||||
|
||||
<script>
|
||||
import config from '@/common/config.js'
|
||||
import account from '@/common/account.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
@@ -71,8 +72,9 @@ export default {
|
||||
content: '确定要退出登录吗?',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
uni.removeStorageSync('token')
|
||||
uni.removeStorageSync('phone')
|
||||
// xuchao: 原来只清 token/phone,权益缓存(isAuth/hasWin/cardNumber/expiresTime/
|
||||
// rightsCount 等)残留会被下一个账号当成自己的数据展示
|
||||
account.clearAccountCache()
|
||||
this.isLogin = false
|
||||
this.phone = ''
|
||||
uni.showToast({ title: '已退出登录', icon: 'success' })
|
||||
|
||||
Reference in New Issue
Block a user