!(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,
      engine: "",
      imageUrl: "",
      chepai: "",
    },
    engineChanage: function (e) {
      this.setData({ engine: e.detail.value });
    },
    mileageChanage: function (e) {
      this.setData({ mileage: e.detail.value });
    },
    getad: function () {},
    queryVolation: function () {
      var a = this;
      this.tongzhi(),
        a.data.mileage
          ? 17 == a.data.mileage.length
            ? "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("点击取消回调");
                  },
                })
              : a.queryVin()
            : wx.showToast({
                title: "车架号错误，请输入正确的车架号",
                icon: "none",
                duration: 2e3,
              })
          : wx.showToast({
              title: "车架号不能为空",
              icon: "none",
              duration: 2e3,
            });
    },
    saoys: function (e) {
      wx.navigateTo({ url: "../xszsb/xszsb?type=1" });
    },
    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,
      };
      wx.setStorageSync("cardatawx", n);
      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: "../carwbjzb/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: "../carwbjzb/carwxjl?orderid=D163746409775526522433",
      });
    },
    toSelectCar: function () {
      wx.navigateTo({ url: "../carwbjzb/selectCar/selectCar" });
    },
    toSelectCity: function () {
      wx.navigateTo({ url: "../carwbjzb/selectCity/selectCity" });
    },
    toSelectTime: function () {
      wx.navigateTo({ url: "../carwbjzb/selectTime/selectTime" });
    },
    onLoad: function (e) {
      wx.getStorageSync("uid") || getApp().wxlogin(),
        this.getad(),
        wx.removeStorageSync("cardata"),
        wx.removeStorageSync("xszimgurl"),
        wx.removeStorageSync("carvehicle"),
        wx.removeStorageSync("carprov"),
        wx.removeStorageSync("carcity"),
        wx.removeStorageSync("cartime"),
        wx.removeStorageSync("cardatawx");
    },
    onReady: function () {},
    onShow: function () {
      var e = wx.getStorageSync("cardata");
      console.log("行驶证数据", e),
        console.log("行驶证照片", wx.getStorageSync("xszimgurl")),
        e &&
          this.setData({
            mileage: e.车辆识别代号.words,
            engine: e.发动机号码.words,
            chepai: e.号牌号码.words,
            imageUrl: wx.getStorageSync("xszimgurl"),
          });
      var a = wx.getStorageSync("carvehicle"),
        t = wx.getStorageSync("carprov"),
        n = wx.getStorageSync("carcity"),
        o = wx.getStorageSync("cartime"),
        i = "";
      "" != n && null != n && (i = t.name + "-" + n.name),
        console.log("" == a),
        "" != a &&
          "" != o &&
          parseInt(o.split("-")[0]) < parseInt(a.makeyear) &&
          (o = ""),
        this.setData({
          carName: a.salesdesc,
          cityName: i,
          regdate: o,
          cityid: n.id,
          provid: t.id,
          carId: a.autohomeid,
        });
    },
    onHide: function () {},
    onUnload: function () {},
    onPullDownRefresh: function () {},
    onReachBottom: function () {},
    onShareAppMessage: function () {},
  });
})();
