update sso init

main
old易 2024-09-28 10:27:06 +08:00
parent 9c0f787dd2
commit f669ff4192
3 changed files with 44 additions and 21 deletions

0
.env.development Normal file
View File

0
.env.production Normal file
View File

View File

@ -44,6 +44,7 @@ export default {
const password = ref(''); const password = ref('');
const phone = ref(''); const phone = ref('');
const verificationCode = ref(''); const verificationCode = ref('');
const referer = ref(''); //
// //
const switchTab = (tab) => { const switchTab = (tab) => {
@ -67,22 +68,32 @@ export default {
}, 1000); }, 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 = () => { const initWeChatLogin = () => {
nextTick(() => { 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 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); const state = Math.random().toString(36).substr(2);
new WxLogin({ new WxLogin({
@ -100,6 +111,7 @@ export default {
// //
onMounted(() => { onMounted(() => {
getReferer(); //
initWeChatLogin(); initWeChatLogin();
}); });
@ -135,12 +147,15 @@ export default {
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
overflow: hidden; /* 隐藏滚动条 */ overflow: hidden;
/* 隐藏滚动条 */
background-image: url('https://static-data-ycymedu.oss-cn-shanghai.aliyuncs.com/backgroundImage.png'); background-image: url('https://static-data-ycymedu.oss-cn-shanghai.aliyuncs.com/backgroundImage.png');
background-size: cover; background-size: cover;
background-position: center; background-position: center;
position: relative; /* 设置为相对定位,以支持绝对定位的子元素 */ position: relative;
padding-bottom: 60px; /* 为底部版权信息预留空间 */ /* 设置为相对定位,以支持绝对定位的子元素 */
padding-bottom: 60px;
/* 为底部版权信息预留空间 */
} }
.login-box { .login-box {
@ -152,8 +167,10 @@ export default {
max-width: 400px; max-width: 400px;
text-align: center; text-align: center;
box-sizing: border-box; box-sizing: border-box;
margin-bottom: 30px; /* 增加底部边距 */ margin-bottom: 30px;
margin: 0 auto; /* 居中 */ /* 增加底部边距 */
margin: 0 auto;
/* 居中 */
} }
.logo { .logo {
@ -224,7 +241,8 @@ button:disabled {
} }
.verification-row input { .verification-row input {
width: calc(100% - 120px); /* 确保输入框宽度 */ width: calc(100% - 120px);
/* 确保输入框宽度 */
margin-right: 10px; margin-right: 10px;
} }
@ -233,14 +251,19 @@ button:disabled {
} }
/* 响应式布局 */ /* 响应式布局 */
@media screen and (min-width: 768px) { /* 平板及更大屏幕 */ @media screen and (min-width: 768px) {
/* 平板及更大屏幕 */
.login-container { .login-container {
padding-bottom: 0; /* 移除底部padding */ padding-bottom: 0;
/* 移除底部padding */
} }
.login-box { .login-box {
width: 400px; /* 固定宽度 */ width: 400px;
margin: 0 auto; /* 水平居中 */ /* 固定宽度 */
margin: 0 auto;
/* 水平居中 */
} }
} }
</style> </style>