mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-mobile.git
synced 2025-12-06 09:26:45 +08:00
合并解决冲突
This commit is contained in:
@@ -2,19 +2,35 @@
|
||||
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;
|
||||
|
||||
let token='';
|
||||
// #ifdef H5
|
||||
var ca = document.cookie.split(';');
|
||||
for(var i=0; i<ca.length; i++)
|
||||
{
|
||||
var c = ca[i].trim();
|
||||
if (c.indexOf(TOKEN_KEY)==0){
|
||||
token=c.substring(TOKEN_KEY.length+1,c.length);
|
||||
break;
|
||||
}
|
||||
}
|
||||
// #endif
|
||||
// #ifndef H5
|
||||
token = uni.getStorageSync(TOKEN_KEY);
|
||||
// #endif
|
||||
return token;
|
||||
//return uni.getStorageSync(TOKEN_KEY);
|
||||
|
||||
}
|
||||
|
||||
export function setToken(token) {
|
||||
return uni.setStorageSync(TOKEN_KEY,token);
|
||||
//如果是h5,token两个小时过期
|
||||
// #ifdef H5
|
||||
var expires = "max-age="+(2*60*60*1000);
|
||||
document.cookie = TOKEN_KEY + "=" + token + ";path=/;" + expires;
|
||||
// #endif
|
||||
// #ifndef H5
|
||||
uni.setStorageSync(TOKEN_KEY,token);
|
||||
// #endif
|
||||
}
|
||||
|
||||
export function removeToken() {
|
||||
|
||||
Reference in New Issue
Block a user