complte model

main
old易 2024-10-08 14:29:07 +08:00
parent c4d421c410
commit d4f7f15a89
1 changed files with 29 additions and 8 deletions

View File

@ -81,8 +81,8 @@ export default {
if (response.data.code === 200 && response.data.result?.img) { if (response.data.code === 200 && response.data.result?.img) {
state.captchaImage = 'data:image/png;base64,' + response.data.result.img; state.captchaImage = 'data:image/png;base64,' + response.data.result.img;
state.codeId = response.data.result.id; state.codeId = response.data.result.id;
console.log('Response data:', response.data); // console.log('Response data:', response.data);
console.log(state.captchaImage); // console.log(state.captchaImage);
} else { } else {
console.error('Invalid response data:', response.data); console.error('Invalid response data:', response.data);
} }
@ -181,7 +181,7 @@ export default {
startCountdown(); // startCountdown(); //
} else { } else {
console.log('验证码发送失败:', response.data); console.log('验证码发送失败:', response.data);
phoneError.value = response.data.message; phoneError.value = response.data.message.replace(/^\[\w+\]\s*/, '');
} }
}) })
.catch(error => { .catch(error => {
@ -232,6 +232,18 @@ export default {
return true; return true;
}); });
const isPwdCode=computed(()=>{
if (!captchaCode.value) {
captchaError.value = '请输入验证码';
return false;
} else if (captchaCode.value.includes(' ')) {
captchaError.value = '验证码不能包含空格';
return false;
}
captchaError.value = ''; //
return true;
});
// //
onMounted(() => { onMounted(() => {
getReferer(); // getReferer(); //
@ -272,7 +284,7 @@ export default {
// startCountdown(); // // startCountdown(); //
} else { } else {
console.log('登录失败:', response.data); console.log('登录失败:', response.data);
phoneError.value = response.data.message; phoneError.value = response.data.message.replace(/^\[\w+\]\s*/, '');
} }
}) })
.catch(error => { .catch(error => {
@ -284,6 +296,7 @@ export default {
// //
const login = () => { const login = () => {
console.log(captchaCode);
if (!isUsernameValid.value) { if (!isUsernameValid.value) {
alert('请检查手机号'); alert('请检查手机号');
return; return;
@ -292,8 +305,12 @@ export default {
alert('请检查密码'); alert('请检查密码');
return; return;
} }
if(!isPwdCode.value){
alert('请检查验证码');
return;
}
axios.post('https://api.sso.ycymedu.com/api/syswechat/pwdlogin', { axios.post('https://api.sso.ycymedu.com/api/syswechat/pwdlogin', {
phoneNumber: phone.value, phoneNumber: username.value,
password: password.value, password: password.value,
redirect_uri: referer.value, redirect_uri: referer.value,
code: captchaCode.value, code: captchaCode.value,
@ -306,7 +323,7 @@ export default {
// startCountdown(); // // startCountdown(); //
} else { } else {
console.log('登录失败:', response.data); console.log('登录失败:', response.data);
captchaError.value = response.data.message; captchaError.value = response.data.message.replace(/^\[\w+\]\s*/, '');
} }
}) })
.catch(error => { .catch(error => {
@ -337,6 +354,8 @@ export default {
isPasswordValid, isPasswordValid,
login, login,
refreshCaptcha, refreshCaptcha,
captchaCode,
captchaError,
state state
}; };
}, },
@ -473,8 +492,8 @@ button:disabled {
margin-top: -10px; margin-top: -10px;
margin-bottom: 10px; margin-bottom: 10px;
} }
}
.captcha-row { .captcha-row {
display: flex; display: flex;
align-items: center; align-items: center;
margin-bottom: 10px; margin-bottom: 10px;
@ -492,4 +511,6 @@ button:disabled {
border-radius: 4px; border-radius: 4px;
border: 1px solid #ccc; border: 1px solid #ccc;
} }
}
</style> </style>