107 lines
4.0 KiB
Vue
107 lines
4.0 KiB
Vue
<template>
|
|
<!--sso单点登录-->
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
name: "checkPage",
|
|
data(){
|
|
return {
|
|
code:''
|
|
}
|
|
},
|
|
methods:{
|
|
// 调用获取水印的前缀接口 获取前缀
|
|
getMarket () {
|
|
return new Promise((resolve,reject)=>{
|
|
this.$api.setting.getOneSetting( this.basMessage['mark'].value).then(res=>{
|
|
if(res.data){
|
|
resolve(res.data.configValue)
|
|
|
|
}else{
|
|
resolve('')
|
|
}
|
|
}).catch(()=>{
|
|
reject('')
|
|
})
|
|
})
|
|
},
|
|
getLogin(){
|
|
this.$api.sso.ssoLogin({code:this.code,
|
|
redirectUrl:'http%3A%2F%2F10.94.1.164%3A8888%2FcheckPage'
|
|
}).then(res=>{
|
|
res.data.roleIdList=res.data.roleEOList.map(item=>{
|
|
return item.id
|
|
})
|
|
|
|
this.$store.commit('saveUserInfo', res.data)
|
|
this.$api.menu.getSysMenu({ roleId: this.$store.getters.userInfo.roleIdList[0] }).then(({ data }) => {
|
|
if (data === null) {
|
|
data = []
|
|
}
|
|
data = data.sort((a, b) => a.sort - b.sort)
|
|
const menu = data.filter(item => item.belong && (item.isButton=='0'|| !item.isButton))
|
|
if(menu.length==0){
|
|
this.$api.login.logout().then(_ => {
|
|
this.$message.warning('暂无权限,请联系管理员授权')
|
|
this.$store.commit('saveUserInfo', null)
|
|
this.$store.commit('setHandleProcess', null)
|
|
this.$store.commit('activeTab', null)
|
|
this.$store.commit('savePathUrl', null)
|
|
this.$store.commit('removeDicts', null)
|
|
localStorage.removeItem('cookie')
|
|
// var sevice = "http://"+window.location.host+"/";
|
|
// var serviceUrl = encodeURIComponent(sevice);
|
|
// 正式
|
|
// window.open("https://caddmuat.changan.com.cn/cas/logout?service=http://10.64.23.30:7766/home", '_self');
|
|
// 测试
|
|
// window.open(BASE_URL.BASE_CHANGAN + "/logout?service=" + BASE_URL.BASE_LOCAL + "/login?loginType=1", '_self');
|
|
this.$router.push('/login')
|
|
})
|
|
return
|
|
}else{
|
|
localStorage.setItem('cookie',res.data.sessionId)
|
|
this.$cookies.get('JSESSIONID')
|
|
let routeList=menu.map(item=> item.href)
|
|
let params
|
|
if(routeList.indexOf('/report/list')>-1){
|
|
params={ path: '/report/list', query: { id: 'AEHJB8YNJ3' }}
|
|
}else if(routeList.indexOf('/report/manager')>-1){
|
|
params={ path: '/report/manager', query: { id: 'AEHJB8YNJ3' }}
|
|
}else if(routeList.indexOf('/userCenter/processCenter')>-1){
|
|
params={ path: '/userCenter/processCenter', query: { id: 'AEHJB8YNJ3' }}
|
|
}
|
|
this.$message.success('登录成功')
|
|
this.getMarket().then((resx)=>{
|
|
this.$store.commit('setMarketpre', resx)
|
|
this.$router.push(params)
|
|
this.$store.commit('savePathUrl', params.path)
|
|
}).catch((resx)=>{
|
|
this.$store.commit('setMarketpre', '')
|
|
this.$router.push({ path: '/report/list', query: { id: 'AEHJB8YNJ3' } })
|
|
})
|
|
}
|
|
})
|
|
|
|
})
|
|
}
|
|
},
|
|
mounted(){
|
|
this.code=this.$route.query.code || ''
|
|
// isADSSO=true&client_id=XXXX&response_type=code&redirect_uri=http%3A%2F%2FXXX.XXXX.XXXX.XXX%3A8080%2FXXXX%2FXXXX&state=http%3A%2F%2Fwww.app1.com%2Ftodu%2F1w2341123
|
|
if(this.code==''){
|
|
// window.location.href ='https://iamuat.faw-vw.com/esc-sso/oauth2.0/authorize?client_id=43da19911e74a14dd5d9&response_type=code&redirect_uri=http%3A%2F%2F127.0.0.1%3A8080%2FcheckPage'
|
|
window.location.href ='https://iam.faw-vw.com/esc-sso/oauth2.0/authorize?client_id=43da19911e74a14dd5d9&response_type=code&redirect_uri=http%3A%2F%2F10.94.1.164%3A8888%2FcheckPage'
|
|
|
|
// window.open('https://iamuat.faw-vw.com/esc-sso/oauth2.0/authorize?isADSSO=true&response_type=code&client_id=&redirect_uri=43da19911e74a14dd5d9'+myUrl)
|
|
}else{
|
|
this.getLogin()
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
|
|
</style>
|