update sso init
parent
9c0f787dd2
commit
f669ff4192
|
|
@ -44,6 +44,7 @@ export default {
|
|||
const password = ref('');
|
||||
const phone = ref('');
|
||||
const verificationCode = ref('');
|
||||
const referer = ref(''); // 新增响应式变量来存储来源网址
|
||||
|
||||
// 切换标签页
|
||||
const switchTab = (tab) => {
|
||||
|
|
@ -67,22 +68,32 @@ export default {
|
|||
}, 1000);
|
||||
};
|
||||
|
||||
// 获取来源页面的域名
|
||||
const getReferer = () => {
|
||||
let ref = document.referrer;
|
||||
if (!ref) {
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
ref = 'https://www.ycymedu.com';
|
||||
console.log('当前是开发环境');
|
||||
} else if (process.env.NODE_ENV === 'production') {
|
||||
console.log('当前是生产环境');
|
||||
window.location.href = "https://www.ycymedu.com";
|
||||
}
|
||||
} else {
|
||||
// 提取来源网址的域名部分
|
||||
const url = new URL(ref);
|
||||
ref = url.origin;
|
||||
}
|
||||
referer.value = ref; // 存储来源网址
|
||||
};
|
||||
|
||||
|
||||
// 微信扫码登录初始化
|
||||
const initWeChatLogin = () => {
|
||||
nextTick(() => {
|
||||
|
||||
// 获取来源页面的域名
|
||||
let referer = document.referrer;
|
||||
if (!referer) {
|
||||
// 如果无法获取 referrer,默认使用当前页面的域名
|
||||
referer = "https://www.ycymedu.com";
|
||||
} else {
|
||||
// 提取来源网址的域名部分
|
||||
const url = new URL(referer);
|
||||
referer = url.origin;
|
||||
}
|
||||
const appid = 'wxf8db44d5ec082dfc';
|
||||
const redirectUri = encodeURIComponent('https://api.sso.ycymedu.com/api/syswechat/snlogin?redirect_uri='+referer);
|
||||
const redirectUri = encodeURIComponent('https://api.sso.ycymedu.com/api/syswechat/snlogin?redirect_uri=' + referer);
|
||||
const state = Math.random().toString(36).substr(2);
|
||||
|
||||
new WxLogin({
|
||||
|
|
@ -100,6 +111,7 @@ export default {
|
|||
|
||||
// 在组件加载时初始化微信扫码登录
|
||||
onMounted(() => {
|
||||
getReferer(); // 获取来源网址
|
||||
initWeChatLogin();
|
||||
});
|
||||
|
||||
|
|
@ -135,12 +147,15 @@ export default {
|
|||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
overflow: hidden; /* 隐藏滚动条 */
|
||||
overflow: hidden;
|
||||
/* 隐藏滚动条 */
|
||||
background-image: url('https://static-data-ycymedu.oss-cn-shanghai.aliyuncs.com/backgroundImage.png');
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
position: relative; /* 设置为相对定位,以支持绝对定位的子元素 */
|
||||
padding-bottom: 60px; /* 为底部版权信息预留空间 */
|
||||
position: relative;
|
||||
/* 设置为相对定位,以支持绝对定位的子元素 */
|
||||
padding-bottom: 60px;
|
||||
/* 为底部版权信息预留空间 */
|
||||
}
|
||||
|
||||
.login-box {
|
||||
|
|
@ -152,8 +167,10 @@ export default {
|
|||
max-width: 400px;
|
||||
text-align: center;
|
||||
box-sizing: border-box;
|
||||
margin-bottom: 30px; /* 增加底部边距 */
|
||||
margin: 0 auto; /* 居中 */
|
||||
margin-bottom: 30px;
|
||||
/* 增加底部边距 */
|
||||
margin: 0 auto;
|
||||
/* 居中 */
|
||||
}
|
||||
|
||||
.logo {
|
||||
|
|
@ -224,7 +241,8 @@ button:disabled {
|
|||
}
|
||||
|
||||
.verification-row input {
|
||||
width: calc(100% - 120px); /* 确保输入框宽度 */
|
||||
width: calc(100% - 120px);
|
||||
/* 确保输入框宽度 */
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
|
|
@ -233,14 +251,19 @@ button:disabled {
|
|||
}
|
||||
|
||||
/* 响应式布局 */
|
||||
@media screen and (min-width: 768px) { /* 平板及更大屏幕 */
|
||||
@media screen and (min-width: 768px) {
|
||||
|
||||
/* 平板及更大屏幕 */
|
||||
.login-container {
|
||||
padding-bottom: 0; /* 移除底部padding */
|
||||
padding-bottom: 0;
|
||||
/* 移除底部padding */
|
||||
}
|
||||
|
||||
.login-box {
|
||||
width: 400px; /* 固定宽度 */
|
||||
margin: 0 auto; /* 水平居中 */
|
||||
width: 400px;
|
||||
/* 固定宽度 */
|
||||
margin: 0 auto;
|
||||
/* 水平居中 */
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
Loading…
Reference in New Issue