var t, e, o; (t = getApp()), (e = getApp()), (o = "https://aip.baidubce.com/rest/2.0/ocr/v1/driving_license"), Page({ data: { url: t.globalData.ceshiurl, src: "", src_01: "", leixing: 2, result_1: [], xuanze: "驾驶证识别", }, onLoad: function (t) { wx.getStorageSync("uid") || getApp().wxlogin(), t.type && this.setData({ typeapi: t.type }); try { wx.removeStorageSync("result_1"); } catch (t) {} this.setData({ src: "https://img.mp.itc.cn/q_70,c_zoom,w_640/upload/20160523/bf7ea2bbb3d948ed81e4a82350784791_th.jpg", }); }, onReady: function () {}, onShow: function () {}, onHide: function () {}, onUnload: function () {}, getad: function () { var t = this; e.ad().then((e) => { console.log("回调广告:", e), t.setData({ adunitId: e.adunitId, capingtId: e.capingtId, payId: e.payId, videoId: e.videoId, dyId: e.dyId, fxzq: e.fxzq, wxpay: e.wxpay, adopen: e.adopen, vadopen: e.vadopen, }); }); }, copyBtn: function () { var t = this; 1 == this.data.vadopen ? e.videoad(this.data.videoId, "看完视频广告复制~").then((e) => { console.log("回调广告:", e), 1 == e && t.copyBtnb(); }) : t.copyBtnb(); }, copyBtnb: function (t) { for (var e = this.data.result_1, a = [], o = 0, s = e.length; o < s; o++) a += e[o].words + "\n\n"; wx.setClipboardData({ data: a, success: function (t) { wx.showToast({ icon: "success", title: "复制成功", duration: 1500, success: function () {}, }); }, fail: function () { wx.showToast({ icon: "loading", title: "复制失败" }); }, }); }, shibie_1: function () { var t = this, s = this; 1 == t.data.leixing ? ((a = t.data.url), wx.chooseImage({ count: 1, sizeType: ["compressed"], sourceType: ["album", "camera"], success: function (a) { wx.showLoading({ title: "提取中.." }); var n = a.tempFilePaths[0], i = a.tempFilePaths[0], d = e.util.url("entry/wxapp/Wenzisb") + "&m=" + e.siteInfo.m + "&api=" + o + "&type=" + s.data.typeapi; wx.uploadFile({ url: d, filePath: n, name: "file", success: function (e) { wx.hideLoading(), console.log("上传参数b", e); var a = e.data, o = JSON.parse(a), n = JSON.parse(o.data); if ((console.log("上传参数", n), "87014" == n.errcode)) return ( wx.hideLoading(), void wx.showModal({ title: "温馨提示", content: "你上传的图片存在违规,请重新上传。", success: function (t) { t.confirm || console.log("点击取消回调"); }, }) ); s.setData({ src: i }), console.log("上传参数", n), console.log("传递参数", s.data.typeapi), "1" == s.data.typeapi && (wx.setStorageSync("jszimgurl", o.message), wx.setStorageSync("cardata", n.words_result), wx.navigateBack({ delta: 1 })), "2" == s.data.typeapi && (wx.setStorageSync("cardata", n.words_result), wx.navigateBack({ delta: 1 })), wx.hideLoading(), t.setData({ result_1: n.words_result, show: 1 }), 0 == n.words_result.length ? (wx.showLoading({ title: "不能识别!" }), setTimeout(function () { wx.hideLoading(); }, 2e3)) : wx.hideLoading(); }, fail: function () { console.log("错误"); }, }); }, })) : 2 == t.data.leixing && wx.chooseImage({ count: 1, sizeType: ["compressed"], sourceType: ["album", "camera"], success: function (a) { wx.showLoading({ title: "提取中.." }); var n = a.tempFilePaths[0], i = a.tempFilePaths[0], d = e.util.url("entry/wxapp/Wenzisb") + "&m=" + e.siteInfo.m + "&api=" + o + "&type=" + s.data.typeapi; wx.uploadFile({ url: d, filePath: n, name: "file", success: function (e) { wx.hideLoading(), console.log("上传参数b", e); var a = e.data, o = JSON.parse(a), n = JSON.parse(o.data); if ((console.log("上传参数", n), "87014" == n.errcode)) return ( wx.hideLoading(), void wx.showModal({ title: "温馨提示", content: "你上传的图片存在违规,请重新上传。", success: function (t) { t.confirm || console.log("点击取消回调"); }, }) ); s.setData({ src: i }), console.log("上传参数", n), console.log("传递参数", s.data.typeapi), "1" == s.data.typeapi && (wx.setStorageSync("jszimgurl", o.message), wx.setStorageSync("cardata", n.words_result), wx.navigateBack({ delta: 1 })), "2" == s.data.typeapi && (wx.setStorageSync("cardata", n.words_result), wx.navigateBack({ delta: 1 })), wx.hideLoading(), t.setData({ result_1: n.words_result, show: 1 }), 0 == n.words_result.length ? (wx.showLoading({ title: "不能识别!" }), setTimeout(function () { wx.hideLoading(); }, 2e3)) : wx.hideLoading(); }, fail: function () { console.log("错误"); }, }); }, }); }, deletewenzi: function (t) { var e = this, a = t.target.dataset.index; e.data.result_1, wx.showActionSheet({ itemList: ["复制"], success: function (o) { if ((console.log(a), console.log(o.tapIndex), 0 == o.tapIndex)) wx.setClipboardData({ data: t.target.dataset.words, success: function (t) { wx.showToast({ icon: "success", title: a + "复制成功", duration: 1500, success: function () {}, }); }, fail: function () { wx.showToast({ icon: "loading", title: "复制失败" }); }, }); else if ((console.log(o.tapIndex), 1 == o.tapIndex)) e.setData({ xianshi: "display:none", upstyle: "display:hidden", xiugai_idx: t.target.dataset.index, upwenzi: e.data.result_1[a].words, }); else if (2 == o.tapIndex) { delete e.data.result_1[a]; for (var s = [], n = 0; n < e.data.result_1.length; n++) null != e.data.result_1[n] && s.push(e.data.result_1[n]); try { wx.setStorageSync("result_1", s); } catch (t) {} e.onShow(); } }, fail: function (t) { console.log(t.errMsg); }, }); }, gohome: function () { wx.switchTab({ url: "/pages/picmake/index" }); }, onShareAppMessage: function (t) { return ( this.data.url, { title: "汽车驾驶证识别小工具!", imageUrl: "", path: "/packageA/pages/jszsb/jszsb", fail: function (t) { console.log("失败"); }, } ); }, });