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-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
QyNTUxOQAAACA20GNyqm4LjDk1gVVnW1B8LnWw8pbZdDCwI+5wU4ishgAAAJAhuzaBIbs2
gQAAAAtzc2gtZWQyNTUxOQAAACA20GNyqm4LjDk1gVVnW1B8LnWw8pbZdDCwI+5wU4ishg
QyNTUxOQAAACA20GNyqm4LjDk1gVVnW1B8LnWw8pbZdDCwI+5wU4ishgAAAJDh6vD44erw
+AAAAAtzc2gtZWQyNTUxOQAAACA20GNyqm4LjDk1gVVnW1B8LnWw8pbZdDCwI+5wU4ishg
AAAECr8W4FkpVwEtReeKxc7PoSe3q089fPxreRPvGDI3+o9TbQY3KqbguMOTWBVWdbUHwu
dbDyltl0MLAj7nBTiKyGAAAACllJX0xJVVlBTkcBAgM=
-----END OPENSSH PRIVATE KEY-----

View File

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