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.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 () {
      var e = this,
        t = { content: e.data.mileage + e.data.engine + e.data.chepai };
      a.getdata(t, "checkContent").then((a) => {
        console.log("文本回调数据：", a),
          0 == a.errcode
            ? e.queryVinc()
            : wx.showModal({
                title: "温馨提示",
                content: "你输入的文本检测存在违规，请检测文本内容后重新输入。",
                success: function (a) {
                  a.confirm || console.log("点击取消回调");
                },
              });
      });
    },
    queryVinc: 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",
              method: "post",
              dataType: "json",
              data: {
                m: "monai_market",
                type: "escgz_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: {
                        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 (n) {
                        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 () {
      wx.showModal({
        title: "温馨提醒",
        content: "下单成功，点击确定后进入估值列表",
        showCancel: !1,
        success: function (a) {
          a.confirm &&
            wx.reLaunch({ url: "/pages/reporlist/reporlist?type=3" });
        },
      });
    },
    getDetailpayb: function (e) {
      var t = this,
        n = this.data,
        i = {
          cardata: t.data.cardata,
          uid: wx.getStorageSync("uid"),
          carName: n.carName,
          cityName: n.cityName,
          regdate: n.regdate,
          cityid: n.cityid,
          provid: n.provid,
          carId: n.carId,
          mileage: n.mileage,
          orderid: t.data.orderid,
        };
      a.getdata(i, "escgz").then((a) => {
        console.log("回调数据：", a),
          a &&
            wx.navigateTo({
              url:
                "/packageA/pages/caresgz/carpg/carpg?orderid=" + t.data.orderid,
            });
      });
    },
    toDetailExample: function () {
      wx.navigateTo({
        url: "../caresgz/carpg/carpg?orderid=D165026490694147402592",
      });
    },
    toSelectCar: function () {
      wx.navigateTo({ url: "../caresgz/selectCar/selectCar" });
    },
    toSelectCity: function () {
      wx.navigateTo({ url: "../caresgz/selectCity/selectCity" });
    },
    toSelectTime: function () {
      wx.navigateTo({ url: "../caresgz/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"),
        n = wx.getStorageSync("carcity"),
        i = wx.getStorageSync("cartime"),
        o = "";
      "" != n && null != n && (o = t.name + "-" + n.name),
        console.log("" == e),
        "" != e &&
          "" != i &&
          parseInt(i.split("-")[0]) < parseInt(e.makeyear) &&
          (i = ""),
        this.setData({
          cardata: e,
          carName: e.fullname,
          cityName: o,
          regdate: i,
          cityid: n.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,
        n = { uid: wx.getStorageSync("uid"), type: t.data.type, page: e };
      a.getdata(n, "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 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/caresgz/carpg/carpg?orderid=" + e,
        success: function () {},
      });
    },
  });
