!(function () {
  var a = getApp(),
    e = getApp();
  !(function (a) {
    a && a.__esModule;
  })(require("../../utils/apis.js"));
  Page({
    data: {
      regdate: "",
      mileage: "",
      carName: "",
      cityName: "",
      cityid: 0,
      provid: 0,
      carId: 0,
      page: 1,
      type: 4,
    },
    mileageChanage: function (a) {
      this.setData({ mileage: a.detail.value });
    },
    saoys: function (a) {
      wx.navigateTo({ url: "../xszsb/xszsb?type=2" });
    },
    queryVolation: function () {
      if (wx.getStorageSync("uid")) {
        var e = this;
        this.tongzhi(),
          e.data.mileage
            ? 17 == e.data.mileage.length
              ? "iosb" == a.getSystemPlatform()
                ? wx.showModal({
                    title: "温馨提示",
                    content: "iOS不支持小程序，请使用公众号查询",
                    success: function (a) {
                      a.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("点击取消回调");
                    },
                  })
                : e.queryVin()
              : wx.showToast({
                  title: "车架号错误，请输入正确的车架号",
                  icon: "none",
                  duration: 2e3,
                })
            : wx.showToast({
                title: "车架号不能为空",
                icon: "none",
                duration: 2e3,
              });
      } else
        wx.showModal({
          title: "温馨提示",
          content: "请去个人中心授权登录用户信息",
          success: function (a) {
            a.confirm
              ? wx.reLaunch({ url: "/pages/mine/index" })
              : console.log("点击取消回调");
          },
        });
    },
    orderid: function () {
      let a = "";
      for (var e = 0; e < 8; e++) a += Math.floor(10 * Math.random());
      (a = "D" + new Date().getTime() + a), this.setData({ orderid: a });
    },
    queryVin: function () {
      var a = this;
      a.orderid(),
        console.log(wx.getStorageSync("uid")),
        wx.getStorageSync("uid")
          ? (console.log(wx.getStorageSync("uid")),
            e.util.request({
              url: "entry/wxapp/paynum",
              method: "post",
              dataType: "json",
              data: {

                type: "vin_money",
                orderid: a.data.orderid,
                uid: wx.getStorageSync("uid"),
                postcardata: JSON.stringify(a.data),
              },
              success: function (t) {
                t.data && t.data.data && 1e3 == t.data.message
                  ? e.util.request({
                      url: "entry/wxapp/Api",
                      data: {

                        uid: wx.getStorageSync("uid"),
                        r: "home.weizhang.paynum",
                        orderid: t.data.data.orderid,
                      },
                      success: function (e) {
                        wx.showModal({ content: e.data.message }),
                          a.setData({
                            weizhang_num: 1 * a.data.weizhang_num + 10,
                          }),
                          a.getDetailpay();
                      },
                    })
                  : t.data &&
                    t.data.data &&
                    t.data.code != 200&&
                    wx.requestPayment({
                      timeStamp: t.data.data.timeStamp,
                      nonceStr: t.data.data.nonceStr,
                      package: t.data.data.package,
                      signType: "MD5",
                      paySign: t.data.data.paySign,
                      success: function (n) {
                        e.util.request({
                          url: "entry/wxapp/Api",
                          data: {

                            uid: wx.getStorageSync("uid"),
                            r: "home.weizhang.paynum",
                            orderid: t.data.data.orderid,
                          },
                          success: function (e) {
                            a.setData({
                              weizhang_num: 1 * a.data.weizhang_num + 10,
                            }),
                              wx.showModal({ content: e.data.message }),
                              a.getDetailpay();
                          },
                        });
                      },
                    });
              },
            }))
          : wx.showModal({
              title: "温馨提醒",
              content: "使用本功能请先登录后在使用~",
              showCancel: !1,
              success: function (a) {
                a.confirm && wx.reLaunch({ url: "/pages/mine/index" });
              },
            });
    },
    getDetailpay: function () {
      var e = this,
        t = {
          uid: wx.getStorageSync("uid"),
          vin: e.data.mileage,
          orderid: e.data.orderid,
        };
      a.getdata(t, "vincx").then((a) => {
        wx.navigateTo({
          url: "/packageA/pages/carvin/carvin?orderid=" + e.data.orderid,
        }),
          console.log("vin回调数据：", a.data),
          a.data;
      });
    },
    tongzhi: function (e) {
      a.getdata({ type: "4" }, "getdyxx").then((e) => {
        console.log(e.data),
          wx.requestSubscribeMessage({
            tmplIds: [e.data],
            success(t) {
              "accept" == t[e.data]
                ? (wx.showToast({ title: "订阅成功" }),
                  a.util.request({
                    url: "entry/wxapp/addtemplateid",
                    data: { templateid: e.data, uid: wx.getStorageSync("uid") },
                    header: { "content-type": "application/json" },
                    success: function (a) {
                      console.log(a);
                    },
                  }))
                : wx.showToast({ title: "订阅失败" });
            },
          });
      });
    },
    toDetailExample: function () {
      wx.navigateTo({ url: "../carvin/carvin?orderid=D163750614515331518116" });
    },
    onLoad: function (a) {
      wx.getStorageSync("uid") || getApp().wxlogin(),
        this.orderid(),
        wx.removeStorageSync("cardata"),
        wx.removeStorageSync("carvehicle"),
        wx.removeStorageSync("carprov"),
        wx.removeStorageSync("carcity"),
        wx.removeStorageSync("cartime"),
        wx.removeStorageSync("cardatawx");
    },
    onReady: function () {},
    onShow: function () {
      a.appdengl();
      var e = wx.getStorageSync("cardata");
      console.log("行驶证数据", e),
        console.log("行驶证照片", wx.getStorageSync("xszimgurl")),
        e &&
          this.setData({
            mileage: e.车辆识别代号.words,
            engine: e.发动机号码.words,
          });
      var t = wx.getStorageSync("carvehicle"),
        n = wx.getStorageSync("carprov"),
        o = wx.getStorageSync("carcity"),
        i = wx.getStorageSync("cartime"),
        r = "";
      "" != o && null != o && (r = n.name + "-" + o.name),
        console.log("" == t),
        "" != t &&
          "" != i &&
          parseInt(i.split("-")[0]) < parseInt(t.makeyear) &&
          (i = ""),
        this.setData({
          carName: t.salesdesc,
          cityName: r,
          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 (e) {
      var t = this,
        n = { uid: wx.getStorageSync("uid"), type: t.data.type, page: e };
      a.getdata(n, "carqxcx").then((a) => {
        if ((console.log("回调数据：", a), a.data && 200 == a.code))
          if (1 == e) t.setData({ repairList: a.data, page: t.data.page + 1 });
          else {
            var n = t.data.repairList;
            n.push.apply(n, a.data),
              t.setData({ repairList: n, page: t.data.page + 1 });
          }
      });
    },
    onHide: function () {},
    onUnload: function () {},
    onShareAppMessage: function () {},
    showRenMsg: function () {
      wx.showToast({
        title: "人工查询中，请稍等",
        icon: "none",
        duration: 3e3,
      });
    },
    showGaoMsg: function () {
      wx.showToast({
        title: "查不到记录，建议使用高级出险查询。",
        icon: "none",
        duration: 3e3,
      });
    },
    getDangerDetail: function (a) {
      var e = a.currentTarget.dataset.orderid;
      wx.navigateTo({
        url: "/packageA/pages/carvin/carvin?orderid=" + e,
        success: function () {},
      });
    },
  });
})();
