Commit b51d6d28be4ee4c6022549e00977d36342ea327a
1 parent
78dcf61c
登录失效
Showing
2 changed files
with
14 additions
and
4 deletions
App.vue
@@ -25,7 +25,16 @@ | @@ -25,7 +25,16 @@ | ||
25 | checkUpdate() | 25 | checkUpdate() |
26 | } | 26 | } |
27 | 27 | ||
28 | - // 一键登录预登陆,可以显著提高登录速度 | 28 | + let token = getGlobalUser("globalUser").token |
29 | + if(!token){ | ||
30 | + //不存在则跳转至登录页 | ||
31 | + uni.reLaunch({ | ||
32 | + url: "/pages/index/index" | ||
33 | + }) | ||
34 | + } | ||
35 | + | ||
36 | + | ||
37 | + // 一键登录预登陆,可以显著提高登录速度 | ||
29 | uni.preLogin({ | 38 | uni.preLogin({ |
30 | provider: 'univerify', | 39 | provider: 'univerify', |
31 | success: (res) => { | 40 | success: (res) => { |
common/requestServer.js
@@ -31,8 +31,9 @@ export const myRequest = (options) => { | @@ -31,8 +31,9 @@ export const myRequest = (options) => { | ||
31 | console.log(result); | 31 | console.log(result); |
32 | 32 | ||
33 | if (result.code == 0) { | 33 | if (result.code == 0) { |
34 | + | ||
34 | resolve(result) | 35 | resolve(result) |
35 | - } else if (result.code == -10000) { | 36 | + } else if (result.code === '-10000') { |
36 | uni.showModal({ | 37 | uni.showModal({ |
37 | title: '提示', | 38 | title: '提示', |
38 | content: result.message, | 39 | content: result.message, |
@@ -41,8 +42,8 @@ export const myRequest = (options) => { | @@ -41,8 +42,8 @@ export const myRequest = (options) => { | ||
41 | if (res.confirm) { | 42 | if (res.confirm) { |
42 | console.log('登录失效'); | 43 | console.log('登录失效'); |
43 | uni.clearStorageSync(); | 44 | uni.clearStorageSync(); |
44 | - uni.reLaunch({ | ||
45 | - url: "../pages/index/index" | 45 | + uni.navigateTo({ |
46 | + url: "/pages/index/index" | ||
46 | }) | 47 | }) |
47 | uni.hideLoading(); | 48 | uni.hideLoading(); |
48 | } | 49 | } |