"use strict";(self.webpackChunkmy_package_ext=self.webpackChunkmy_package_ext||[]).push([[6461],{46461:function(t,e,n){n.r(e),n.d(e,{default:function(){return a}});var o=n(57231),a=(e={name:"ocr",props:{value:{}},data:function(){return{access_token:"",configObj:null}},mounted:function(){this.configObj=localStorage.getItem("globalConfig")},methods:{transformBase64:function(t){return new Promise((function(e,n){var o=new FileReader;o.readAsDataURL(t),o.onload=function(t){e(t.target.result)}}))},getAccess_token:function(){var t=this;return new Promise((function(e,n){var a=(i=t.configObj&&t.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(t){e(t.data.access_token)}))}))},idCardIdentify:function(t){var e=this;return new Promise((function(n,a){var i=new FormData;i.append("image",t),i.append("id_card_side","front"),i.append("access_token",e.access_token),o.Z.post("/baiduApi/rest/2.0/ocr/v1/idcard?",i,{headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then((function(t){n(t.data.words_result)}))}))},changePictureUploadIDBack:function(t,e){var n=this;this.transformBase64(t.raw).then((function(t){n.getAccess_token().then((function(e){n.access_token=e,n.idCardIdentify(t).then((function(t){n.$emit("uploadSuccess",t),n.$emit("input",t["姓名"].words),console.log("ocr识别----",t)}))}))}))}}},(0,n(51900).Z)(e,(function(){var t=this,e=t._self._c;return e("div",{staticStyle:{width:"100%"}},[e("el-upload",t._b({staticClass:"upload-demo",attrs:{limit:1,action:"#","auto-upload":!1,"show-file-list":!1,"on-change":t.changePictureUploadIDBack}},"el-upload",t.$attrs,!1),[e("el-button",{attrs:{size:"small",icon:"el-icon-postcard",plain:""}},[t._v("识别证件")])],1)],1)}),[],!1,null,null,null).exports)},51900:function(t,e,n){function o(t,e,n,o,a,i,c,r){var s,d,u="function"==typeof t?t.options:t;return e&&(u.render=e,u.staticRenderFns=n,u._compiled=!0),o&&(u.functional=!0),i&&(u._scopeId="data-v-"+i),c?(s=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),a&&a.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(c)},u._ssrRegister=s):a&&(s=r?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(t,e){return s.call(e),d(t,e)}):(e=u.beforeCreate,u.beforeCreate=e?[].concat(e,s):[s])),{exports:t,options:u}}n.d(e,{Z:function(){return o}})}}]);