提交 9bd2b3ba authored 作者: 王鹏飞's avatar 王鹏飞

fix: 修复退出登录的问题

上级 eaa4f85e
...@@ -37,6 +37,7 @@ App({ ...@@ -37,6 +37,7 @@ App({
// 退出登录 // 退出登录
logout() { logout() {
return api.logout().then(response => { return api.logout().then(response => {
this.setToken('')
wx.removeStorageSync('token') wx.removeStorageSync('token')
}) })
}, },
...@@ -52,6 +53,7 @@ App({ ...@@ -52,6 +53,7 @@ App({
// 检查权限 // 检查权限
async checkAccess(token) { async checkAccess(token) {
if (token) this.setToken(token) if (token) this.setToken(token)
if (!this.store.token) return false
try { try {
const user = await this.getUser({ check: true }) const user = await this.getUser({ check: true })
return !!user?.id return !!user?.id
......
...@@ -18,11 +18,8 @@ const url_online = { ...@@ -18,11 +18,8 @@ const url_online = {
let config = url_online let config = url_online
/* 请求接口统一 重定义 */ /* 请求接口统一 重定义 */
const requestApi = obj => { const requestApi = obj => {
const token = wx.getStorageSync('token') const app = getApp()
if (!token) { const token = app ? app.store.token : wx.getStorageSync('token')
wx.reLaunch({ url: '/pages/login/index' })
return
}
wx.request({ wx.request({
url: obj.url, url: obj.url,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论