动态从身份证图片中获取数据

dev_xd
haha 2025-01-24 23:37:20 +08:00
parent a8853781c4
commit 19fb6e61f9
2 changed files with 46 additions and 4 deletions

View File

@ -25,6 +25,7 @@ import './permission' // permission control
import { useDict } from '@/utils/dict'
import { parseTime, resetForm, addDateRange, formatDuraDate, formatDuraTime, handleTree, selectDictLabel, selectDictLabels } from '@/utils/ruoyi'
import request from '@/utils/request'
// 分页组件
import Pagination from '@/components/Pagination'
@ -70,6 +71,8 @@ app.config.globalProperties.$tryToJson=(str,df)=>{
}
}
app.config.globalProperties.$dt=dayjs;
app.config.globalProperties.$http=request;
// 全局组件挂载
app.component('DictTag', DictTag)
app.component('Pagination', Pagination)

View File

@ -245,16 +245,16 @@
<el-col :span="8">
<div class="div-header">头像面</div>
<image-upload v-model="form.certificatePhoto1" :limit="1" class="identification-card-1"
@change="doImageUpload" />
@change="doImageUpload(1)" />
</el-col>
<el-col :span="8">
<div class="div-header">国徽面</div>
<image-upload v-model="form.certificatePhoto2" :limit="1" class="identification-card-2"
@change="doImageUpload" />
@change="doImageUpload(2)" />
</el-col>
<el-col :span="8">
<div class="div-header">人脸识别头像</div>
<image-upload v-model="form.faceImage" :limit="1" class="face-image" @change="doImageUpload" />
<image-upload v-model="form.faceImage" :limit="1" class="face-image" @change="doImageUpload(3)" />
</el-col>
</el-form-item>
</el-col>
@ -382,9 +382,48 @@ function handleBatchEnterState(state) {
}
//
function doImageUpload() {
function doImageUpload(type) {
setTimeout(() => {
let url='';
form.value.identificationCard = form.value.certificatePhoto1 && form.value.certificatePhoto2 && form.value.faceImage ? "yes" : ''
if(type==1){
url=form.value.certificatePhoto1;
if(url){
url=location.origin+url;
//url="http://62.234.3.186/statics/2025/01/19/4491f170cd1609142f9a6f097cbf681f_20250119000046A004.jpg"
proxy.$http.get(`/system/tools/id/front?url=${url}`).then(d=>{
form.value.userName=form.value.userName||d.data.name||'';
form.value.certificateCode=form.value.certificateCode||d.data.cardId||'';
form.value.address=form.value.address||d.data.address||'';
let nation=d.data.nation||"";
if(nation){
let tmps= data.nationOpts.filter(it=>it.indexOf(nation)>=0);
if(tmps.length>0){
form.value.nation=form.value.nation||tmps[0]||'';
}
}
let sex=d.data.sex||'';
if(sex){
form.value.sex=form.value.sex||(sex=='男'?0:1);
}
let birthDay=d.data.birthday;
if(birthDay && birthDay.length==8){
birthDay=birthDay.substr(0,4)+"-"+birthDay.substr(4,2)+"-"+birthDay.substr(6);
form.value.birthDay=form.value.birthDay||birthDay;
}
});
}
}else if(type==2){
url=form.value.certificatePhoto2;
if(url){
url=location.origin+url;
//url="https://gss0.baidu.com/9fo3dSag_xI4khGko9WTAnF6hhy/zhidao/pic/item/a8014c086e061d95103a068779f40ad162d9ca14.jpg"
proxy.$http.get(`/system/tools/id/back?url=${url}`).then(d=>{
form.value.nativePlace=form.value.nativePlace||d.data.issuing||'';
});
}
}
}, 800);
}