Commit 0e981854 authored by Mac's avatar Mac

身份证验证

parent ffbcc2c0
......@@ -101,6 +101,31 @@
height: 97px;
}
.basicdata .input-style{
width: 100%;
height: 43px;
margin-top: 15px;
display: flex;
flex-direction: row;
align-items: center;
border-bottom: 1px solid #E2E2E2;
}
.basicdata .input-style-l{
width: 80px;
font-size: 14px;
color: #111111;
}
.basicdata .tjiao{
width: 100%;
height: 44px;
margin-top: 35px;
border-radius: 22px;
display: flex;
align-items: center;
justify-content: center;
font-size: 16px;
color: #FFFFFF;
}
</style>
<template>
<view class="basicdata">
......@@ -131,7 +156,7 @@
<text style="font-size: 13px;color: #888888;margin-left: 5px;">出生日期(年龄大于18岁)</text>
</view>
<view style="padding: 20px 0;">
<mypicker mode="time" :params="params" :end-year='endyear' @confirm='getTime'></mypicker>
<mypicker mode="time" :params="params" :end-year='endyear' @confirm='getTime' :default-time='addmsg.birth'></mypicker>
</view>
</view>
</view>
......@@ -162,7 +187,7 @@
<view style="padding: 0 15px;" v-if="step==3">
<view class="xueli_item" v-for="(x,y) in xuelist" :key='y' @click="addmsg.xueli= x.Id" :style="{'border':addmsg.xueli==x.Id?'1px solid '+mainColor:'none','box-shadow':addmsg.xueli==x.Id?'0 3px 8px 0px '+mainColor:'0'}">
<view class="xueli_item_l">
<image :src='xueilibg' style="width: 70px;height: 63px;position: absolute;left: 12px;bottom: 0;"></image>
<image src='https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/xueilibg.png' style="width: 70px;height: 63px;position: absolute;left: 12px;bottom: 0;"></image>
<image :src='x.img_y' v-if="addmsg.xueli==x.Id" style="width: 66px;height: 70px;margin-top: 5px;"></image>
<image :src='x.img_n' v-else style="width: 66px;height: 70px;margin-top: 5px;"></image>
</view>
......@@ -201,8 +226,8 @@
<view class="sfz-l-c">上传您的身份证头像面</view>
</view>
<view class="sfz-r" @click="upimg(1)">
<image :src="zfz_z" style="width: 100%;height: 100%;" v-if="addmsg.sfz_z==''"></image>
<image :src="addmsg.zfz_z" style="width: 100%;height: 100%;" v-else></image>
<image src="https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/sfz-z.png" style="width: 100%;height: 100%;" v-if="addmsg.sfz_z==''"></image>
<image :src="addmsg.sfz_z" style="width: 100%;height: 100%;" v-else></image>
</view>
</view>
<view class="sfz">
......@@ -211,10 +236,22 @@
<view class="sfz-l-c">上传您的身份证国徽面</view>
</view>
<view class="sfz-r" @click="upimg(2)">
<image :src="zfz_f" style="width: 100%;height: 100%;" v-if="addmsg.sfz_f==''"></image>
<image src="https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/sfz-f.png" style="width: 100%;height: 100%;" v-if="addmsg.sfz_f==''"></image>
<image :src="addmsg.sfz_f" style="width: 100%;height: 100%;" v-else></image>
</view>
</view>
<view style="font-size: 17px;color:#111111;font-weight: bold;margin-top: 20px;">请完善您的个人信息</view>
<view class="input-style">
<view class="input-style-l">姓名</view>
<input type="text" v-model="addmsg.name" style="width: 1px;flex: 1;border: none;" placeholder='请输入姓名'>
</view>
<view class="input-style">
<view class="input-style-l">身份证号</view>
<input type="idcard" v-model="addmsg.IDNo" style="width: 1px;flex: 1;border: none;" placeholder='请输入本人身份证号'>
</view>
<view class="tjiao" :style="{background:mainColor}">
提交
</view>
</view>
</view>
</template>
......@@ -234,16 +271,18 @@
pageTitle:'基础资料',
mainColor: '',
secondary: '',
step:5,
step:1,
addmsg:{
gender:1,//性别
birth:'1990-01-01',
birth:'1990-03-01',
weight:60,
height:160,
xueli:0,
marriage:0,
sfz_z:'',
sfz_f:'',
name:'',
IDNo:'',
},
endyear:'',
params: {
......@@ -272,9 +311,6 @@
{Id:2,name:'丧偶',img_n:'https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/shangou-n.png',img_y:'https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/shangou-y.png'},
],
xueilibg:'https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/xueilibg.png',
zfz_z:'https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/sfz-z.png',
zfz_f:'https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/sfz-f.png',
data:{},//百度的返回数据
}
},
......@@ -299,6 +335,11 @@
},
nextstep(){//下一步
this.step++
if(this.step==5){
uni.setNavigationBarTitle({
title: '实名认证',
});
}
},
scroll(val){//体重
this.addmsg.weight = val
......@@ -334,15 +375,134 @@
},
upimg(type){//身份证上传
var that = this;
cwx.OcrIdCard(that.data.access_token).then(function(_res){
var trdata = _res.data.words_result;
console.log(trdata)
// that.setData({
// name: trdata['姓名'].words,
// idcard: trdata['公民身份号码'].words,
// userloc: trdata['住址'].words
// })
})
uni.chooseImage({
count: 1, //默认9
sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
success: function (res) {
//核心代码 身份证识别
wx.getFileSystemManager().readFile({
filePath: res.tempFilePaths[0],
encoding: 'base64', //编码格式
success(ans) {
wx.showLoading({ title: '识别中' })
wx.request({
url: 'https://aip.baidubce.com/rest/2.0/ocr/v1/idcard?access_token=' + that.data.access_token,
method: 'POST',
header: {
'Content-Type': 'application/x-www-form-urlencoded'
},
data: {
image: ans.data,
id_card_side: 'front'
},
success(_res) {
wx.hideLoading();
console.log(_res.data)
if(_res.data.image_status=='normal' && type==1){//身份证为正面
that.upFile(res.tempFilePaths[0],type)
that.addmsg.name = _res.data.words_result['姓名'].words?_res.data.words_result['姓名'].words:'';
that.addmsg.IDNo = _res.data.words_result['公民身份号码'].words?_res.data.words_result['公民身份号码'].words:'';
}
if(_res.data.image_status=='reversed_side' && type==2){//身份证反面
that.upFile(res.tempFilePaths[0],type)
}
if(_res.data.image_status=='normal' && type==2){
wx.showToast({
title: '请上传反面身份证',
icon:'none'
})
}
if(_res.data.image_status=='reversed_side' && type==1){
wx.showToast({
title: '请上传正面身份证',
icon:'none'
})
}
if(_res.data.image_status=='non_idcard' ){
wx.showToast({
title: '上传的图片中不包含身份证',
icon:'none'
})
}
if(_res.data.image_status=='blurred' ){
wx.showToast({
title: '其他类型证照',
icon:'none'
})
}
if(_res.data.image_status=='other_type_card' ){
wx.showToast({
title: '身份证关键字段反光或过曝',
icon:'none'
})
}
if(_res.data.image_status=='over_exposure' ){
wx.showToast({
title: '身份证模糊',
icon:'none'
})
}
if(_res.data.image_status=='over_dark' ){
wx.showToast({
title: '身份证欠曝(亮度过低)',
icon:'none'
})
}
if(_res.data.image_status=='unknown' ){
wx.showToast({
title: '未知状态',
icon:'none'
})
}
}, fail(_res) {
wx.hideLoading();
wx.showToast({
title: '请求出错',
icon:'none'
})
console.log(_res)
}
})
}
})
}
});
},
upFile(img,type){
//图片上传
var that = this;
wx.showLoading({ title: '上传中' })
let MallBaseId = uni.getStorageSync("mall_UserInfo").MallBaseId ? uni.getStorageSync("mall_UserInfo").MallBaseId :1;
let action = that.host2 + '/api/File/UploadTencent?MallBaseId=' + MallBaseId
uni.uploadFile({
url: action,
filePath: img,
name: 'file',
formData: {
user: 'test'
},
success: (uploadFileRes) => {
uni.hideLoading()
if (uploadFileRes.statusCode == 200) {
let data = JSON.parse(uploadFileRes.data)
if(type==1){
that.addmsg.sfz_z = data.data
}else{
that.addmsg.sfz_f = data.data
}
}
},
fail: function(res) {
console.log(res)
wx.showToast({
title: '上传失败!',
icon: 'none',
duration: 1000
})
}
});
}
}
......
......@@ -186,7 +186,7 @@
// 默认显示的时间,2025-07-02 || 2025-07-02 13:01:00 || 2025/07/02
defaultTime: {
type: String,
default: ''
default: '1990-01-01'
},
// 默认显示的地区,可传类似["河北省", "秦皇岛市", "北戴河区"]
defaultRegion: {
......@@ -253,6 +253,7 @@
area: 0,
}
},
mounted() {
this.init();
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment