"use strict";(self.webpackChunkmy_package_ext=self.webpackChunkmy_package_ext||[]).push([[3210],{3210:function(e,t,n){n.r(t),n.d(t,{default:function(){return a}});var o=n(57231),a=(t={name:"ocr",props:{value:{}},data:function(){return{access_token:"",configObj:null}},mounted:function(){this.configObj=localStorage.getItem("globalConfig")},methods:{transformBase64:function(e){return new Promise((function(t,n){var o=new FileReader;o.readAsDataURL(e),o.onload=function(e){t(e.target.result)}}))},getAccess_token:function(){var e=this;return new Promise((function(t,n){var a=(i=e.configObj&&e.configObj.baiduApi||{}).client_id,i=void 0===(i=i.client_secret)?"QeVc3e9vIZDwSq6pGDkv0MDHG294iXm0":i;o.Z.post("/baiduApi/oauth/2.0/token?grant_type=client_credentials&client_id=".concat(void 0===a?"KcUawwp9rmCZk0QRelaGMWqO":a,"&client_secret=").concat(i),{headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then((function(e){t(e.data.access_token)}))}))},idCardIdentify:function(e){var t=this;return new Promise((function(n,a){var i=new FormData;i.append("image",e),i.append("id_card_side","back"),i.append("access_token",t.access_token),o.Z.post("/baiduApi/rest/2.0/ocr/v1/idcard?",i,{headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then((function(e){n(e.data.words_result)}))}))},afterRead:function(e){var t=this;this.transformBase64(e.file).then((function(e){t.getAccess_token().then((function(n){t.access_token=n,t.idCardIdentify(e).then((function(e){t.$emit("uploadSuccess",e),t.$emit("input",e["姓名"].words),console.log("ocr识别----",e)}))}))}))}}},(0,n(51900).Z)(t,(function(){var e=this,t=e._self._c;return t("div",{staticStyle:{display:"flex",width:"100%"}},[t("van-uploader",{attrs:{"after-read":e.afterRead}},[t("van-button",{attrs:{size:"small",icon:"el-icon-upload",type:"primary"}},[e._v("证件识别")])],1)],1)}),[],!1,null,"418d7cb5",null).exports)},51900:function(e,t,n){function o(e,t,n,o,a,i,r,c){var s,d,u="function"==typeof e?e.options:e;return t&&(u.render=t,u.staticRenderFns=n,u._compiled=!0),o&&(u.functional=!0),i&&(u._scopeId="data-v-"+i),r?(s=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),a&&a.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(r)},u._ssrRegister=s):a&&(s=c?function(){a.call(this,(u.functional?this.parent:this).$root.$options.shadowRoot)}:a),s&&(u.functional?(u._injectStyles=s,d=u.render,u.render=function(e,t){return s.call(t),d(e,t)}):(t=u.beforeCreate,u.beforeCreate=t?[].concat(t,s):[s])),{exports:e,options:u}}n.d(t,{Z:function(){return o}})}}]);