|
|
@ -1,8 +1,8 @@ |
|
|
|
import { createRouter, createWebHistory } from 'vue-router'; |
|
|
|
import { createRouter, createWebHistory } from 'vue-router'; |
|
|
|
import Layout from '@/layout/index.vue'; |
|
|
|
import Layout from '@/layout/index.vue'; |
|
|
|
import store from '@/store'; |
|
|
|
import store from '@/store'; |
|
|
|
import { refreshToken, casLogin } from '@/api/auth'; |
|
|
|
import { refreshToken } from '@/api/auth'; |
|
|
|
import '@/utils/fineClubSDK'; |
|
|
|
// import '@/utils/fineClubSDK';
|
|
|
|
import { getUid, getExpiresTime } from '@/utils/cookie'; |
|
|
|
import { getUid, getExpiresTime } from '@/utils/cookie'; |
|
|
|
import { delUrlParams } from '@/utils/urlQuery'; |
|
|
|
import { delUrlParams } from '@/utils/urlQuery'; |
|
|
|
|
|
|
|
|
|
|
@ -345,16 +345,17 @@ let getdate = parseInt(new Date().getTime() / 1000); |
|
|
|
router.beforeEach((to, from, next) => { |
|
|
|
router.beforeEach((to, from, next) => { |
|
|
|
// const { title } = to.meta;
|
|
|
|
// const { title } = to.meta;
|
|
|
|
// document.title = getPageTitle(title);
|
|
|
|
// document.title = getPageTitle(title);
|
|
|
|
|
|
|
|
// console.log('to====',to);
|
|
|
|
|
|
|
|
|
|
|
|
const get_ticket = to.query.ticket || 0; |
|
|
|
const get_ticket = to.query.ticket || 0; |
|
|
|
const get_type = to.query.type ? to.query.type : '0'; |
|
|
|
const get_type = to.query.type ? to.query.type : '0'; |
|
|
|
|
|
|
|
|
|
|
|
// ticket空执行删除
|
|
|
|
// ticket空执行删除
|
|
|
|
const is_ticket_null = new URL(window.location); |
|
|
|
const is_ticket_null = new URL(window.location); |
|
|
|
if(is_ticket_null.searchParams.has("ticket")){ |
|
|
|
if (is_ticket_null.searchParams.has("ticket")) { |
|
|
|
if(get_ticket===0 || get_ticket=='null'){ |
|
|
|
if (get_ticket === 0 || get_ticket == 'null') { |
|
|
|
console.log('ticket空'); |
|
|
|
console.log('ticket空'); |
|
|
|
parent.window.location.replace(process.env.VUE_APP_ID_URL+'/login/token/logout?referrer='+encodeURIComponent(process.env.VUE_APP_EDU_URL)); |
|
|
|
parent.window.location.replace(process.env.VUE_APP_ID_URL + '/login/token/logout?referrer=' + encodeURIComponent(process.env.VUE_APP_EDU_URL)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -365,7 +366,25 @@ router.beforeEach((to, from, next) => { |
|
|
|
return getUid() || 0; |
|
|
|
return getUid() || 0; |
|
|
|
} |
|
|
|
} |
|
|
|
window.fineClub.config({ app, getLoginUid, debug: isDev, dev: isDev }); |
|
|
|
window.fineClub.config({ app, getLoginUid, debug: isDev, dev: isDev }); |
|
|
|
window.fineClub.autoReloadOnLoginChange({ loginUrl: process.env.VUE_APP_ID_URL + '/login/signin/?app=edu&protocol=cas&referrer=' + encodeURIComponent(window.location.href) }); |
|
|
|
|
|
|
|
|
|
|
|
// 监听登录
|
|
|
|
|
|
|
|
function callback(data) { |
|
|
|
|
|
|
|
console.log('callback_data', data); |
|
|
|
|
|
|
|
if (!get_ticket && data.uid > 0) { |
|
|
|
|
|
|
|
console.log('跳转到通行证登录'); |
|
|
|
|
|
|
|
let ticket_login_url = '/v1/user/cas/get/ticket/?redirect='+to.path+'&service='+process.env.VUE_APP_EDU_URL+'/v1/user/cas/edu/login/'; |
|
|
|
|
|
|
|
window.location.href = ticket_login_url; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!data.uid) { |
|
|
|
|
|
|
|
console.log('监听到登出', 'del_token'); |
|
|
|
|
|
|
|
store.commit('del_token'); |
|
|
|
|
|
|
|
window.location.reload(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
window.fineClub.onLoginChange(callback); |
|
|
|
|
|
|
|
// if(!getUid()){
|
|
|
|
|
|
|
|
// callback({uid:73851});
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
if (to.meta.title) { |
|
|
|
if (to.meta.title) { |
|
|
|
document.title = to.meta.title; |
|
|
|
document.title = to.meta.title; |
|
|
@ -386,28 +405,11 @@ router.beforeEach((to, from, next) => { |
|
|
|
setTimeout(function () { |
|
|
|
setTimeout(function () { |
|
|
|
next(); |
|
|
|
next(); |
|
|
|
}, 500); |
|
|
|
}, 500); |
|
|
|
} else if (get_ticket) { |
|
|
|
}else if (get_type === 'logout') { |
|
|
|
casLogin(get_ticket).then((res) => {
|
|
|
|
|
|
|
|
if (res.code === 200 && res.status != -1) { |
|
|
|
|
|
|
|
console.log('casLogin', res); |
|
|
|
|
|
|
|
store.commit('set_token', res.data); |
|
|
|
|
|
|
|
setTimeout(function () { |
|
|
|
|
|
|
|
// parent.window.location.replace(process.env.VUE_APP_EDU_URL + to.path);
|
|
|
|
|
|
|
|
// parent.location.reload();
|
|
|
|
|
|
|
|
let jumpUrl = delUrlParams(location.href,['ticket','sid']); |
|
|
|
|
|
|
|
console.log('jumpUrl',jumpUrl); |
|
|
|
|
|
|
|
parent.window.location.replace(jumpUrl); |
|
|
|
|
|
|
|
}, 250); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
next(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else if (get_type === 'logout') { |
|
|
|
|
|
|
|
console.log('logout', 'del_token'); |
|
|
|
console.log('logout', 'del_token'); |
|
|
|
store.commit('del_token'); |
|
|
|
store.commit('del_token'); |
|
|
|
setTimeout(function () { |
|
|
|
setTimeout(function () { |
|
|
|
let jumpUrl = delUrlParams(location.href,['type']); |
|
|
|
let jumpUrl = delUrlParams(location.href, ['type']); |
|
|
|
window.location.replace(jumpUrl); |
|
|
|
window.location.replace(jumpUrl); |
|
|
|
// next();
|
|
|
|
// next();
|
|
|
|
}, 500); |
|
|
|
}, 500); |
|
|
|