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