complte model
parent
c4d421c410
commit
d4f7f15a89
|
|
@ -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>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue