|
|
|
@ -4,11 +4,12 @@ |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
import router from './router/router' |
|
|
|
import router from './router/router' |
|
|
|
import store from './store' |
|
|
|
import store from './store' |
|
|
|
import {validatenull} from '@/util/validate' |
|
|
|
import { validatenull } from '@/util/validate' |
|
|
|
import {getToken} from '@/util/auth' |
|
|
|
import { getToken } from '@/util/auth' |
|
|
|
import NProgress from 'nprogress' // progress bar
|
|
|
|
import NProgress from 'nprogress' // progress bar
|
|
|
|
import 'nprogress/nprogress.css' // progress bar style
|
|
|
|
import 'nprogress/nprogress.css' // progress bar style
|
|
|
|
NProgress.configure({showSpinner: false}); |
|
|
|
import { MessageBox } from 'element-ui'; |
|
|
|
|
|
|
|
NProgress.configure({ showSpinner: false }); |
|
|
|
const lockPage = store.getters.website.lockPage; //锁屏页
|
|
|
|
const lockPage = store.getters.website.lockPage; //锁屏页
|
|
|
|
router.beforeEach((to, from, next) => { |
|
|
|
router.beforeEach((to, from, next) => { |
|
|
|
const meta = to.meta || {}; |
|
|
|
const meta = to.meta || {}; |
|
|
|
@ -16,14 +17,14 @@ router.beforeEach((to, from, next) => { |
|
|
|
store.commit('SET_IS_MENU', isMenu === undefined); |
|
|
|
store.commit('SET_IS_MENU', isMenu === undefined); |
|
|
|
if (getToken()) { |
|
|
|
if (getToken()) { |
|
|
|
if (store.getters.isLock && to.path !== lockPage) { //如果系统激活锁屏,全部跳转到锁屏页
|
|
|
|
if (store.getters.isLock && to.path !== lockPage) { //如果系统激活锁屏,全部跳转到锁屏页
|
|
|
|
next({path: lockPage}) |
|
|
|
next({ path: lockPage }) |
|
|
|
} else if (to.path === '/newlogin') { //如果登录成功访问登录页跳转到主页
|
|
|
|
} else if (to.path === '/newlogin') { //如果登录成功访问登录页跳转到主页
|
|
|
|
next({path: '/wel/index'}) |
|
|
|
next({ path: '/wel/index' }) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
//如果用户信息为空则获取用户信息,获取用户信息失败,跳转到登录页
|
|
|
|
//如果用户信息为空则获取用户信息,获取用户信息失败,跳转到登录页
|
|
|
|
if (store.getters.token.length === 0) { |
|
|
|
if (store.getters.token.length === 0) { |
|
|
|
store.dispatch('FedLogOut').then(() => { |
|
|
|
store.dispatch('FedLogOut').then(() => { |
|
|
|
next({path: '/newlogin'}) |
|
|
|
next({ path: '/newlogin' }) |
|
|
|
}) |
|
|
|
}) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
const value = to.query.src || to.fullPath; |
|
|
|
const value = to.query.src || to.fullPath; |
|
|
|
@ -53,9 +54,58 @@ router.beforeEach((to, from, next) => { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
console.log('nologin===permission===========',to.path) |
|
|
|
console.log('nologin===permission===========', to,from) |
|
|
|
|
|
|
|
const ssotoken = to.query.SSOToken; |
|
|
|
|
|
|
|
if (process.env.NODE_ENV == "production" && to.path != '/newlogin') { |
|
|
|
|
|
|
|
//过滤ssotoken重新拼接回调地址
|
|
|
|
|
|
|
|
let newQuery = JSON.parse(JSON.stringify(to.query)); |
|
|
|
|
|
|
|
delete newQuery.SSOToken; |
|
|
|
|
|
|
|
let fallbackUrl = window.location.href.substring(0, window.location.href.indexOf("?")); |
|
|
|
|
|
|
|
let keys = Object.keys(newQuery); |
|
|
|
|
|
|
|
for (let i = 0; i < keys.length; i++) { |
|
|
|
|
|
|
|
if (i === 0) { |
|
|
|
|
|
|
|
fallbackUrl = fallbackUrl + '?' + keys[i] + '=' + newQuery[keys[i]] |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
fallbackUrl = fallbackUrl + '&' + keys[i] + '=' + newQuery[keys[i]] |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// alert(fallbackUrl)
|
|
|
|
|
|
|
|
// router.replace({path: fallbackUrl})
|
|
|
|
|
|
|
|
store.dispatch("LoginBySso", { SSOToken: ssotoken, grantType: 'yawei', fallbackUrl: fallbackUrl }) |
|
|
|
|
|
|
|
.then(() => { |
|
|
|
|
|
|
|
// this.loading = false;
|
|
|
|
|
|
|
|
console.log('=============登录成功') |
|
|
|
|
|
|
|
router.replace({ path: fallbackUrl }) |
|
|
|
|
|
|
|
}, err => { |
|
|
|
|
|
|
|
// this.loading = false;
|
|
|
|
|
|
|
|
console.log('err=======res', err) |
|
|
|
|
|
|
|
if (err.error == 'invalid_request') { |
|
|
|
|
|
|
|
window.location.href = err.error_description;//重定向
|
|
|
|
|
|
|
|
} else if (err.error == 'invalid_grant') { |
|
|
|
|
|
|
|
MessageBox.confirm(err.error_description, '提示', { |
|
|
|
|
|
|
|
confirmButtonText: '确定', |
|
|
|
|
|
|
|
showClose: false, |
|
|
|
|
|
|
|
showCancelButton: false, |
|
|
|
|
|
|
|
type: 'warning', |
|
|
|
|
|
|
|
closeOnClickModal: false |
|
|
|
|
|
|
|
}).then(() => { |
|
|
|
|
|
|
|
window.location.href = 'http://jhoa.qd.gov.cn/Default.aspx'; |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
MessageBox.confirm(err.error_description || '登录失败', '提示', { |
|
|
|
|
|
|
|
confirmButtonText: '确定', |
|
|
|
|
|
|
|
showClose: false, |
|
|
|
|
|
|
|
showCancelButton: false, |
|
|
|
|
|
|
|
type: 'warning', |
|
|
|
|
|
|
|
closeOnClickModal: false |
|
|
|
|
|
|
|
}).then(() => { |
|
|
|
|
|
|
|
window.location.href = 'http://jhoa.qd.gov.cn/Default.aspx'; |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
//判断是否需要认证,没有登录访问去登录页
|
|
|
|
//判断是否需要认证,没有登录访问去登录页
|
|
|
|
if (meta.isAuth === false) { |
|
|
|
else if (meta.isAuth === false) { |
|
|
|
next() |
|
|
|
next() |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
next('/newlogin') |
|
|
|
next('/newlogin') |
|
|
|
|