permission.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import router from './router'
  2. import { MessageBox } from 'element-ui';
  3. import { getToken, setToken } from '@/utils/auth' // getToken from cookie
  4. import { lockStatus,unlock } from "@/api/allApi";
  5. //路由跳转之前
  6. router.beforeEach((to, _from, next) => {
  7. setToken('05d98c1c44791e203223c23611392c6b');
  8. const path = to.path;
  9. const Authorization = to.query.Authorization
  10. if (path.indexOf('auth') != -1 && Authorization) {
  11. setToken(Authorization);
  12. console.log(Authorization);
  13. next({ path: '/' });
  14. }else{
  15. const token = getToken();
  16. if( token && token != 'undefined' ){
  17. next();
  18. // lockStatus().then(response=>{
  19. // let lockStatus = response.data.data;
  20. // if(lockStatus==0){
  21. // MessageBox.alert('欢迎来到DGT誉商城系统,已为您发放工龄年限积分,请前往个人中心查看。', '积分发放通知', {
  22. // confirmButtonText: '确定',
  23. // showClose:false,
  24. // callback: action => {
  25. // unlock().then(response=>{
  26. // next();
  27. // })
  28. // }
  29. // });
  30. // }else{
  31. // next();
  32. // }
  33. // })
  34. }else{
  35. const prodHref = 'http://dgt.dgtis.com/oneportal/login';//正式地址
  36. // const prodHref = 'http://dgtcloud.dgtis.com/oneportal/login';//阿里云地址
  37. const devHref = 'http://192.168.100.208:8080/oneportal/login';//测试地址
  38. location.href = process.env.NODE_ENV === 'production' ? prodHref : devHref;
  39. }
  40. }
  41. })
  42. router.afterEach(() => {})