处理 token 过期问题
This commit is contained in:
+12
-2
@@ -148,12 +148,22 @@
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
if (!uni.getStorageSync('token')) {
|
||||
// 检查是否有 token,没有则先登录
|
||||
const token = uni.getStorageSync('token');
|
||||
|
||||
if (!token) {
|
||||
// 没有 token,先登录
|
||||
this.mini_login().then(() => {
|
||||
this.bannerListfn()
|
||||
this.$refs.paging && this.$refs.paging.reload()
|
||||
}).catch(() => {
|
||||
// 登录失败也加载数据(可能是游客模式)
|
||||
this.bannerListfn()
|
||||
this.$refs.paging && this.$refs.paging.reload()
|
||||
})
|
||||
}else{
|
||||
} else {
|
||||
// 有 token,直接加载数据
|
||||
// 如果 token 过期,API 层会自动重新登录
|
||||
this.bannerListfn()
|
||||
this.$refs.paging && this.$refs.paging.reload()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user