提交 4a81a72f authored 作者: 王天霸's avatar 王天霸

1

上级 e52fe058
......@@ -7,3 +7,4 @@ diff a/.env.development b/.env.development (rejected hunks)
# 路由懒加载
VUE_CLI_BABEL_TRANSPILE_MODULES = true
\ No newline at end of file
......@@ -35,3 +35,12 @@ export function getallCloudList(params) {
params
})
}
//获取sso域名
export function getssoUrl(data) {
return request({
url: '//sysapi.jxhh.com/api/v1/oem/webSite/ssoChannel' ,
// url: '//192.168.26.179:6601/api/v1/oem/webSite/ssoChannel' ,
method: 'get',
params: data
})
}
\ No newline at end of file
......@@ -46,7 +46,7 @@
<el-dropdown-item @click.native="setting = true">
<span>布局设置</span>
</el-dropdown-item>
<el-dropdown-item divided @click.native="logout">
<el-dropdown-item divided @click.native="ssooutinfo">
<span>退出登录</span>
</el-dropdown-item>
</el-dropdown-menu>
......@@ -93,10 +93,30 @@ export default {
}
}
},
data(){
return{
ssourl:'',
}
},
methods: {
toggleSideBar() {
this.$store.dispatch('app/toggleSideBar')
},
ssooutinfo(){
var ssa = window.location.host
let data={
domain:ssa
}
this.$store.dispatch('getssourl',data).then((res) => {
if(res.code==1){
this.ssourl = res.data.sso_url
this.logout()
}
})
.catch(() => {
})
},
async logout() {
this.$confirm('确定注销并退出系统吗?', '提示', {
confirmButtonText: '确定',
......@@ -105,10 +125,11 @@ export default {
}).then(() => {
this.$store.dispatch('LogOut').then(() => {
var ssa = window.location.host
var ht = document.location.protocol
if(ssa =='localhost:1024'){
window.location.href='http://sso.jxhh.com/logout?redirect=http://'+ssa+'/login'
window.location.href=ht+'//'+this.ssourl +'/logout?redirect='+ht+'//'+ssa+'/login'
}else{
window.location.href='http://sso.jxhh.com/logout?redirect=http://'+ssa+'/login'
window.location.href=ht+'//'+this.ssourl +'/logout?redirect='+ht+'//'+ssa+'/login'
}
})
})
......
import { login, login2,logout, getInfo, getStatistics } from '@/api/login'
import { getssoUrl } from '@/api/webSite'
import { getToken, setToken, removeToken } from '@/utils/auth'
const user = {
......@@ -8,10 +9,14 @@ const user = {
avatar: '',
sellerid:0,
roles: [],
permissions: []
permissions: [],
ssourl:''
},
mutations: {
SET_SSOURL:(state,ssourl)=>{
state.ssourl = ssourl
},
SET_TOKEN: (state, token) => {
state.token = token
},
......@@ -33,6 +38,20 @@ const user = {
},
actions: {
getssourl({commit},data){
return new Promise((resolve, reject) => {
getssoUrl(data).then(response => {
const date = response.data
debugger
if (response.code == 1) {
commit('SET_SSOURL', date.access_token)
}
resolve(response)
}).catch(error => {
reject(error)
})
})
},
// 新登录
// oLDLogin({ commit }, userInfo) {
// const username = userInfo.username.trim()
......
......@@ -35,21 +35,41 @@ export default {
}
},
created() {
this.tiaozuan();
this.getssourl();
// this.getCookie();
// this.getCode();
},
methods: {
getssourl(){
debugger
var ssa = window.location.host
// var ssa = 'scm.jxhh.com'
let data = {
domain:ssa
}
this.$store.dispatch('getssourl', data)
.then((res) => {
if(res.code==1){
this.ssourl = res.data.sso_url
this.tiaozuan()
}
})
.catch(() => {
})
},
tiaozuan(){
console.log(this.gwToken)
if(this.gwToken == "" || this.gwToken ==null){
var ssa = window.location.host
var ht = document.location.protocol
var that = this
setTimeout(function (){
if(ssa =='localhost:1024'){
window.location.href='http://sso.jxhh.com/login?redirect=http://'+ssa+'/platformlogin'
window.location.href=ht+'//'+that.ssourl+'/login?redirect='+ht+'//'+ssa+'/platformlogin'
}else{
window.location.href='http://sso.jxhh.com/login?redirect=http://'+ssa+'/platformlogin'
window.location.href=ht+'//'+that.ssourl+'/login?redirect='+ht+'//'+ssa+'/platformlogin'
}
}, 1000)
}
......
......@@ -6,10 +6,33 @@
import request from '@/utils/request'
export default {
name: "Platformlogin",
data(){
return{
ssourl:''
}
},
created() {
this.gotosso();
this.getssourl();
},
methods: {
getssourl(){
debugger
var ssa = window.location.host
// var ssa = 'scm.jxhh.com'
let data = {
domain:ssa
}
this.$store.dispatch('getssourl', data)
.then((res) => {
if(res.code==1){
this.ssourl = res.data.sso_url
this.gotosso()
}
})
.catch(() => {
})
},
gotosso() {
var ticket = this.$route.query.ticket;
this.$store.dispatch('Login', {"ticket": ticket}).then((res) => {
......@@ -66,11 +89,13 @@
this.$store.dispatch('Statistic')
this.$store.dispatch('FedLogOut')
var ssa = window.location.host;
var ht = document.location.protocol
let that = this
setTimeout(function () {
if (ssa == 'localhost:1024') {
window.location.href = 'http://sso.jxhh.com/logout?redirect=http://' + ssa + '/login'
window.location.href = ht+'//'+that.ssourl+'/logout?redirect='+ht+'//' + ssa + '/login'
} else {
window.location.href = 'http://sso.jxhh.com/logout?redirect=http://' + ssa + '/login'
window.location.href = ht+'//'+that.ssourl+'/logout?redirect='+ht+'//' + ssa + '/login'
}
}, 1000)
}
......@@ -79,11 +104,12 @@
.catch(() => {
this.$store.dispatch('FedLogOut')
var ssa = window.location.host
var ht = document.location.protocol
setTimeout(function () {
if (ssa == 'localhost:1024') {
window.location.href = 'http://sso.jxhh.com/logout?redirect=http://' + ssa + '/login'
window.location.href = ht+'//'+that.ssourl+'/logout?redirect='+ht+'//' + ssa + '/login'
} else {
window.location.href = 'http://sso.jxhh.com/logout?redirect=http://' + ssa + '/login'
window.location.href = ht+'//'+that.ssourl+'/logout?redirect='+ht+'//' + ssa + '/login'
}
}, 1000)
this.loading = false
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论