"use strict";(self["webpackChunk"]=self["webpackChunk"]||[]).push([[206],{1206:function(e,t,a){a.r(t),a.d(t,{default:function(){return m}});var s=function(){var e=this,t=e._self._c;return t("div",{staticClass:"container"},[t("div",{staticClass:"header"},[e._v("请完成实名认证后进行使用")]),t("div",{staticClass:"content"},[t("div",{staticClass:"item",on:{click:e.selectCardType}},[e._m(0),t("div",{staticClass:"value"},[e._v(e._s(e.typeLabel))])]),t("div",{staticClass:"item-verify-side"},[e._m(1),t("div",{staticClass:"collect-box"},[t("el-image",{staticClass:"collect-box-image",attrs:{src:e.rightSideUrl||a(4269)}}),t("div",{staticClass:"collect-box-btn",on:{click:function(t){return e.toCollect("front")}}},[e._v("点击采集")])],1)]),t("div",{staticClass:"item-verify-side"},[e._m(2),t("div",{staticClass:"collect-box"},[t("el-image",{staticClass:"collect-box-image",attrs:{src:e.reverseSideUrl||a(1457)}}),t("div",{staticClass:"collect-box-btn",on:{click:function(t){return e.toCollect("back")}}},[e._v("点击采集")])],1)]),t("div",{staticClass:"collect-item"},[e._m(3),t("div",{class:"根据认证信息自动读取"===e.userIdcardInfo.name?"default":"value"},[e._v(e._s(e.userIdcardInfo.name))])]),t("div",{staticClass:"collect-item"},[e._m(4),t("div",{class:"根据认证信息自动读取"===e.userIdcardInfo.idCardNum?"default":"value"},[e._v(e._s(e.userIdcardInfo.idCardNum))])]),t("div",{staticClass:"collect-item"},[e._m(5),t("el-input",{staticClass:"phone",attrs:{placeholder:"请输入手机号"},model:{value:e.phone,callback:function(t){e.phone=t},expression:"phone"}})],1),t("div",{staticClass:"item",on:{click:e.faceCollection}},[e._m(6),t("div",{staticClass:"value",staticStyle:{color:"#6f737f"}},[e._v(e._s(e.faceCollectLabel))])]),t("div",{staticClass:"verify-btn",on:{click:e.toFace}},[e._v("提交核验")])]),t("el-drawer",{attrs:{title:"","with-header":!1,visible:e.cardTypeShow,direction:"btt","custom-class":"cardTypeStyle","before-close":e.handleClose},on:{"update:visible":function(t){e.cardTypeShow=t}}},[t("div",{staticClass:"camera-box"},e._l(e.cardTypeArr,(function(a){return t("div",{key:a.value,staticClass:"camera-box-item",on:{click:function(t){return e.takeIdCard(a)}}},[e._v(e._s(a.label))])})),0)]),t("input",{ref:"leftFile",staticClass:"hide_file",staticStyle:{display:"none"},attrs:{id:"upload",type:"file",accept:"image/*"},on:{change:function(t){return e.getFile(t)}}}),t("input",{ref:"faceFile",staticClass:"hide_file",staticStyle:{display:"none"},attrs:{id:"upload",type:"file",accept:"image/*",capture:"camera"},on:{change:function(t){return e.getFile(t)}}})],1)},i=[function(){var e=this,t=e._self._c;return t("div",{staticClass:"txt"},[t("span",[e._v("*")]),e._v("证件类型")])},function(){var e=this,t=e._self._c;return t("div",{staticClass:"txt"},[t("span",[e._v("*")]),e._v("身份证人面像")])},function(){var e=this,t=e._self._c;return t("div",{staticClass:"txt"},[t("span",[e._v("*")]),e._v("身份证国徽面")])},function(){var e=this,t=e._self._c;return t("div",{staticClass:"txt"},[t("span",[e._v("*")]),e._v("姓名")])},function(){var e=this,t=e._self._c;return t("div",{staticClass:"txt"},[t("span",[e._v("*")]),e._v("身份证号")])},function(){var e=this,t=e._self._c;return t("div",{staticClass:"txt"},[t("span",[e._v("*")]),e._v("手机号")])},function(){var e=this,t=e._self._c;return t("div",{staticClass:"txt"},[t("span",[e._v("*")]),e._v("人脸采集")])}],r=a(3261),o=a.n(r),n=a(2112),c=a(5139),l={name:"Face",data(){return{token:"",areaCode:"",credentialType:"",domainId:"",obsFilePath:"",faceCollectLabel:"未采集",videoWidth:640,videoHeight:480,typeLabel:"",idCardType:"",rightSideUrl:"",reverseSideUrl:"",drawer:!1,cardTypeShow:!1,userIdcardInfo:{name:"根据认证信息自动读取",idCardNum:"根据认证信息自动读取",address:"",validDateFrom:"",validDateTo:""},phone:"",cardTypeArr:[{label:"居民身份证(户口簿)",value:"IdCard"},{label:"香港特区护照/身份证明",value:"IdCardOfXiangGang"},{label:"澳门特区护照/身份证明",value:"IdCardOfAoMen"},{label:"台湾居民来往大陆通行证",value:"IdCardOfTaiwan"},{label:"外国人护照",value:"Passport"},{label:"警号",value:"PoliceNo"}],faceImage:"",isDev:!0,timer:null,headPhoto:""}},computed:{},mounted(){console.log("🚀 ~ mounted ~ this.$route.query:",this.$route.query);const{domainId:e,areaCode:t,isDev:a,token:s,headPhoto:i}=this.$route.query;if(this.domainId=e,this.areaCode=t,this.isDev=!1,localStorage.setItem("__isDev__",a),this.token=s,i&&"undefined"!==i)if(-1==i.indexOf("http")){const e=this.isDev?"https://v5qy.te.baibaodun.com.cn":"https://v5qy.baibaodun.cn";this.headPhoto=e+"/obpm"+i}else this.headPhoto=i},beforeDestroy(){},methods:{getFaceImage(){const{verify_token:e}=this.$route.query;e&&(clearInterval(this.timer),(0,c.TJ)({verify_token:e}).then((e=>{e.success&&(this.faceImage=e?.result?.image,uni.postMessage({data:{faceImage:e?.result?.image,msg:"身份核验成功"}}),o().miniProgram.postMessage({data:{faceImage:e?.result?.image,msg:"身份核验成功"}}))})))},faceCollection(){this.idCardType="face",this.handleClose(),this.$refs.faceFile.click()},takeIdCard(e){this.handleClose(),this.credentialType=e.value,this.typeLabel=e.label},selectCardType(){this.cardTypeShow=!0},toCollect(e){this.idCardType=e,this.takeFile()},handleClose(e){this.drawer=!1,this.cardTypeShow=!1},takeCamera(){this.handleClose();const e=document.getElementById("videoCamera"),t=document.getElementById("canvasCamera"),a=t.getContext("2d");a.drawImage(e,0,0,this.videoWidth,this.videoHeight),this.imgSrc=t.toDataURL("image/png")},takeFile(){this.handleClose(),this.$refs.leftFile.click()},async getHwLiveFace(e){try{const t=await(0,c.$A)(),a=(0,c.e)({image_url:e,attributes:"人脸属性"},{"X-Auth-Token":t["x-subject-token"]});console.log("facwRes: ",a)}catch{}},async getFile(e){let t=e.target.files[0];if("face"===this.idCardType){const e=await(0,n.UE)(t,this.domainId);this.obsFilePath=e,this.faceCollectLabel="已采集"}else{const e=this.$loading({lock:!0,text:"身份证识别中...",spinner:"el-icon-loading",background:"rgba(0, 0, 0, 0.7)",customClass:"createLoading"});try{const a=await(0,n.UE)(t,this.domainId);console.log("obsUrl: ",a);const s=await this.fileChange(t);e.close(),s?"front"===this.idCardType?this.frontPhoto=a:this.reversePhoto=a:this.$message.error("身份证识别失败,请重新上传清晰图片!")}catch{e.close()}}this.$refs.leftFile.value=""},uploadFileToV5(e){const t={filePath:e,name:"file"};(0,c.mv)(t).then((e=>{if(200==e.statusCode){let t=e.data&&JSON.parse(e.data);t.status}})).catch((e=>{}))},getWhitePortraitPhoto(e){return new Promise(((t,a)=>{(0,c.K9)({bStream:e}).then((e=>{if(console.log("base64位图片",e),200==e.status&&e.data&&e.data.indexOf("/uploads")>-1){let a,s;return this.isDev?(a=`https://v5qy.te.baibaodun.com.cn/obpm/${e.data}`,s=e.data):(a=e.data.replace("/uploads","https://02obs.baibaodun.cn"),s=e.data.replace("/uploads","https://02obs.baibaodun.cn")),t({file:s,fullFile:a})}this.$message.error("网络异常,请重试")})).catch((e=>{this.$message.error("身份证采集失败,请重试")}))}))},fileChange(e){return new Promise(((t,a)=>{const s=this,i=new FileReader;i.readAsDataURL(e),i.onload=function(e){const i=e.target.result,r=e.target.result.split(",")[1];(0,c.T$)({image:r,id_card_side:s.idCardType,detect_photo:!0}).then((async e=>{if("normal"===e.image_status){const{words_result:a,photo:r}=e;if("front"===s.idCardType)if(r)try{if(s.portrait="data:image/jpg;base64,"+r,!s.headPhoto){const{file:e,fullFile:t}=await s.getWhitePortraitPhoto(s.portrait);s.headPhoto=t,console.log("file, fullFile: ",e,t)}s.userIdcardInfo.name=a["姓名"].words,s.userIdcardInfo.idCardNum=a["公民身份号码"].words,s.userIdcardInfo.address=a["住址"].words,s.rightSideUrl=i,t(!0)}catch{t(!1)}else t(!1);else{t(!0);let e=a["失效日期"].words,r="";r=isNaN(e)?null:e.slice(0,4)+"-"+e.slice(4,6)+"-"+e.slice(-2);let o=a["签发日期"].words,n="";if(n=isNaN(o)?null:o.slice(0,4)+"-"+o.slice(4,6)+"-"+o.slice(-2),r){let e=new Date(r).getTime(),t=(new Date).getTime();t>e&&s.$message.error("该证件已过期,请证件补办后再提交核验!")}s.userIdcardInfo.validDateFrom=n,s.userIdcardInfo.validDateTo=r,s.reverseSideUrl=i}}else s.$message.error("身份证识别失败,请重新上传清晰图片!"),a()})).catch((e=>{a(e)}))}}))},matchFace(){return new Promise(((e,t)=>{const a={oneImg:this.headPhoto,twoImg:this.obsFilePath};console.log("params:-人脸比对参数 ",a);const s=this.isDev?"https://identify.test.bcxin.com.cn":"https://identify.qiye.baibaodun.com.cn:14433";(0,c.nl)(a,s).then((t=>{if(console.log("🚀 ~ matchFaceApi ~ res:",t),0==t.retType){let a=t.data.result;if(1==a)return e(!0)}e(!1)})).catch((e=>{console.log("🚀 ~ matchFaceApi ~ err:",e),t(!1)}))}))},async toFace(){if(!this.typeLabel)return this.$message.error("请选择证件类型");if(!this.rightSideUrl)return this.$message.error("请先采集身份证人面像");if(!this.userIdcardInfo.address)return this.$message.error("身份证人面信息识别失败,请重新上传");if(!this.userIdcardInfo.validDateFrom)return this.$message.error("请先采集身份证国徽面");if("未采集"===this.faceCollectLabel)return this.$message.error("请先采集人脸信息");if(!this.phone)return this.$message.error("请输入手机号");if(!/^[1][3,4,5,7,8,9][0-9]{9}$/.test(this.phone))return this.$message.error("请输入正确的手机号");const e=await this.matchFace();if(!e)return this.$message.error("人脸比对失败");const t={address:this.userIdcardInfo.address,areaCode:this.areaCode,certificateImage:this.obsFilePath,credentialType:this.credentialType,loginFrom:"BBD",name:this.userIdcardInfo.name,number:this.userIdcardInfo.idCardNum,phone:this.phone,frontPhoto:this.frontPhoto,headPhoto:this.headPhoto,reversePhoto:this.reversePhoto,validDateFrom:this.userIdcardInfo.validDateFrom,validDateTo:this.userIdcardInfo.validDateTo},a={Authorization:"Bearer "+this.token};(0,c.tb)(t,a).then((e=>{console.log("🚀 ~ confirmCheckStatus ~ res:",e),this.$message.success("核验成功"),o().miniProgram.postMessage({data:{msg:"身份核验成功",cgiToken:e.data.cgiToken,token:e.data.token}}),o().miniProgram.navigateBack()})).catch((e=>{}))}}},d=l,u=a(1656),h=(0,u.A)(d,s,i,!1,null,"e7ab46f4",null),m=h.exports},5139:function(e,t,a){a.d(t,{tb:function(){return v},T$:function(){return u},TJ:function(){return d},Em:function(){return h},$A:function(){return b},e:function(){return y},nl:function(){return g},Uw:function(){return m},K9:function(){return f},mv:function(){return p}});var s=a(417),i=a(4927);const r=s.A.create({baseURL:window.location.origin,timeout:5e4,headers:{"Content-Type":"application/json"}});r.interceptors.request.use((e=>{if(!e.url.includes("/api/v2/recogInvoive.do")){const t=localStorage.getItem("accessToken");t&&(e.headers.accessToken=t)}return e}),(e=>Promise.reject(e))),r.interceptors.response.use((e=>{let t=e.data;return e.headers["x-subject-token"]&&(t={...e.data,"x-subject-token":e.headers["x-subject-token"]}),t.code&&0!==t.code?401!==t.code?t:void(window.location.href="/"):t}),(e=>(-1!=e.message.indexOf("timeout")?i.Message.error("网络超时"):"Network Error"==e.message?i.Message.error("网络连接错误"):e.response.data?i.Message.error(e.response.data.message||e.response.statusText):i.Message.error("接口路径找不到"),Promise.reject(e))));var o=r;const n="OAnbVZhEuY5UNB9WbDeqstbj",c="1mMtAGw9ZgoblmNpTrk0SQFikFHFVsbh",l=()=>{let e={method:"POST",url:`/bdapi/oauth/2.0/token?client_id=${n}&client_secret=${c}&grant_type=client_credentials`,headers:{"Content-Type":"application/x-www-form-urlencoded"}};return new Promise(((t,a)=>{o(e).then((e=>{t(e.access_token)})).catch((e=>{a(e)}))}))},d=async(e={})=>o({url:"/bdapi/rpc/2.0/brain/solution/faceprint/result/simple?access_token="+await l(),method:"post",headers:{"Content-Type":"application/json",Accept:"application/json"},data:e}),u=async(e={})=>o({url:"/bdapi/rest/2.0/ocr/v1/idcard?access_token="+await l(),method:"post",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},data:e}),h=async(e={})=>o({url:"https://netocr.com/api/v2/recogInvoive.do",method:"post",headers:{"Content-Type":"multipart/form-data"},data:e}),m=async(e={})=>o({url:"/obpm/magic-api/tax/payment",method:"post",data:e}),p=async(e={})=>o({url:"/v5api/v3/shared/common/resources",method:"post",data:e}),f=async(e={})=>o({url:"/v5api/v3/shared/common/resources/base64",method:"post",data:e}),v=async(e={},t)=>o({url:"/v5api/v3/wechat/cgi-bin/confirm-check-status",method:"post",data:e,headers:t});function g(e,t){return o(`${t}/identify/api/baidu/match-face`,{method:"post",headers:{"Content-Type":"application/x-www-form-urlencoded"},data:{bizFaceMode:"UNIAPP",vtp:70,appointChannel:"UNIAPP",...e}})}const b=async()=>o({url:"/hwapi/v3/auth/tokens",method:"post",headers:{"Content-Type":"application/json",Accept:"application/json"},data:{auth:{identity:{methods:["password"],password:{user:{name:"bcxin_yw",password:"Bcxin#202103#5186",domain:{name:"bcxin_yw"}}}},scope:{project:{name:"cn-north-4"}}}}}),y=async(e,t)=>o({url:"/hwfaceapi/v2/967cb11fa5304894816463bde95c8a78/face-detect",method:"post",headers:{...t},data:e})},2313:function(e,t,a){a.d(t,{J:function(){return i},R:function(){return s}});let s={};s="true"==localStorage.getItem("__isDev__")?{ak:"YYSIHHGD8VTNTQVA2NCB",sk:"fd3My9hE8N7Byl4SJ8Mx0kKcn7gvaZoh506WGC0y",urlserver:"obs.cn-north-1.myhuaweicloud.com",BucketName:"bcxin-saas-test",CDN_POINT:"https://bcxinsaasprod.baibaodun.cn"}:{ak:"YYSIHHGD8VTNTQVA2NCB",sk:"fd3My9hE8N7Byl4SJ8Mx0kKcn7gvaZoh506WGC0y",urlserver:"obs.cn-north-1.myhuaweicloud.com",BucketName:"bcxin-saas-prod",CDN_POINT:"https://bcxinsaasprod.baibaodun.cn"};const i={key:"Es1TRT94hJsvSttv9GLhy4",secret:"19d6be2e3e164f98a1b7d1321a73189c"}},2112:function(e,t,a){a.d(t,{UE:function(){return r},u9:function(){return i}});var s=a(2313);const i=e=>{let t,a,s,i=new Array("零","壹","贰","叁","肆","伍","陆","柒","捌","玖"),r=new Array("","拾","佰","仟"),o=new Array("","万","亿","兆"),n=new Array("角","分","毫","厘"),c="整",l="元",d=1e15,u="";if(""==e)return"";if(e=parseFloat(e),e>=d)return"";if(0==e)return u=i[0]+l+c,u;if(e=e.toString(),-1==e.indexOf(".")?(t=e,a=""):(s=e.split("."),t=s[0],a=s[1].substr(0,4)),parseInt(t,10)>0){let e=0,a=t.length;for(let s=0;s0&&(u+=i[0]),e=0,u+=i[parseInt(n)]+r[d]),0==d&&e<4&&(u+=o[l])}u+=l}if(""!=a){let e=a.length;for(let t=0;tnew Promise(((a,i)=>{const r=new Date,o=r.getFullYear(),n=r.getMonth()+1<10?"0"+(r.getMonth()+1):r.getMonth()+1,c=r.getDate()<10?"0"+r.getDate():r.getDate(),l=n+"-"+c,d=`uploads/${o}/${l}/${t}/${r.getTime()}/${e.name}`,u=new ObsClient({access_key_id:s.R.ak,secret_access_key:s.R.sk,server:s.R.urlserver,timeout:300});u.putObject({Bucket:s.R.BucketName,Key:d,SourceFile:e}).then((function(e){if(e.CommonMsg.Status<300){const e=`https://${s.R.BucketName}.${s.R.urlserver}/${d}`;a(e)}else i(!1)})).catch((()=>{i(!1)}))}))},1457:function(e,t,a){e.exports=a.p+"img/icon-reverse-side.7211ca55.png"},4269:function(e,t,a){e.exports=a.p+"img/icon-right-side.934d077d.png"}}]); //# sourceMappingURL=206.946ce6c2.js.map