permission.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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('444a49a3b1d19fc2ba71d3fdee84d055');
  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. lockStatus().then(response=>{
  18. let lockStatus = response.data.data;
  19. if(lockStatus==0){
  20. MessageBox.alert('欢迎来到DGT誉商城系统,已为您发放工龄年限积分,请前往个人中心查看。', '积分发放通知', {
  21. confirmButtonText: '确定',
  22. showClose:false,
  23. callback: action => {
  24. unlock().then(response=>{
  25. next();
  26. })
  27. }
  28. });
  29. }else{
  30. next();
  31. }
  32. })
  33. }else{
  34. const prodHref = 'http://dgt.dgtis.com/oneportal/login';//正式地址
  35. // const prodHref = 'http://dgtcloud.dgtis.com/oneportal/login';//阿里云地址
  36. const devHref = 'http://192.168.100.208:8080/oneportal/login';//测试地址
  37. location.href = process.env.NODE_ENV === 'production' ? prodHref : devHref;
  38. }
  39. }
  40. })
  41. router.afterEach(() => {})