mirror of
https://github.com/certd/certd.git
synced 2025-11-25 09:10:11 +08:00
修复邮箱注册验证码报错的bug
This commit is contained in:
@@ -56,10 +56,10 @@ function onChange(data: any) {
|
||||
}
|
||||
|
||||
async function getCaptchaForm() {
|
||||
return await captchaRef.value.getCaptchaForm();
|
||||
return await captchaRef.value?.getCaptchaForm();
|
||||
}
|
||||
async function reset() {
|
||||
await captchaRef.value.reset();
|
||||
await captchaRef.value?.reset();
|
||||
}
|
||||
defineExpose({
|
||||
getCaptchaForm,
|
||||
|
||||
@@ -53,6 +53,13 @@ function callback(res: { ret: number; ticket: string; randstr: string; errorCode
|
||||
// res(验证成功) = {ret: 0, ticket: "String", randstr: "String"}
|
||||
// res(请求验证码发生错误,验证码自动返回trerror_前缀的容灾票据) = {ret: 0, ticket: "String", randstr: "String", errorCode: Number, errorMessage: "String"}
|
||||
// 此处代码仅为验证结果的展示示例,真实业务接入,建议基于ticket和errorCode情况做不同的业务处理
|
||||
|
||||
if (res.errorCode && res.errorCode > 0) {
|
||||
notification.error({
|
||||
message: `验证码验证失败:${res.errorMessage || res.errorCode}`,
|
||||
});
|
||||
}
|
||||
|
||||
if (res.ret === 0) {
|
||||
emitChange({
|
||||
ticket: res.ticket,
|
||||
@@ -116,7 +123,7 @@ function emitChange(value: any) {
|
||||
emit("change", value);
|
||||
}
|
||||
function reset() {
|
||||
captchaInstanceRef.value.instance.reset();
|
||||
captchaInstanceRef.value?.instance?.reset();
|
||||
}
|
||||
|
||||
watch(
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
</a-input-password>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item has-feedback name="imgCode" label="验证码" :rules="rules.imgCode">
|
||||
<a-form-item has-feedback name="captchaForEmail" label="验证码" :rules="rules.captchaForEmail">
|
||||
<CaptchaInput v-model:model-value="formState.captchaForEmail"></CaptchaInput>
|
||||
</a-form-item>
|
||||
|
||||
@@ -118,6 +118,7 @@ export default defineComponent({
|
||||
password: "",
|
||||
confirmPassword: "",
|
||||
captcha: null,
|
||||
captchaForEmail: null,
|
||||
});
|
||||
|
||||
const rules = {
|
||||
@@ -180,10 +181,10 @@ export default defineComponent({
|
||||
message: "请通过验证码",
|
||||
},
|
||||
],
|
||||
imgCode: [
|
||||
captchaForEmail: [
|
||||
{
|
||||
required: true,
|
||||
message: "请输入验证码",
|
||||
message: "请通过验证码",
|
||||
},
|
||||
],
|
||||
};
|
||||
@@ -204,7 +205,7 @@ export default defineComponent({
|
||||
password: formState.password,
|
||||
username: formState.username,
|
||||
email: formState.email,
|
||||
captcha: formState.captcha,
|
||||
captcha: registerType.value === "email" ? formState.captchaForEmail : formState.captcha,
|
||||
validateCode: formState.validateCode,
|
||||
}) as any
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user