mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-mobile.git
synced 2025-12-07 01:46:44 +08:00
2022年5月29日 从svn移到git
This commit is contained in:
33
utils/token.js
Normal file
33
utils/token.js
Normal file
@@ -0,0 +1,33 @@
|
||||
//const TOKEN_KEY = 'XBOE-Access-Token'
|
||||
const TOKEN_KEY = 'token'
|
||||
|
||||
export function getToken() {
|
||||
let token=uni.getStorageSync(TOKEN_KEY);
|
||||
if(!token){
|
||||
token=uni.getStorageSync('userInfo');
|
||||
if(token){
|
||||
token=JSON.parse(token).token;
|
||||
}
|
||||
}
|
||||
return token;
|
||||
//return uni.getStorageSync(TOKEN_KEY);
|
||||
}
|
||||
|
||||
export function setToken(token) {
|
||||
return uni.setStorageSync(TOKEN_KEY,token);
|
||||
}
|
||||
|
||||
export function removeToken() {
|
||||
uni.removeStorageSync(TOKEN_KEY);
|
||||
uni.removeStorageSync('returnUrl');
|
||||
uni.setStorageSync('oh','quit');
|
||||
uni.removeStorageSync('userInfo');
|
||||
uni.removeStorageSync('inner');
|
||||
// #ifdef H5
|
||||
document.cookie = "token=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
|
||||
document.cookie = "userInfo=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
|
||||
document.cookie = "inner=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
|
||||
// #endif
|
||||
}
|
||||
|
||||
export const tokenName='token';
|
||||
Reference in New Issue
Block a user