!(function () {
  var e = getApp();
  !(function (e) {
    e && e.__esModule;
  })(require("../../utils/apis.js"));
  Page({
    data: {
      regdate: "",
      mileage: "",
      carName: "",
      cityName: "",
      cityid: 0,
      provid: 0,
      carId: 0,
      daben: "",
      page: 1,
      type: 8,
      index: 0,
      bdtype: ["交强险查询", "商业保险查询"],
      cxtype: "交强险查询",
    },
    mileageChanage: function (e) {
      this.setData({ mileage: e.detail.value });
    },
    bindPickerChange: function (e) {
      console.log("picker发送选择改变,携带值为", e.detail.value),
        this.setData({
          index: e.detail.value,
          cxtype: this.data.bdtype[e.detail.value],
        });
    },
    saoys: function (e) {
      wx.navigateTo({ url: "../xszsb/xszsb?type=1" });
    },
    daben: function (a) {
      var t = this;
      wx.chooseImage({
        count: 1,
        sizeType: ["compressed"],
        sourceType: ["album", "camera"],
        success: function (a) {
          var n =
            e.util.url("entry/wxapp/scqiniu") + "&m=monai_market&ids=daben";
          wx.uploadFile({
            url: n,
            filePath: a.tempFilePaths[0],
            name: "file",
            success: function (e) {
              var a = (a = (a = e.data).replace("\n", "")).replace("\r", "");
              console.log(a),
                t.setData({ daben: a }),
                wx.setStorageSync("daben", a);
            },
          });
        },
      });
    },
    daben1: function (a) {
      var t = this;
      wx.chooseImage({
        count: 1,
        sizeType: ["compressed"],
        sourceType: ["album", "camera"],
        success: function (a) {
          var n =
            e.util.url("entry/wxapp/scqiniu") + "&m=monai_market&ids=daben";
          wx.uploadFile({
            url: n,
            filePath: a.tempFilePaths[0],
            name: "file",
            success: function (e) {
              var a = (a = (a = e.data).replace("\n", "")).replace("\r", "");
              console.log(a),
                t.setData({ daben1: a }),
                wx.setStorageSync("daben1", a);
            },
          });
        },
      });
    },
    daben2: function (a) {
      var t = this;
      wx.chooseImage({
        count: 1,
        sizeType: ["compressed"],
        sourceType: ["album", "camera"],
        success: function (a) {
          var n =
            e.util.url("entry/wxapp/scqiniu") + "&m=monai_market&ids=daben";
          wx.uploadFile({
            url: n,
            filePath: a.tempFilePaths[0],
            name: "file",
            success: function (e) {
              var a = (a = (a = e.data).replace("\n", "")).replace("\r", "");
              console.log(a),
                t.setData({ daben2: a }),
                wx.setStorageSync("daben2", a);
            },
          });
        },
      });
    },
    daben3: function (a) {
      var t = this;
      wx.chooseImage({
        count: 1,
        sizeType: ["compressed"],
        sourceType: ["album", "camera"],
        success: function (a) {
          var n =
            e.util.url("entry/wxapp/scqiniu") + "&m=monai_market&ids=daben";
          wx.uploadFile({
            url: n,
            filePath: a.tempFilePaths[0],
            name: "file",
            success: function (e) {
              var a = (a = (a = e.data).replace("\n", "")).replace("\r", "");
              console.log(a),
                t.setData({ daben3: a }),
                wx.setStorageSync("daben3", a);
            },
          });
        },
      });
    },
    queryVolation: function () {
      if (wx.getStorageSync("uid")) {
        var a = this;
        if ((this.tongzhi(), a.data.mileage))
          if (17 == a.data.mileage.length)
            if ("iosb" == e.getSystemPlatform())
              wx.showModal({
                title: "温馨提示",
                content: "iOS不支持小程序,请使用公众号查询",
                success: function (e) {
                  e.confirm
                    ? wx.navigateTo({
                        url:
                          "/pages/website/website?url=https://mp.weixin.qq.com/s?__biz=MzIwOTYxMTI2Nw==&mid=2247483888&idx=1&sn=1f5deda3e1a2d5e109dfaf8000520030&chksm=97707e9ca007f78a7ade8b1b57eda40183c6de47a6a115836fdb77748fc248c320a29e3309c6&token=1742855998&lang=zh_CN#rd&img=" +
                          wx.getStorageSync("gzhurl"),
                      })
                    : console.log("点击取消回调");
                },
              });
            else if (a.data.imageUrl) {
              var t = this,
                n = { content: t.data.mileage + t.data.engine + t.data.chepai };
              e.getdata(n, "checkContent").then((e) => {
                console.log("文本回调数据:", e),
                  0 == e.errcode
                    ? a.queryVin()
                    : wx.showModal({
                        title: "温馨提示",
                        content:
                          "你输入的文本检测存在违规,请检测文本内容后重新输入。",
                        success: function (e) {
                          e.confirm || console.log("点击取消回调");
                        },
                      });
              });
            } else
              wx.showToast({
                title: "请上传行驶证,高级查询必须需要行驶证",
                icon: "none",
                duration: 2e3,
              });
          else
            wx.showToast({
              title: "车架号错误,请输入正确的车架号",
              icon: "none",
              duration: 2e3,
            });
        else
          wx.showToast({
            title: "车架号不能为空",
            icon: "none",
            duration: 2e3,
          });
      } else
        wx.showModal({
          title: "温馨提示",
          content: "请去个人中心授权登录用户信息",
          success: function (e) {
            e.confirm
              ? wx.reLaunch({ url: "/pages/mine/index" })
              : console.log("点击取消回调");
          },
        });
    },
    queryVin: function (a) {
      var t = this;
      wx.setStorageSync("cardatawx", {});
      var n = {
        vin: t.data.mileage,
        imageUrl: t.data.imageUrl,
        engine: t.data.engine,
        chepai: t.data.chepai,
        cxtype: t.data.cxtype,
      };
      wx.setStorageSync("cardatawx", n), console.log(t.data.daben);
      var o = { uid: wx.getStorageSync("uid"), vin: t.data.mileage };
      e.getdata(o, "vincxmf").then((e) => {
        if ((console.log("vin回调数据:", e.data), e.data)) {
          var a = JSON.parse(e.data);
          console.log(a.result),
            wx.setStorageSync("orderInfo", a.result),
            wx.navigateTo({ url: "../cardzbd/carInfo" });
        }
      });
    },
    tongzhi: function (a) {
      e.getdata({ type: "4" }, "getdyxx").then((a) => {
        console.log(a.data),
          wx.requestSubscribeMessage({
            tmplIds: [a.data],
            success(t) {
              "accept" == t[a.data]
                ? (wx.showToast({ title: "订阅成功" }),
                  e.util.request({
                    url: "entry/wxapp/addtemplateid",
                    data: { templateid: a.data, uid: wx.getStorageSync("uid") },
                    header: { "content-type": "application/json" },
                    success: function (e) {
                      console.log(e);
                    },
                  }))
                : wx.showToast({ title: "订阅失败" });
            },
          });
      });
    },
    toDetailExample: function () {
      wx.navigateTo({
        url: "../cardzbd/carcxjl?orderid=D164001170278907858681",
      });
    },
    toSelectCar: function () {
      wx.navigateTo({ url: "/pages/selectCar/selectCar" });
    },
    toSelectCity: function () {
      wx.navigateTo({ url: "/pages/selectCity/selectCity" });
    },
    toSelectTime: function () {
      wx.navigateTo({ url: "/pages/selectTime/selectTime" });
    },
    onLoad: function (e) {
      wx.getStorageSync("uid") || getApp().wxlogin(),
        wx.removeStorageSync("cardata"),
        wx.removeStorageSync("carvehicle"),
        wx.removeStorageSync("carprov"),
        wx.removeStorageSync("carcity"),
        wx.removeStorageSync("cartime"),
        wx.removeStorageSync("cardatawx"),
        wx.removeStorageSync("daben"),
        wx.removeStorageSync("daben1"),
        wx.removeStorageSync("daben2"),
        wx.removeStorageSync("daben3");
    },
    onReady: function () {},
    onShow: function () {
      e.appdengl();
      var a = wx.getStorageSync("cardata");
      console.log("行驶证数据", a),
        console.log("行驶证照片", wx.getStorageSync("xszimgurl")),
        a &&
          this.setData({
            mileage: a.车辆识别代号.words,
            engine: a.发动机号码.words,
            chepai: a.号牌号码.words,
            imageUrl: wx.getStorageSync("xszimgurl"),
          });
      var t = wx.getStorageSync("carvehicle"),
        n = wx.getStorageSync("carprov"),
        o = wx.getStorageSync("carcity"),
        i = wx.getStorageSync("cartime"),
        c = "";
      "" != o && null != o && (c = n.name + "-" + o.name),
        console.log("" == t),
        "" != t &&
          "" != i &&
          parseInt(i.split("-")[0]) < parseInt(t.makeyear) &&
          (i = ""),
        this.setData({
          carName: t.salesdesc,
          cityName: c,
          regdate: i,
          cityid: o.id,
          provid: n.id,
          carId: t.autohomeid,
        }),
        this.getDetail(1);
    },
    onPullDownRefresh: function () {
      this.clearCache(), this.getArticles(1);
    },
    onReachBottom: function () {
      console.log("加上"), this.getDetail(this.data.page);
    },
    clearCache: function () {
      this.setData({ repairList: [], page: 1 });
    },
    getDetail: function (a) {
      var t = this,
        n = { uid: wx.getStorageSync("uid"), type: t.data.type, page: a };
      e.getdata(n, "carqxcx").then((e) => {
        if ((console.log("回调数据:", e), e.data && 200 == e.code))
          if (1 == a) t.setData({ repairList: e.data, page: t.data.page + 1 });
          else {
            var n = t.data.repairList;
            n.push.apply(n, e.data),
              t.setData({ repairList: n, page: t.data.page + 1 });
          }
      });
    },
    showRenMsg: function () {
      wx.showToast({
        title: "人工查询中,请稍等",
        icon: "none",
        duration: 3e3,
      });
    },
    showGaoMsg: function () {
      wx.showToast({
        title: "查不到记录,建议使用高级出险查询。",
        icon: "none",
        duration: 3e3,
      });
    },
    getdzbdDetail: function (e) {
      var a = e.currentTarget.dataset.orderid;
      wx.navigateTo({
        url: "/packageA/pages/cardzbd/carcxjl?orderid=" + a,
        success: function () {},
      });
    },
    onHide: function () {},
    onUnload: function () {},
    onShareAppMessage: function () {},
  });
})();