|
@@ -1,65 +1,65 @@
|
|
|
import router from '@/router'
|
|
|
import store from '@/config/config'
|
|
|
import ajax from '@/api/userApi'
|
|
|
-import { setToken,getToken } from '@/utils/auth' // get token from cookie
|
|
|
+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 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('/projectApplication');
|
|
|
- callback(state);
|
|
|
- }).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('/projectApplication');
|
|
|
+ callback(state);
|
|
|
+ }).catch(err => {
|
|
|
+ console.log(err)
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
router.beforeEach(async(to, from, next) => {
|
|
|
// set page title
|
|
|
|
|
|
try {
|
|
|
- // throw Error('测试')
|
|
|
- const response = await ajax.get('http://10.16.30.130/sso/api');
|
|
|
+ // 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()
|
|
|
- })
|
|
|
+ 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'){
|
|
@@ -68,7 +68,7 @@ router.beforeEach(async(to, from, next) => {
|
|
|
// next()
|
|
|
// })
|
|
|
// });
|
|
|
- window.location.href = "http://10.16.30.130/sso/caslogin.jsp";
|
|
|
+ window.location.href = "https://cxcy.ssti.net.cn/sso/caslogin.jsp";
|
|
|
}
|
|
|
} catch {
|
|
|
// setToken('2021400203')//yym
|
|
@@ -82,7 +82,7 @@ router.beforeEach(async(to, from, next) => {
|
|
|
// next()
|
|
|
// })
|
|
|
// });
|
|
|
- window.location.href = "http://10.16.30.130/sso/caslogin.jsp";
|
|
|
+ window.location.href = "https://cxcy.ssti.net.cn/sso/caslogin.jsp";
|
|
|
}
|
|
|
// determine whether the user has logged in
|
|
|
|