|
@@ -6,9 +6,24 @@ import { setToken, getToken } from '@/utils/auth' // get token from cookie
|
|
|
|
|
|
// let flag = false; //查看是否登录
|
|
|
|
|
|
-function userLogin(callback) {
|
|
|
+function userLogin(uid, callback) {
|
|
|
if (store.state.isLogin) return callback(true);
|
|
|
ajax.post(store.state.api + '/userLogin', {
|
|
|
+ id: uid,
|
|
|
+ }).then(res => {
|
|
|
+ if (res['data'] != "ERROR") {
|
|
|
+ userLogin2(callback);
|
|
|
+ } else {
|
|
|
+ console.error("错误")
|
|
|
+ }
|
|
|
+ }).catch(err => {
|
|
|
+ console.log(err)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+function userLogin2(callback) {
|
|
|
+ if (store.state.isLogin) return callback(true);
|
|
|
+ ajax.post(store.state.api + '/userLogin2', {
|
|
|
id: getToken(),
|
|
|
}).then(res => {
|
|
|
if (res['data'] != "ERROR") {
|
|
@@ -23,6 +38,7 @@ function userLogin(callback) {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+
|
|
|
function getSystemState(to, callback) {
|
|
|
ajax.get(store.state.api + '/getSystemState', {
|
|
|
uid: store.state.userInfo.userid
|
|
@@ -46,8 +62,9 @@ router.beforeEach(async(to, from, next) => {
|
|
|
console.log(response);
|
|
|
let data = response.data.replaceAll("\'", "\"")
|
|
|
if (data && JSON.parse(data).uid) {
|
|
|
- setToken(JSON.parse(data).uid);
|
|
|
- userLogin((isLogin) => {
|
|
|
+ // setToken(JSON.parse(data).uid);
|
|
|
+ let userid = JSON.parse(data).uid;
|
|
|
+ userLogin(userid, (isLogin) => {
|
|
|
getSystemState(to, () => {
|
|
|
if (!isLogin && to.name != 'resultShowDetail') {
|
|
|
store.commit('getPlanEndProjectData');
|