|
@@ -1,7 +1,23 @@
|
|
|
import router from '@/router'
|
|
|
+import store from '@/config/config'
|
|
|
import ajax from '@/api/userApi'
|
|
|
-import { setToken } from '@/utils/auth' // get token from cookie
|
|
|
+import { setToken,getToken } from '@/utils/auth' // get token from cookie
|
|
|
// eslint-disable-next-line prettier/prettier
|
|
|
+
|
|
|
+function userLogin(){
|
|
|
+ ajax.post(store.state.api+'/userLogin',{
|
|
|
+ id:getToken(),
|
|
|
+ }).then(res=>{
|
|
|
+ if(res['data']!="ERROR"){
|
|
|
+ store.commit('update',['userInfo',res['data']])
|
|
|
+ }else{
|
|
|
+ console.error("错误")
|
|
|
+ }
|
|
|
+ }).catch(err=>{
|
|
|
+ console.log(err)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
router.beforeEach(async(to, from, next) => {
|
|
|
// set page title
|
|
|
try {
|
|
@@ -10,14 +26,22 @@ router.beforeEach(async(to, from, next) => {
|
|
|
let data = response.data.replaceAll("\'", "\"")
|
|
|
if (data && JSON.parse(data).uid) {
|
|
|
setToken(JSON.parse(data).uid);
|
|
|
+ userLogin();
|
|
|
+ // console.log(111)
|
|
|
next()
|
|
|
} else {
|
|
|
// setToken("201901766");
|
|
|
+ // setToken("201901763");
|
|
|
+ // setToken('1270')
|
|
|
+ // userLogin();
|
|
|
// next();
|
|
|
window.location.href = "http://10.16.30.130/sso/caslogin.jsp";
|
|
|
}
|
|
|
} catch {
|
|
|
// setToken("201901766");
|
|
|
+ // setToken("201901763");
|
|
|
+ // setToken('1270')
|
|
|
+ // userLogin();
|
|
|
// next();
|
|
|
window.location.href = "http://10.16.30.130/sso/caslogin.jsp";
|
|
|
}
|