护照认证
This commit is contained in:
parent
72c47d1c41
commit
47ce6786aa
@ -20,6 +20,15 @@ export const commonOcrRecognizePassportPost = (data) => {
|
||||
return http.post('/ocr/recognize/passport', data);
|
||||
};
|
||||
|
||||
/**
|
||||
* OCR识别户口本
|
||||
* @param {Object} data - OCR请求
|
||||
* @param {string} data.imageUrl - 图片URL
|
||||
*/
|
||||
export const commonOcrRecognizeHouseholdPost = (data) => {
|
||||
return http.post('/ocr/recognize/household', data);
|
||||
};
|
||||
|
||||
/**
|
||||
* 发送短信验证码
|
||||
* @param {Object} data - 验证码请求
|
||||
|
||||
@ -115,11 +115,12 @@
|
||||
<el-radio-group v-model="ocrType">
|
||||
<el-radio label="idcard">身份证认证</el-radio>
|
||||
<el-radio label="passport">护照认证</el-radio>
|
||||
<el-radio label="household">户口本认证</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
|
||||
<!-- 证件照片上传 -->
|
||||
<el-form-item :label="ocrType === 'passport' ? '护照照片' : '身份证照片'" prop="idCardImageUrl">
|
||||
<el-form-item :label="ocrType === 'passport' ? '护照照片' : (ocrType === 'household' ? '户口本照片' : '身份证照片')" prop="idCardImageUrl">
|
||||
<el-upload class="avatar-uploader" action="/api/file/upload" :show-file-list="false"
|
||||
:on-success="handleAvatarSuccess" :before-upload="beforeAvatarUpload">
|
||||
<img v-if="formData.idCardImageUrl" :src="formData.idCardImageUrl" class="avatar" style="height: 150px;" />
|
||||
@ -146,7 +147,7 @@
|
||||
<span v-else style="color: #909399;">请选择性别</span>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item v-if="ocrType === 'idcard'" label="身份证号" prop="idCardNumber">
|
||||
<el-form-item v-if="ocrType === 'idcard' || ocrType === 'household'" label="身份证号" prop="idCardNumber">
|
||||
<el-input v-model="formData.idCardNumber" disabled placeholder="请输入身份证号"></el-input>
|
||||
</el-form-item>
|
||||
|
||||
@ -192,12 +193,13 @@ import { auths } from '/@/utils/authFunction';
|
||||
import ProTable from '/@/components/ProTable/index.vue';
|
||||
import { teamPageGet, teamDetailGet, teamAddPost, teamDeleteDelete, teamUpdatePut } from '/@/api/match/unituser';
|
||||
import { appuserAthletePageGet, appuserAthleteAddPost, appuserAthleteUpdatePut, appuserLeaderPageGet, appuserCoachPageGet, appuserMemberDeletePost } from '/@/api/match/appuser';
|
||||
import { commonOcrRecognizeIdcardPost, commonOcrRecognizePassportPost, commonSmsSendVerificationCodePost } from '/@/api/match/common';
|
||||
import { commonOcrRecognizeIdcardPost, commonOcrRecognizePassportPost, commonOcrRecognizeHouseholdPost, commonSmsSendVerificationCodePost } from '/@/api/match/common';
|
||||
// 定义表单引用类型
|
||||
const formRef = ref();
|
||||
const activeTab = ref('first')
|
||||
const getDefaultFormData = () => ({
|
||||
id: undefined,
|
||||
authType: 1,
|
||||
name: '',
|
||||
idCardNumber: '',
|
||||
gender: '',
|
||||
@ -208,7 +210,7 @@ const getDefaultFormData = () => ({
|
||||
});
|
||||
const formData = ref(getDefaultFormData())
|
||||
|
||||
// 证件识别类型:idcard-身份证,passport-护照
|
||||
// 证件识别类型:idcard-身份证,passport-护照, household-户口本
|
||||
const ocrType = ref('idcard')
|
||||
|
||||
const initParam = ref({
|
||||
@ -566,13 +568,26 @@ const onOpenMenu = (row) => {
|
||||
originalMobile.value = '';
|
||||
|
||||
if (row && typeof row === 'object') {
|
||||
const savedAuthType = Number(row.authType) || 1;
|
||||
let savedOcrType = 'idcard';
|
||||
if (savedAuthType === 2) savedOcrType = 'passport';
|
||||
else if (savedAuthType === 3) savedOcrType = 'household';
|
||||
ocrType.value = savedOcrType;
|
||||
|
||||
const imageUrl = savedAuthType === 2
|
||||
? (row.passportPhotoUrl || row.idCardImageUrl || '')
|
||||
: savedAuthType === 3
|
||||
? (row.householdPhotoUrl || row.idCardImageUrl || '')
|
||||
: (row.idCardImageUrl || '');
|
||||
|
||||
formData.value = {
|
||||
...getDefaultFormData(),
|
||||
authType: savedAuthType,
|
||||
id: row.id,
|
||||
name: row.name ?? '',
|
||||
idCardNumber: row.idCardNumber ?? '',
|
||||
gender: row.gender !== undefined && row.gender !== null ? Number(row.gender) : '',
|
||||
idCardImageUrl: row.idCardImageUrl ?? '',
|
||||
idCardImageUrl: imageUrl,
|
||||
birthDate: row.birthDate ?? '',
|
||||
mobile: row.mobile ?? row.mobile ?? '',
|
||||
};
|
||||
@ -663,28 +678,36 @@ const handleAvatarSuccess = async (response,
|
||||
uploadFile) => {
|
||||
//response[0].url
|
||||
const imageUrl = response[0].url;
|
||||
const res = ocrType.value === 'passport'
|
||||
? await commonOcrRecognizePassportPost({ imageUrl })
|
||||
: await commonOcrRecognizeIdcardPost({ imageUrl });
|
||||
if(res.succeeded){
|
||||
if(ocrType.value === 'passport'){
|
||||
formData.value.name = res.data.name
|
||||
formData.value.idCardNumber = res.data.passportNumber
|
||||
formData.value.gender = res.data.gender == 'Male' ? 0 : 1
|
||||
formData.value.idCardImageUrl = imageUrl
|
||||
formData.value.birthDate = res.data.issueDateYmd
|
||||
}else{
|
||||
formData.value.name = res.data.name
|
||||
formData.value.idCardNumber = res.data.idCardNumber
|
||||
formData.value.gender = res.data.gender == '男' ? 0 : 1
|
||||
formData.value.idCardImageUrl = imageUrl
|
||||
formData.value.birthDate = res.data.birthDate
|
||||
}
|
||||
|
||||
}else{
|
||||
ElMessage.error('请上传正确的身份证/护照')
|
||||
let res;
|
||||
if (ocrType.value === 'passport') {
|
||||
res = await commonOcrRecognizePassportPost({ imageUrl });
|
||||
} else if (ocrType.value === 'household') {
|
||||
res = await commonOcrRecognizeHouseholdPost({ imageUrl });
|
||||
} else {
|
||||
res = await commonOcrRecognizeIdcardPost({ imageUrl });
|
||||
}
|
||||
console.log(res)
|
||||
if (res && res.succeeded && res.data) {
|
||||
const data = res.data;
|
||||
formData.value.idCardImageUrl = imageUrl;
|
||||
if (ocrType.value === 'household') {
|
||||
formData.value.name = data.name || '';
|
||||
formData.value.gender = data.gender === '男' ? 0 : 1;
|
||||
formData.value.idCardNumber = data.idCardNumber || '';
|
||||
} else if (ocrType.value === 'passport') {
|
||||
formData.value.name = data.name;
|
||||
formData.value.idCardNumber = data.passportNumber;
|
||||
formData.value.gender = data.gender === 'Male' ? 0 : 1;
|
||||
formData.value.birthDate = data.birthDateYmd || data.birthDate || data.issueDateYmd || '';
|
||||
} else {
|
||||
formData.value.name = data.name;
|
||||
formData.value.idCardNumber = data.idCardNumber;
|
||||
formData.value.gender = data.gender === '男' ? 0 : 1;
|
||||
formData.value.birthDate = data.birthDate || '';
|
||||
}
|
||||
} else {
|
||||
ElMessage.error('请上传正确的证件图片');
|
||||
}
|
||||
console.log(res);
|
||||
}
|
||||
|
||||
const beforeAvatarUpload = () => {
|
||||
@ -706,8 +729,10 @@ const onSubmit = () => {
|
||||
formRef.value.validate(async (valid) => {
|
||||
if (!valid) return;
|
||||
try {
|
||||
const authType = ocrType.value === 'passport' ? 2 : (ocrType.value === 'household' ? 3 : 1);
|
||||
const payload = {
|
||||
...formData.value,
|
||||
authType,
|
||||
gender: formData.value.gender !== undefined && formData.value.gender !== null ? Number(formData.value.gender) : '',
|
||||
mobile: formData.value.mobile,
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user