| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 | 
							- import router from '@/router'
 
- import store from '@/config/config'
 
- import ajax from '@/api/userApi'
 
- import { setToken, getToken } from '@/utils/auth' // get token from cookie
 
- // eslint-disable-next-line prettier/prettier
 
- // let flag = false; //查看是否登录
 
- function userLogin(callback) {
 
-     if (store.state.isLogin) return callback(true);
 
-     ajax.post(store.state.api + '/userLogin', {
 
-         id: getToken(),
 
-     }).then(res => {
 
-         if (res['data'] != "ERROR") {
 
-             store.commit('update', ['userInfo', res['data']]);
 
-             store.commit('update', ['isLogin', true]);
 
-             callback(false)
 
-         } else {
 
-             console.error("错误")
 
-         }
 
-     }).catch(err => {
 
-         console.log(err)
 
-     })
 
- }
 
- function getSystemState(to, callback) {
 
-     ajax.get(store.state.api + '/getSystemState', {
 
-         uid: store.state.userInfo.userid
 
-     }).then(res => {
 
-         let state = res['data'][0][0]['state'];
 
-         store.commit('update', ['systemState', state]);
 
-         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');
 
-         callback(state);
 
-     }).catch(err => {
 
-         console.log(err)
 
-     })
 
- }
 
- router.beforeEach(async(to, from, next) => {
 
-     // set page title
 
-     try {
 
-         // throw Error('测试')
 
-         const response = await ajax.get('https://cxcy.ssti.net.cn/sso/api');
 
-         console.log(response);
 
-         let data = response.data.replaceAll("\'", "\"")
 
-         if (data && JSON.parse(data).uid) {
 
-             setToken(JSON.parse(data).uid);
 
-             userLogin((isLogin) => {
 
-                 getSystemState(to, () => {
 
-                     if (!isLogin && to.name != 'resultShowDetail') {
 
-                         store.commit('getPlanEndProjectData');
 
-                     }
 
-                     next()
 
-                 })
 
-             });
 
-         } else {
 
-             // setToken('2021400203')//yym
 
-             // setToken("201901766");//qgt    
 
-             // userLogin((isLogin)=>{    
 
-             //   getSystemState(to,()=>{
 
-             //     if(!isLogin&&to.name!='resultShowDetail'){
 
-             //       store.commit('getPlanEndProjectData');
 
-             //     }
 
-             //     next()
 
-             //   })
 
-             // });
 
-             window.location.href = "https://cxcy.ssti.net.cn/sso/caslogin.jsp";
 
-         }
 
-     } catch {
 
-         // setToken('2021400203')//yym
 
-         // setToken("1270"); //wyt
 
-         // userLogin((isLogin) => {
 
-         //     getSystemState(to, () => {
 
-         //         if (!isLogin && to.name != 'resultShowDetail') {
 
-         //             store.commit('getPlanEndProjectData');
 
-         //         }
 
-         //         next()
 
-         //     })
 
-         // });
 
-         window.location.href = "https://cxcy.ssti.net.cn/sso/caslogin.jsp";
 
-     }
 
-     // determine whether the user has logged in
 
- })
 
 
  |