实名认证表单添加验证和提交修复
实名认证功能已进行以下改进: - 表单字段添加了验证规则,以确保用户输入有效的姓名和身份证号。- 修复了表单提交逻辑,确保只有在通过验证后才会进行实名认证提交。 -调整了实名认证弹窗关闭时的处理逻辑。 - 修正了实名认证成功后的导航路径。master
parent
70eb109eb6
commit
e609d05e5b
|
@ -10,7 +10,7 @@
|
||||||
width="30%"
|
width="30%"
|
||||||
@close="handleDialogClose"
|
@close="handleDialogClose"
|
||||||
>
|
>
|
||||||
<el-form :model="authForm">
|
<el-form :model="authForm" :rules="rules" ref="authFormRef">
|
||||||
<el-form-item label="姓名" :label-width="formLabelWidth">
|
<el-form-item label="姓名" :label-width="formLabelWidth">
|
||||||
<el-input v-model="authForm.name"></el-input>
|
<el-input v-model="authForm.name"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
@ -82,9 +82,17 @@ export default {
|
||||||
name: '',
|
name: '',
|
||||||
idCard: ''
|
idCard: ''
|
||||||
},
|
},
|
||||||
form:{
|
rules: {
|
||||||
|
name: [
|
||||||
}
|
{required: true, message: '请输入姓名', trigger: 'blur'},
|
||||||
|
{min: 2, max: 10, message: '姓名长度在 2 到 10 个字符', trigger: 'blur'}
|
||||||
|
],
|
||||||
|
idCard: [
|
||||||
|
{required: true, message: '请输入身份证号', trigger: 'blur'},
|
||||||
|
{pattern: /^\d{17}[\dXx]$/, message: '身份证号格式不正确', trigger: 'blur'}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
form: {}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
@ -117,6 +125,8 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async handleConfirm() {
|
async handleConfirm() {
|
||||||
|
this.$refs.authFormRef.validate(async (valid) => {
|
||||||
|
if (valid) {
|
||||||
try {
|
try {
|
||||||
const {name, idCard} = this.authForm;
|
const {name, idCard} = this.authForm;
|
||||||
const authResponse = await checkRealNameAuth(this.authForm);
|
const authResponse = await checkRealNameAuth(this.authForm);
|
||||||
|
@ -131,6 +141,12 @@ export default {
|
||||||
this.$message.error('实名认证验证失败,请稍后再试');
|
this.$message.error('实名认证验证失败,请稍后再试');
|
||||||
console.error('实名认证验证失败:', error);
|
console.error('实名认证验证失败:', error);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
console.log('error submit!!');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
async fetchUserBalance() {
|
async fetchUserBalance() {
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue