var a, e;
(a = getApp()),
  (e = getApp()),
  Page({
    data: {
      regdate: "",
      mileage: "",
      carName: "",
      cityName: "",
      cityid: 0,
      provid: 0,
      carId: 0,
      page: 1,
      type: 3,
    },
    mileageChanage: function (a) {
      this.setData({ mileage: a.detail.value });
    },
    queryVolation: function () {
      if (wx.getStorageSync("uid")) {
        var a = this;
        "" == a.data.carName
          ? wx.showToast({ title: "车型不能为空", icon: "none", duration: 2e3 })
          : "" == a.data.cityName
          ? wx.showToast({ title: "地区不能为空", icon: "none", duration: 2e3 })
          : "" == a.data.regdate
          ? wx.showToast({
              title: "上牌日期不能为空",
              icon: "none",
              duration: 2e3,
            })
          : "" == a.data.mileage
          ? wx.showToast({ title: "里程不能为空", icon: "none", duration: 2e3 })
          : (wx.showLoading({ title: "请求中" }), a.queryVinb());
      } else
        wx.showModal({
          title: "温馨提示",
          content: "请去个人中心授权登录用户信息",
          success: function (a) {
            a.confirm
              ? wx.reLaunch({ url: "/pages/mine/index" })
              : console.log("点击取消回调");
          },
        });
    },
    queryVinb: function () {
      "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("点击取消回调");
            },
          })
        : this.queryVin();
    },
    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",
              data: {
                m: "monai_market",
                type: "escgz_money",
                orderid: a.data.orderid,
                uid: wx.getStorageSync("uid"),
              },
              success: function (t) {
                t.data && t.data.data && 1e3 == t.data.message
                  ? e.util.request({
                      url: "entry/wxapp/Api",
                      data: {
                        m: "monai_market",
                        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.errno &&
                    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 (i) {
                        e.util.request({
                          url: "entry/wxapp/Api",
                          data: {
                            m: "monai_market",
                            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 (e) {
      var t = this,
        i = this.data,
        n = {
          cardata: t.data.cardata,
          uid: wx.getStorageSync("uid"),
          carName: i.carName,
          cityName: i.cityName,
          regdate: i.regdate,
          cityid: i.cityid,
          provid: i.provid,
          carId: i.carId,
          mileage: i.mileage,
          orderid: t.data.orderid,
        };
      a.getdata(n, "escgzapinew").then((a) => {
        console.log("回调数据：", a),
          a &&
            wx.navigateTo({
              url:
                "/packageA/pages/caresgznew/carpg/carpg?orderid=" +
                t.data.orderid,
            });
      });
    },
    toDetailExample: function () {
      wx.navigateTo({
        url: "../caresgznew/carpg/carpg?orderid=D165026490694147402592",
      });
    },
    toSelectCar: function () {
      wx.navigateTo({ url: "../caresgznew/selectCar/selectCar" });
    },
    toSelectCity: function () {
      wx.navigateTo({ url: "../caresgznew/selectCity/selectCity" });
    },
    toSelectTime: function () {
      wx.navigateTo({ url: "../caresgznew/selectTime/selectTime" });
    },
    onLoad: function (a) {
      wx.getStorageSync("uid") || getApp().wxlogin(),
        this.orderid(),
        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("carvehicle"),
        t = wx.getStorageSync("carprov"),
        i = wx.getStorageSync("carcity"),
        n = wx.getStorageSync("cartime"),
        o = "";
      "" != i && null != i && (o = t.name + "-" + i.name),
        console.log("" == e),
        "" != e &&
          "" != n &&
          parseInt(n.split("-")[0]) < parseInt(e.makeyear) &&
          (n = ""),
        this.setData({
          cardata: e,
          carName: e.fullname,
          cityName: o,
          regdate: n,
          cityid: i.id,
          provid: t.id,
          carId: e.id,
        }),
        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,
        i = { uid: wx.getStorageSync("uid"), type: t.data.type, page: e };
      a.getdata(i, "carqxcx").then((a) => {
        if ((console.log("回调数据：", a), a.data && 0 == a.errno))
          if (1 == e) t.setData({ repairList: a.data, page: t.data.page + 1 });
          else {
            var i = t.data.repairList;
            i.push.apply(i, a.data),
              t.setData({ repairList: i, 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/caresgznew/carpg/carpg?orderid=" + e,
        success: function () {},
      });
    },
  });
