mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-mobile.git
synced 2025-12-06 17:36:45 +08:00
33 lines
891 B
JavaScript
33 lines
891 B
JavaScript
//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'; |