|
@@ -6,25 +6,9 @@ import { setToken, getToken } from '@/utils/auth' // get token from cookie
|
|
|
|
|
|
// let flag = false; //查看是否登录
|
|
// let flag = false; //查看是否登录
|
|
|
|
|
|
-function userLogin(uid, callback) {
|
|
|
|
|
|
+function userLogin(callback) {
|
|
if (store.state.isLogin) return callback(true);
|
|
if (store.state.isLogin) return callback(true);
|
|
ajax.post(store.state.api + '/userLogin', {
|
|
ajax.post(store.state.api + '/userLogin', {
|
|
- id: uid,
|
|
|
|
- }).then(res => {
|
|
|
|
- if (res['data'] != "ERROR") {
|
|
|
|
- setToken(res.data.userid)
|
|
|
|
- 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(),
|
|
id: getToken(),
|
|
}).then(res => {
|
|
}).then(res => {
|
|
if (res['data'] != "ERROR") {
|
|
if (res['data'] != "ERROR") {
|
|
@@ -39,15 +23,14 @@ function userLogin2(callback) {
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
function getSystemState(to, callback) {
|
|
function getSystemState(to, callback) {
|
|
ajax.get(store.state.api + '/getSystemState', {
|
|
ajax.get(store.state.api + '/getSystemState', {
|
|
- uid: getToken()
|
|
|
|
|
|
+ uid: store.state.userInfo.userid
|
|
}).then(res => {
|
|
}).then(res => {
|
|
let state = res['data'][0][0]['state'];
|
|
let state = res['data'][0][0]['state'];
|
|
store.commit('update', ['systemState', state]);
|
|
store.commit('update', ['systemState', state]);
|
|
if (state != 0 && store.state.userInfo.type != 0 && to.name != 'CloseWeb') return router.push('/CloseWeb');
|
|
if (state != 0 && store.state.userInfo.type != 0 && to.name != 'CloseWeb') return router.push('/CloseWeb');
|
|
- if (state == 0 && to.name == 'CloseWeb') return router.push('/home');
|
|
|
|
|
|
+ if (state == 0 && to.name == 'CloseWeb') return router.push('/projectApplication');
|
|
callback(state);
|
|
callback(state);
|
|
}).catch(err => {
|
|
}).catch(err => {
|
|
console.log(err)
|
|
console.log(err)
|
|
@@ -63,10 +46,8 @@ router.beforeEach(async(to, from, next) => {
|
|
console.log(response);
|
|
console.log(response);
|
|
let data = response.data.replaceAll("\'", "\"")
|
|
let data = response.data.replaceAll("\'", "\"")
|
|
if (data && JSON.parse(data).uid) {
|
|
if (data && JSON.parse(data).uid) {
|
|
- // setToken(JSON.parse(data).uid);
|
|
|
|
- let userid = JSON.parse(data).uid;
|
|
|
|
- // let userid = 1270;
|
|
|
|
- userLogin(userid, (isLogin) => {
|
|
|
|
|
|
+ setToken(JSON.parse(data).uid);
|
|
|
|
+ userLogin((isLogin) => {
|
|
getSystemState(to, () => {
|
|
getSystemState(to, () => {
|
|
if (!isLogin && to.name != 'resultShowDetail') {
|
|
if (!isLogin && to.name != 'resultShowDetail') {
|
|
store.commit('getPlanEndProjectData');
|
|
store.commit('getPlanEndProjectData');
|