合并解决冲突

This commit is contained in:
yujicun
2023-08-02 15:36:46 +08:00
9 changed files with 69 additions and 30 deletions

View File

@@ -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() {