Signed-off-by: YangWX <shiy720@hotmail.com>
This commit is contained in:
YangWX
2023-03-18 10:21:04 +08:00
parent 3cfb5daed7
commit 5497e73d38
2 changed files with 24 additions and 15 deletions

View File

@@ -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
} }
// 对响应数据做些什么 // 对响应数据做些什么

View File

@@ -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
}
}); });
} }
} }