old易 2024-10-08 11:39:28 +08:00
parent 661aa6cea7
commit 0c257a2a4c
2 changed files with 91 additions and 78 deletions

View File

@ -1,7 +1,7 @@
-----BEGIN OPENSSH PRIVATE KEY----- -----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
QyNTUxOQAAACA20GNyqm4LjDk1gVVnW1B8LnWw8pbZdDCwI+5wU4ishgAAAJAhuzaBIbs2 QyNTUxOQAAACA20GNyqm4LjDk1gVVnW1B8LnWw8pbZdDCwI+5wU4ishgAAAJDh6vD44erw
gQAAAAtzc2gtZWQyNTUxOQAAACA20GNyqm4LjDk1gVVnW1B8LnWw8pbZdDCwI+5wU4ishg +AAAAAtzc2gtZWQyNTUxOQAAACA20GNyqm4LjDk1gVVnW1B8LnWw8pbZdDCwI+5wU4ishg
AAAECr8W4FkpVwEtReeKxc7PoSe3q089fPxreRPvGDI3+o9TbQY3KqbguMOTWBVWdbUHwu AAAECr8W4FkpVwEtReeKxc7PoSe3q089fPxreRPvGDI3+o9TbQY3KqbguMOTWBVWdbUHwu
dbDyltl0MLAj7nBTiKyGAAAACllJX0xJVVlBTkcBAgM= dbDyltl0MLAj7nBTiKyGAAAACllJX0xJVVlBTkcBAgM=
-----END OPENSSH PRIVATE KEY----- -----END OPENSSH PRIVATE KEY-----

View File

@ -26,7 +26,8 @@
{{ countdown !== null ? `${countdown} 秒后重新发送` : '获取验证码' }} {{ countdown !== null ? `${countdown} 秒后重新发送` : '获取验证码' }}
</button> </button>
</div> </div>
<button @click="verifyCodeAndLogin" :disabled="!isPhoneValid || !isVerificationCodeValid || countdown !== null">登录</button> <button @click="verifyCodeAndLogin"
:disabled="!isPhoneValid || !isVerificationCodeValid || countdown !== null">登录</button>
</div> </div>
<div v-if="selectedTab === 'wechat'"> <div v-if="selectedTab === 'wechat'">
@ -80,29 +81,29 @@ export default {
}; };
// //
const getReferer = () => { const getReferer = () => {
let ref = document.referrer; let ref = document.referrer;
console.log('refref:', ref); console.log('refref:', ref);
// //
if (!ref) { if (!ref) {
if (process.env.NODE_ENV === 'development') { if (process.env.NODE_ENV === 'development') {
ref = 'https://www.ycymedu.com'; // ref = 'https://www.ycymedu.com'; //
} else { } else {
console.log('当前是生产环境'); console.log('当前是生产环境');
window.location.href = "https://www.ycymedu.com"; // window.location.href = "https://www.ycymedu.com"; //
} }
} else { } else {
try { try {
const url = new URL(ref); const url = new URL(ref);
console.log('url:', url); console.log('url:', url);
referer.value = url.origin; // referer.value = url.origin; //
} catch (error) { } catch (error) {
console.error('解析来源网址时出错:', error); console.error('解析来源网址时出错:', error);
} }
} }
}; };
// //
@ -143,50 +144,32 @@ export default {
// //
const sendVerificationCode = () => { const sendVerificationCode = () => {
if (isPhoneValid.value) { if (isPhoneValid.value) {
// //
axios.post('https://api.sso.ycymedu.com/api/syssms/sendsms', { axios.post('https://api.sso.ycymedu.com/api/syssms/sendsms', {
phoneNumber: phone.value phoneNumber: phone.value
})
.then(response => {
if(response.data.code === '200'){
console.log('验证码发送成功:', response.data);
startCountdown(); //
}else{
console.log('验证码发送失败:', response.data);
phoneError.value = response.data.message;
}
}) })
.catch(error => { .then(response => {
console.error('发送验证码失败:', error); if (response.data.code === '200') {
phoneError.value = '发送验证码失败,请稍后再试'; console.log('验证码发送成功:', response.data);
}); startCountdown(); //
} } else {
}; console.log('验证码发送失败:', response.data);
phoneError.value = response.data.message;
}
})
.catch(error => {
console.error('发送验证码失败:', error);
phoneError.value = '发送验证码失败,请稍后再试';
});
}
};
// //
const isVerificationCodeValid = computed(() => { const isVerificationCodeValid = computed(() => {
if (!verificationCode.value) { if (!verificationCode.value) {
verificationCodeError.value = '请输入验证码'; verificationCodeError.value = '请输入验证码';
return false; return false;
} }
axios.post('https://api.sso.ycymedu.com/api/syswechat/smslogin', {
phoneNumber: phone.value,
code:verificationCode.value,
redirect_uri:referer.value
})
.then(response => {
if(response.data.code === '200'){
console.log('验证码发送成功:', response.data);
startCountdown(); //
}else{
console.log('验证码发送失败:', response.data);
phoneError.value = response.data.message;
}
})
.catch(error => {
console.error('发送验证码失败:', error);
phoneError.value = '发送验证码失败,请稍后再试';
});
verificationCodeError.value = ''; // verificationCodeError.value = ''; //
return true; return true;
}); });
@ -250,17 +233,47 @@ export default {
// //
const login = () => { const login = () => {
if (selectedTab.value === 'password') {
if (!isUsernameValid.value) { switch (selectedTab.value) {
alert('请检查手机号'); case 'wechat':
return; //
} break;
if (!isPasswordValid.value) { case 'password':
alert('请检查密码'); if (!isUsernameValid.value) {
return; alert('请检查手机号');
} return;
alert('账号密码登录功能尚未实现'); }
if (!isPasswordValid.value) {
alert('请检查密码');
return;
}
alert('账号密码登录功能尚未实现');
//
break;
case 'phone':
axios.post('https://api.sso.ycymedu.com/api/syswechat/smslogin', {
phoneNumber: phone.value,
code: verificationCode.value,
redirect_uri: referer.value
})
.then(response => {
if (response.data.code === '200') {
console.log('验证码发送成功:', response.data);
startCountdown(); //
} else {
console.log('验证码发送失败:', response.data);
phoneError.value = response.data.message;
}
})
.catch(error => {
console.error('发送验证码失败:', error);
phoneError.value = '发送验证码失败,请稍后再试';
});
break;
} }
}; };
return { return {
@ -411,11 +424,11 @@ button:disabled {
/* 水平居中 */ /* 水平居中 */
} }
.error-message { .error-message {
color: red; color: red;
font-size: 12px; font-size: 12px;
margin-top: -10px; margin-top: -10px;
margin-bottom: 10px; margin-bottom: 10px;
} }
} }
</style> </style>