@@ -31,6 +31,11 @@ instance.interceptors.response.use(
|
|||||||
let res = response.data;
|
let res = response.data;
|
||||||
if (res.hasOwnProperty('token') && res.token!= "")
|
if (res.hasOwnProperty('token') && res.token!= "")
|
||||||
uni.setStorageSync('token', res.token);
|
uni.setStorageSync('token', res.token);
|
||||||
|
if (res.code == 4001) {
|
||||||
|
uni.navigateTo({
|
||||||
|
url:"/pages/login/login"
|
||||||
|
})
|
||||||
|
}
|
||||||
return response.data
|
return response.data
|
||||||
}
|
}
|
||||||
// 对响应数据做些什么
|
// 对响应数据做些什么
|
||||||
|
|||||||
@@ -57,8 +57,12 @@ export default {
|
|||||||
actions: {
|
actions: {
|
||||||
actionLogout(context) {
|
actionLogout(context) {
|
||||||
uni.$ajax("/User/logout").then(res => {
|
uni.$ajax("/User/logout").then(res => {
|
||||||
context.commit('updateUserInfo', {});
|
try {
|
||||||
|
uni.removeStorageSync('updateUserInfo');
|
||||||
uni.setStorageSync('token', "");
|
uni.setStorageSync('token', "");
|
||||||
|
} catch (e) {
|
||||||
|
// error
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user