Commit 083daa657d64141d545e0c8c12e5160a369d06d3
1 parent
83bc6fac
用户登录token过期处理
Showing
1 changed file
with
4 additions
and
1 deletions
yudao-ui-app/util/request/responseInterceptors.js
| @@ -9,9 +9,12 @@ module.exports = vm => { | @@ -9,9 +9,12 @@ module.exports = vm => { | ||
| 9 | //可以根据业务情况做相应的处理 | 9 | //可以根据业务情况做相应的处理 |
| 10 | if (res.data.code === 0) { | 10 | if (res.data.code === 0) { |
| 11 | return res.data | 11 | return res.data |
| 12 | + } else if(res.data.code === 401) { | ||
| 13 | + //用户未登录或登录token已过期 | ||
| 14 | + vm.$store.commit('clearLoginInfo') | ||
| 12 | } else { | 15 | } else { |
| 13 | console.log(res) | 16 | console.log(res) |
| 14 | - //错误信息统一处理 | 17 | + //其他错误信息统一处理 |
| 15 | uni.$u.toast(res.data.msg) | 18 | uni.$u.toast(res.data.msg) |
| 16 | return Promise.reject(res) | 19 | return Promise.reject(res) |
| 17 | } | 20 | } |