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

1

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