提交 e076db79 authored 作者: 钟是志's avatar 钟是志

带token 登录

上级 b80abdae
...@@ -4,19 +4,23 @@ ...@@ -4,19 +4,23 @@
import { isJSON } from '@/webPublic/one_stop_public/copy'; import { isJSON } from '@/webPublic/one_stop_public/copy';
import { getOneStopMyInfo } from '@/webPublic/one_stop_public/utils/utils'; import { getOneStopMyInfo } from '@/webPublic/one_stop_public/utils/utils';
export function setToken(value, time){ export function setToken(value, time) {
if(getToken() !== value){ if (getToken() !== value) {
localStorage.setItem('antd-pro-token-onestop', value); localStorage.setItem('antd-pro-token-onestop', value);
localStorage.setItem('antd-pro-token', value); localStorage.setItem('antd-pro-token', value);
localStorage.setItem('wisdom-school-token', value); localStorage.setItem('wisdom-school-token', value);
getOneStopMyInfo(); return getOneStopMyInfo();
} else {
return new Promise((resolve, reject) => {
resolve(true);
});
} }
} }
/** /**
* 获取token * 获取token
* */ * */
export function getToken(){ export function getToken() {
const x = localStorage.getItem('antd-pro-token-onestop'); const x = localStorage.getItem('antd-pro-token-onestop');
if (x && x.length > 11) { if (x && x.length > 11) {
return x; return x;
...@@ -41,13 +45,13 @@ export const delToken = () => { ...@@ -41,13 +45,13 @@ export const delToken = () => {
export const getUserInfo = () => { export const getUserInfo = () => {
let x = localStorage.getItem('user'); let x = localStorage.getItem('user');
if(isJSON(x)){ if (isJSON(x)) {
x = JSON.parse(x); x = JSON.parse(x);
if(!x.groupsId){ if (!x.groupsId) {
x.groupsId = 'pub'; x.groupsId = 'pub';
} }
return x; return x;
}else{ } else {
return { return {
groupsId: 'pub', groupsId: 'pub',
}; };
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论