var e, t, s; (e = getApp()), (t = getApp()), (s = "https://aip.baidubce.com/rest/2.0/ocr/v1/vehicle_license"), Page({ data: { url: e.globalData.ceshiurl, src: "", src_01: "", leixing: 2, result_1: [], xuanze: "行驶证识别", }, onLoad: function (e) { e.type && this.setData({ typeapi: e.type }), e.name && this.setData({ name: e.name }); try { wx.removeStorageSync("result_1"); } catch (e) {} this.setData({ src: "https://api.ym23.com/addons/monai_market/static/images/car/xsz_example.jpg", }), this.getad(); }, onReady: function () {}, onShow: function () {}, onHide: function () {}, onUnload: function () {}, getad: function () {}, copyBtn: function () { var e = this; 1 == this.data.vadopen ? t.videoad(this.data.videoId, "看完视频广告复制~").then((t) => { console.log("回调广告:", t), 1 == t && e.copyBtnb(); }) : e.copyBtnb(); }, copyBtnb: function (e) { for (var t = this.data.result_1, a = [], s = 0, o = t.length; s < o; s++) a += t[s].words + "\n\n"; wx.setClipboardData({ data: a, success: function (e) { wx.showToast({ icon: "success", title: "复制成功", duration: 1500, success: function () {}, }); }, fail: function () { wx.showToast({ icon: "loading", title: "复制失败" }); }, }); }, shibie_1: function () { var e = this, o = this; 1 == e.data.leixing ? ((a = e.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], c = t.util.url("entry/wxapp/Wenzisb") + "&m=" + t.siteInfo.m + "&api=" + s + "&type=" + o.data.typeapi; wx.uploadFile({ url: c, filePath: n, name: "file", success: function (t) { wx.hideLoading(), console.log("上传参数b", t); var a = t.data, s = JSON.parse(a), n = JSON.parse(s.data); if ((console.log("上传参数", n), "87014" == n.errcode)) return ( wx.hideLoading(), void wx.showModal({ title: "温馨提示", content: "你上传的图片存在违规,请重新上传。", success: function (e) { e.confirm || console.log("点击取消回调"); }, }) ); o.setData({ src: i }), "1" == o.data.typeapi && (wx.setStorageSync("xszimgurl", s.message), wx.setStorageSync("cardata", n.words_result), wx.navigateBack({ delta: 1 })), "2" == o.data.typeapi && (wx.setStorageSync("cardata", n.words_result), wx.navigateBack({ delta: 1 })), wx.hideLoading(), e.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 == e.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], c = t.util.url("entry/wxapp/Wenzisb") + "&m=" + t.siteInfo.m + "&api=" + s + "&type=" + o.data.typeapi; wx.uploadFile({ url: c, filePath: n, name: "file", success: function (t) { wx.hideLoading(), console.log("上传参数b", t); var a = t.data, s = JSON.parse(a), n = JSON.parse(s.data); if ((console.log("上传参数", n), "87014" == n.errcode)) return ( wx.hideLoading(), void wx.showModal({ title: "温馨提示", content: "你上传的图片存在违规,请重新上传。", success: function (e) { e.confirm || console.log("点击取消回调"); }, }) ); o.setData({ src: i }), console.log("传递参数", o.data.typeapi), "1" == o.data.typeapi && (wx.setStorageSync("xszimgurl", s.message), wx.setStorageSync("keyname", o.data.name), wx.setStorageSync("cardata", n.words_result), wx.navigateBack({ delta: 1 })), "2" == o.data.typeapi && (wx.setStorageSync("cardata", n.words_result), wx.setStorageSync("keyname", o.data.name), wx.navigateBack({ delta: 1 })), wx.hideLoading(), e.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 (e) { var t = this, a = e.target.dataset.index; t.data.result_1, wx.showActionSheet({ itemList: ["复制"], success: function (s) { if ((console.log(a), console.log(s.tapIndex), 0 == s.tapIndex)) wx.setClipboardData({ data: e.target.dataset.words, success: function (e) { wx.showToast({ icon: "success", title: a + "复制成功", duration: 1500, success: function () {}, }); }, fail: function () { wx.showToast({ icon: "loading", title: "复制失败" }); }, }); else if ((console.log(s.tapIndex), 1 == s.tapIndex)) t.setData({ xianshi: "display:none", upstyle: "display:hidden", xiugai_idx: e.target.dataset.index, upwenzi: t.data.result_1[a].words, }); else if (2 == s.tapIndex) { delete t.data.result_1[a]; for (var o = [], n = 0; n < t.data.result_1.length; n++) null != t.data.result_1[n] && o.push(t.data.result_1[n]); try { wx.setStorageSync("result_1", o); } catch (e) {} t.onShow(); } }, fail: function (e) { console.log(e.errMsg); }, }); }, gohome: function () { wx.switchTab({ url: "/pages/picmake/index" }); }, onShareAppMessage: function (e) { return ( this.data.url, { title: "汽车行驶证识别小工具!", imageUrl: "", path: "/packageA/pages/xszsb/xszsb", fail: function (e) { console.log("失败"); }, } ); }, });