This commit is contained in:
iizmg
2020-04-30 15:16:50 +08:00
parent 31e5a3013d
commit c83d61267c
+11 -2
View File
@@ -9,19 +9,28 @@ const glob = {
//初始化Axios
this.intiAxios();
},
//读取cookies
getCookie(name) {
var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
if (arr === document.cookie.match(reg)) {
return unescape(arr[2]);
} else {
return null;
}
},
//返回token
getToken() {
//token名称
const TOKEN_NAME = 'token';
//返回TOKEN
return $cookies.get(this.TOKEN_NAME);
return $cookies.get(TOKEN_NAME);
},
//检查是否登陆
checkLogin() {
//检查是否有token
if (!this.getToken()) {
//跳转到登陆页
this.jumpLoginPage();
//this.jumpLoginPage();
}
},
//跳转到登陆页