var e, t, o;
(e = getApp()),
  (t = getApp()),
  (o = "https://aip.baidubce.com/rest/2.0/ocr/v1/license_plate"),
  Page({
    data: {
      url: e.globalData.ceshiurl,
      src: "",
      src_01: "",
      leixing: 2,
      result_1: [],
      xuanze: "车牌号识别",
    },
    onLoad: function (a) {
      a.type && this.setData({ typeapi: a.type });
      try {
        wx.removeStorageSync("result_1");
      } catch (a) {}
      this.setData({
        src: "https://pic.ym23.com/uploads/20221114/FqZ-rcL-1r4HucIDc4CrSoRVZGY2.png",
      }),
        this.getad();
    },
    onReady: function () {},
    onShow: function () {},
    onHide: function () {},
    onUnload: function () {},
    getad: function () {
      var a = this;
      t.ad().then((e) => {
        console.log("回调广告：", e),
          a.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 a = this;
      1 == this.data.vadopen
        ? t.videoad(this.data.videoId, "看完视频广告复制~").then((e) => {
            console.log("回调广告：", e), 1 == e && a.copyBtnb();
          })
        : a.copyBtnb();
    },
    copyBtnb: function (e) {
      console.log(e),
        wx.setClipboardData({
          data: a,
          success: function (a) {
            wx.showToast({
              icon: "success",
              title: "复制成功",
              duration: 1500,
              success: function () {},
            });
          },
          fail: function () {
            wx.showToast({ icon: "loading", title: "复制失败" });
          },
        });
    },
    shibie_1: function () {
      var e = this,
        s = 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 i = a.tempFilePaths[0],
                n = a.tempFilePaths[0],
                c =
                  t.util.url("entry/wxapp/Wenzisb") +
                  "&m=" +
                  t.siteInfo.m +
                  "&api=" +
                  o +
                  "&type=" +
                  s.data.typeapi;
              wx.uploadFile({
                url: c,
                filePath: i,
                name: "file",
                success: function (a) {
                  wx.hideLoading(), console.log("上传参数b", a);
                  var t = a.data,
                    o = JSON.parse(t),
                    i = JSON.parse(o.data);
                  if ((console.log("上传参数", i), "87014" == i.errcode))
                    return (
                      wx.hideLoading(),
                      void wx.showModal({
                        title: "温馨提示",
                        content: "你上传的图片存在违规，请重新上传。",
                        success: function (a) {
                          a.confirm || console.log("点击取消回调");
                        },
                      })
                    );
                  s.setData({ src: n }),
                    console.log("上传参数", i),
                    console.log("传递参数", s.data.typeapi),
                    "1" == s.data.typeapi &&
                      (wx.setStorageSync("jszimgurl", o.message),
                      wx.setStorageSync("cardata", i.words_result),
                      wx.navigateBack({ delta: 1 })),
                    "2" == s.data.typeapi &&
                      (wx.setStorageSync("cardata", i.words_result),
                      wx.navigateBack({ delta: 1 })),
                    wx.hideLoading(),
                    e.setData({ result_1: i.words_result, show: 1 }),
                    0 == i.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 i = a.tempFilePaths[0],
                n = a.tempFilePaths[0],
                c =
                  t.util.url("entry/wxapp/Wenzisb") +
                  "&m=" +
                  t.siteInfo.m +
                  "&api=" +
                  o +
                  "&type=" +
                  s.data.typeapi;
              wx.uploadFile({
                url: c,
                filePath: i,
                name: "file",
                success: function (a) {
                  wx.hideLoading(), console.log("上传参数b", a);
                  var t = a.data,
                    o = JSON.parse(t),
                    i = JSON.parse(o.data);
                  if ((console.log("上传参数", i), "87014" == i.errcode))
                    return (
                      wx.hideLoading(),
                      void wx.showModal({
                        title: "温馨提示",
                        content: "你上传的图片存在违规，请重新上传。",
                        success: function (a) {
                          a.confirm || console.log("点击取消回调");
                        },
                      })
                    );
                  s.setData({ src: n }),
                    console.log("上传参数", i),
                    console.log("传递参数", s.data.typeapi),
                    "1" == s.data.typeapi &&
                      (wx.setStorageSync("jszimgurl", o.message),
                      wx.setStorageSync("cardata", i.words_result),
                      wx.navigateBack({ delta: 1 })),
                    "2" == s.data.typeapi &&
                      (wx.setStorageSync("cardata", i.words_result),
                      wx.navigateBack({ delta: 1 })),
                    wx.hideLoading(),
                    e.setData({ result_1: i.words_result, show: 1 }),
                    0 == i.words_result.length
                      ? (wx.showLoading({ title: "不能识别！" }),
                        setTimeout(function () {
                          wx.hideLoading();
                        }, 2e3))
                      : wx.hideLoading();
                },
                fail: function () {
                  console.log("错误");
                },
              });
            },
          });
    },
    deletewenzi: function (a) {
      console.log(a);
      var e = a.target.dataset.words;
      wx.setClipboardData({
        data: e,
        success: function (a) {
          wx.showToast({
            icon: "success",
            title: e + "复制成功",
            duration: 1500,
            success: function () {},
          });
        },
        fail: function () {
          wx.showToast({ icon: "loading", title: "复制失败" });
        },
      });
    },
    gohome: function () {
      wx.switchTab({ url: "/pages/picmake/index" });
    },
    onShareAppMessage: function (a) {
      return (
        this.data.url,
        {
          title: "汽车车牌识别小工具！",
          imageUrl: "",
          path: "/packageA/pages/cphsb/cphsb",
          fail: function (a) {
            console.log("失败");
          },
        }
      );
    },
  });
