|
@@ -84,7 +84,7 @@
|
|
|
<el-button :loading="loading" type="primary" class="loginBtn" @click.native.prevent="singleLogin">
|
|
|
登录
|
|
|
</el-button>
|
|
|
- <!-- <div class="singleLogin" @click="singleLogin"><i class="el-icon-cloudy" /> 单点登录测试</div> -->
|
|
|
+ <div class="singleLogin" @click="goBackWebUrl"><i class="el-icon-refresh-right" /> 点此返回原网站</div>
|
|
|
</el-form>
|
|
|
<!--开始验证表单 end-->
|
|
|
</div>
|
|
@@ -127,7 +127,8 @@ export default {
|
|
|
username: '', // 15210211200
|
|
|
password: '', // 111111
|
|
|
type: 1, //1=账号密码登录
|
|
|
- captcha: ''
|
|
|
+ captcha: '',//验证码图片
|
|
|
+ code:''//验证code
|
|
|
},
|
|
|
loginRules: { // 2.配置from表单验证规则
|
|
|
username: [{ required: true, trigger: 'blur', validator: validateUsername }],
|
|
@@ -212,7 +213,7 @@ export default {
|
|
|
}else if(res.code!=0&&res.code!=200){
|
|
|
this.$message({
|
|
|
type:'error',
|
|
|
- message:"用户不存在!"
|
|
|
+ message:res.message
|
|
|
})
|
|
|
}
|
|
|
})
|
|
@@ -229,8 +230,17 @@ export default {
|
|
|
getImgCode() {
|
|
|
const that = this
|
|
|
this.$store.dispatch('user/getImgCode').then( res => {
|
|
|
- console.log(res)
|
|
|
- that.codeImg = res.data
|
|
|
+ if(res.code==200){
|
|
|
+ console.log(res)
|
|
|
+ //that.codeImg = res.data
|
|
|
+ that.codeImg = res.data.img;
|
|
|
+ that.loginForm.code = res.data.code;
|
|
|
+
|
|
|
+ console.log(that.loginForm)
|
|
|
+ }else{
|
|
|
+ this.$message.error("获取验证码失败,请稍后再试!")
|
|
|
+ }
|
|
|
+
|
|
|
}).catch(() => {
|
|
|
this.loading = false
|
|
|
})
|
|
@@ -272,11 +282,11 @@ export default {
|
|
|
const backurl = hashParams.get('backurl');
|
|
|
// 获取backurl参数的值
|
|
|
const userurl = hashParams.get('userurl');
|
|
|
-
|
|
|
+
|
|
|
// 解码backurl
|
|
|
const decodedBackurl = decodeURIComponent(backurl);
|
|
|
const decodedUserurl = decodeURIComponent(userurl);
|
|
|
-
|
|
|
+
|
|
|
// 第一种情况, 不含有backUrl或者userUrl 说明登录者是超级管理员
|
|
|
if(hashParams.size==0){
|
|
|
console.log("执行超级管理员登录!")
|
|
@@ -287,13 +297,22 @@ export default {
|
|
|
console.log("执行单点登录!")
|
|
|
const backurlObj = new URL(decodedBackurl);
|
|
|
const back_url = backurlObj.hostname;
|
|
|
- this.login(2)
|
|
|
+ this.login(2,back_url)
|
|
|
|
|
|
}else if(userurl!=null){
|
|
|
+ //第三种情况 含有userurl 说明是会员登录
|
|
|
+ console.log(user_url)
|
|
|
console.log("执行会员登录!")
|
|
|
const backurlObj = new URL(decodedUserurl);
|
|
|
const user_url = backurlObj.hostname;
|
|
|
- this.login(3,user_url)
|
|
|
+
|
|
|
+ if(user_url==""){
|
|
|
+ this.$message.error("登录链接错误!")
|
|
|
+ }else{
|
|
|
+ console.log("当前登录链接是:" + user_url)
|
|
|
+ this.login(3,user_url)
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}else{
|
|
|
this.$message.error("检查登录链接失败,请从正规渠道登录!")
|
|
@@ -304,6 +323,7 @@ export default {
|
|
|
// 登录分路器 end ---------------------------------------->
|
|
|
// 登录 start ---------------------------------------->
|
|
|
login(type,url){
|
|
|
+
|
|
|
//超级管理员登录
|
|
|
if(type==1){
|
|
|
this.$refs.loginForm.validate(valid => {
|
|
@@ -323,7 +343,7 @@ export default {
|
|
|
}else if(res.code!=0&&res.code!=200){
|
|
|
this.$message({
|
|
|
type:'error',
|
|
|
- message:"用户不存在!"
|
|
|
+ message:res.message
|
|
|
})
|
|
|
}
|
|
|
})
|
|
@@ -336,9 +356,8 @@ export default {
|
|
|
//单点登录
|
|
|
if(type==2){
|
|
|
// 获取当前页面的 URL
|
|
|
- const currentUrl = window.location.href;
|
|
|
- const backurlValue = this.getBackUrl(currentUrl);
|
|
|
-
|
|
|
+ this.loginForm.backurl = url;
|
|
|
+
|
|
|
this.$refs.loginForm.validate(valid => {
|
|
|
if (valid) {
|
|
|
this.loading = true
|
|
@@ -352,13 +371,17 @@ export default {
|
|
|
message:"表单项有误,请检查!"
|
|
|
})
|
|
|
}else if(res.code==200){
|
|
|
+ const currentUrl = window.location.href;
|
|
|
+ const backurlValue = this.getBackUrl(currentUrl);
|
|
|
console.log("单点登录成功,开始启动跳转!")
|
|
|
- window.location.href = 'http://admindev.bjzxtw.org.cn/auth/back_login.php?backurl=' + backurlValue + '&token='+res.data.token;
|
|
|
+ console.log(backurlValue)
|
|
|
+ console.log(res.data.token)
|
|
|
+ window.location.href = 'http://admindev.bjzxtw.org.cn/auth/back_login.php?backurl=' + backurlValue + '&token=' + res.data.token;
|
|
|
|
|
|
}else if(res.code!=0&&res.code!=200){
|
|
|
this.$message({
|
|
|
type:'error',
|
|
|
- message:"用户不存在!"
|
|
|
+ message:res.message
|
|
|
})
|
|
|
}
|
|
|
})
|
|
@@ -374,11 +397,10 @@ export default {
|
|
|
}
|
|
|
//会员登录
|
|
|
if(type==3){
|
|
|
+ this.loginForm.userurl = url;
|
|
|
this.$refs.loginForm.validate(valid => {
|
|
|
if (valid) {
|
|
|
this.loading = true;
|
|
|
- this.loginForm.userurl = url;
|
|
|
- //console.log(this.loginForm)
|
|
|
this.$store.dispatch('user/login', this.loginForm).then( res => {
|
|
|
this.loading = false
|
|
|
console.log(res)
|
|
@@ -393,7 +415,7 @@ export default {
|
|
|
}else if(res.code!=0&&res.code!=200){
|
|
|
this.$message({
|
|
|
type:'error',
|
|
|
- message:"用户不存在!"
|
|
|
+ message:res.message
|
|
|
})
|
|
|
}
|
|
|
})
|
|
@@ -404,15 +426,39 @@ export default {
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
- }
|
|
|
+ },
|
|
|
// 登录 end ---------------------------------------->
|
|
|
+
|
|
|
+ // 返回原网站 start---------------------------------------->
|
|
|
+ goBackWebUrl(){
|
|
|
+ // 获得当前域名
|
|
|
+ const urlString = window.location.href;
|
|
|
+ // 创建一个URL对象
|
|
|
+ const url = new URL(urlString);
|
|
|
+ // 获取hash部分(即#后面的部分)
|
|
|
+ const hash = url.hash;
|
|
|
+ // 从hash中提取查询参数
|
|
|
+ const hashParams = new URLSearchParams(hash.split('?')[1]);
|
|
|
+ // 获取backurl参数的值
|
|
|
+ const backurl = hashParams.get('backurl');
|
|
|
+ // 解码backurl
|
|
|
+ const decodedBackurl = decodeURIComponent(backurl);
|
|
|
+
|
|
|
+ if(hashParams.size!=0&&backurl!=null){
|
|
|
+ window.location.href = decodedBackurl
|
|
|
+ }else{
|
|
|
+ this.$message.error("无法返回原网站,请检查登录地址链接!")
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ // 返回原网站 end---------------------------------------->
|
|
|
}
|
|
|
}
|
|
|
</script>
|
|
|
|
|
|
<style scoped lang="less">
|
|
|
.singleLogin {
|
|
|
- font-size: 14px;
|
|
|
+ font-size: 18px;
|
|
|
color: #666;
|
|
|
cursor: pointer;
|
|
|
margin-top: 30px;
|