!(function () {
  var e = getApp();
  !(function (e) {
    e && e.__esModule;
  })(require("../../utils/apis.js"));
  Page({
    change: function (e) {
      var t = this.data.query,
        a = e.detail.value,
        c = this.trim(a);
      (t.license_plate = c), this.setData({ query: t });
    },
    trim: function (e) {
      return (e = (e = e.replace(/\s+/gi, "")).replace(
        /\W+/,
        ""
      )).toUpperCase();
    },
    selectResult: function (e, t, a) {
      if (a)
        switch (a) {
          case 1:
            1 == t
              ? this.setData({ "query.license_plate_code": e.title })
              : this.setData({ "query.province_small": e.province_small });
            break;
          case 2:
            this.setData({
              "query.license_plate_type": e.id,
              license_plate_type: e.title,
            });
            break;
          case 3:
            this.setData({ "query.hot_type": e.id, hot_type: e.title });
        }
    },
    isGDCar: function (e) {
      var t = this.data,
        a = t.pickerArray,
        c = t.letter;
      try {
        -1 != a[0][e].province_small.indexOf("粤")
          ? (c = c.filter(function (e) {
              return "X" != e.title && "Y" != e.title;
            }))
          : "Y" != c[c.length - 1].title &&
            (c = c.concat([
              { checked: !1, title: "X" },
              { checked: !1, title: "Y" },
            ]));
      } catch (e) {
        "Y" != c[c.length - 1].title &&
          (c = c.concat([
            { checked: !1, title: "X" },
            { checked: !1, title: "Y" },
          ]));
      }
      (a[1] = c), this.setData({ letter: c, pickerArray: a });
    },
    onChange: function (e) {
      var t = e.detail.value[0];
      1 == this.data.typeName.num && this.isGDCar(t),
        this.setData({ piclerNum: e.detail.value });
    },
    onengine: function (e) {
      this.setData({ "query.engine": e.detail.value });
    },
    onvin: function (e) {
      this.setData({ "query.vin": e.detail.value });
    },
    openPick: function (e) {
      var t = this,
        a = this.data,
        c = a.carHeadList,
        i = a.letter,
        d = a.carKind,
        l = a.rules,
        n = a.piclerNum,
        r = a.typeName;
      if (e.currentTarget.dataset.index) {
        var o,
          s = parseInt(e.currentTarget.dataset.index);
        switch (((o = 4 == s ? this.data.pickerArray : []), s)) {
          case 1:
            (r.title = "选择车牌前缀"), (r.num = s), o.push(c), o.push(i);
            break;
          case 2:
            (r.title = "选择车牌种类"), (r.num = s), o.push(d);
            break;
          case 3:
            (r.title = "选择查找规则"), (r.num = s), o.push(l);
            break;
          case 4:
            o.forEach(function (e) {
              e.forEach(function (e) {
                e.checked = !1;
              });
            }),
              n.forEach(function (e, a) {
                (o[a][e].checked = !0), t.selectResult(o[a][e], a, r.num);
              });
        }
        var p = [];
        o.forEach(function (e, t) {
          (p[t] = 0),
            e.forEach(function (e, a) {
              e.checked && (p[t] = a);
            });
        }),
          this.setData({ pickerArray: o, piclerNum: p, typeName: r }),
          1 == s && this.isGDCar(p[0]);
      }
      this.setData({ pickerBol: !this.data.pickerBol });
    },
    mileageChanage: function (e) {
      this.setData({ mileage: e.detail.value });
    },
    sumbin: function () {
      if (wx.getStorageSync("uid")) {
        this.tongzhi();
        var t = this.data.query;
        t.license_plate_code
          ? t.license_plate_type
            ? t.license_plate
              ? "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("点击取消回调");
                    },
                  })
                : (wx.setStorageSync("carquery", this.data.query),
                  this.queryVin(),
                  console.log("开始执行"))
              : wx.showToast({
                  title: "请输入车牌号码",
                  icon: "none",
                  duration: 2e3,
                })
            : wx.showToast({
                title: "请选择车牌种类",
                icon: "none",
                duration: 2e3,
              })
          : 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 (t) {
      var a = { uid: wx.getStorageSync("uid"), vin: this.data.query.vin };
      e.getdata(a, "vincxmf").then((e) => {
        if ((console.log("vin回调数据:", e.data), e.data)) {
          var t = JSON.parse(e.data);
          console.log(t.result),
            wx.setStorageSync("orderInfo", t.result),
            wx.navigateTo({ url: "../carwzcx/carInfob" });
        }
      });
    },
    queryVinb: function () {
      var t = this,
        a = wx.getStorageSync("userid");
      e.util.request({
        url: "entry/wxapp/Payordeo",
        cachetime: "0",
        data: { typeid: 7, openid: a, seriousno: t.data.orderid },
        success(e) {
          e.data &&
            e.data.data &&
            e.data.code!=200 &&
            (console.log(e.data),
            wx.requestPayment({
              timeStamp: e.data.data.timeStamp,
              nonceStr: e.data.data.nonceStr,
              package: e.data.data.package,
              signType: "MD5",
              paySign: e.data.data.paySign,
              success: function (e) {
                t.getDetail();
              },
              fail: function (e) {},
            }));
        },
        fail(e) {
          wx.showModal({
            title: "温馨提醒",
            content: e.data.message ? e.data.message : "错误",
            showCancel: !1,
            success: function (e) {
              e.confirm;
            },
          });
        },
      });
    },
    getDetail: function () {
      var t = this,
        a = wx.getStorageSync("userid");
      this.setData({ "query.openid": a, "query.seriousno": t.data.orderid });
      var c = this.data.query;
      e.getdata(c, "carnjcx").then((e) => {
        console.log("年检回调数据:", e.data),
          wx.navigateTo({
            url:
              "/pages/carnj/carcxjl?car=" +
              c.province_small +
              c.license_plate_code +
              c.license_plate,
          }),
          (e = e.data).data && t.setData({ order: e.data.result });
      });
    },
    tongzhi: function (t) {
      e.getdata({ type: "4" }, "getdyxx").then((t) => {
        console.log(t.data),
          wx.requestSubscribeMessage({
            tmplIds: [t.data],
            success(a) {
              "accept" == a[t.data]
                ? (wx.showToast({ title: "订阅成功" }),
                  e.util.request({
                    url: "entry/wxapp/addtemplateid",
                    data: { templateid: t.data, uid: wx.getStorageSync("uid") },
                    header: { "content-type": "application/json" },
                    success: function (e) {
                      console.log(e);
                    },
                  }))
                : wx.showToast({ title: "订阅失败" });
            },
          });
      });
    },
    toDetailExample: function () {
      wx.navigateTo({ url: "/pages/carcxjl/carcxjl" });
    },
    toSelectCar: function () {
      wx.navigateTo({ url: "/pages/selectCar/selectCar" });
    },
    toSelectCity: function () {
      wx.navigateTo({ url: "/pages/selectCity/selectCity" });
    },
    toSelectTime: function () {
      wx.navigateTo({ url: "/pages/selectTime/selectTime" });
    },
    orderid: function () {
      let e = "";
      for (var t = 0; t < 8; t++) e += Math.floor(10 * Math.random());
      (e = "D" + new Date().getTime() + e), this.setData({ orderid: e });
    },
    saoys: function (e) {
      wx.navigateTo({ url: "../xszsb/xszsb?type=2" });
    },
    onLoad: function (e) {
      wx.getStorageSync("uid") || getApp().wxlogin(),
        wx.removeStorageSync("cardata"),
        this.orderid(),
        wx.removeStorageSync("carvehicle"),
        wx.removeStorageSync("carprov"),
        wx.removeStorageSync("carcity"),
        wx.removeStorageSync("cartime"),
        wx.removeStorageSync("cardatawx");
    },
    onReady: function () {},
    onShow: function () {
      e.appdengl();
      var t = wx.getStorageSync("cardata");
      if ((console.log("行驶证数据", t), t)) {
        this.setData({
          "query.province_small": t.号牌号码.words.substring(0, 1),
          "query.license_plate_code": t.号牌号码.words.substring(1, 2),
          "query.license_plate": t.号牌号码.words.substring(2, 8),
          "query.engine": t.发动机号码.words,
          "query.vin": t.车辆识别代号.words,
        });
        for (
          var a = t.车辆类型.words, c = this.data.carKind, i = 0;
          i < c.length;
          ++i
        )
          c[i].title == a &&
            this.setData({
              license_plate_type: c[i].title,
              "query.license_plate_type": c[i].id,
            });
      }
      var d = wx.getStorageSync("carvehicle"),
        l = wx.getStorageSync("carprov"),
        n = wx.getStorageSync("carcity"),
        r = wx.getStorageSync("cartime"),
        o = "";
      "" != n && null != n && (o = l.name + "-" + n.name),
        console.log("" == d),
        "" != d &&
          "" != r &&
          parseInt(r.split("-")[0]) < parseInt(d.makeyear) &&
          (r = ""),
        this.setData({
          carName: d.salesdesc,
          cityName: o,
          regdate: r,
          cityid: n.id,
          provid: l.id,
          carId: d.autohomeid,
        });
    },
    data: {
      regdate: "",
      mileage: "",
      carName: "",
      cityName: "",
      cityid: 0,
      provid: 0,
      carId: 0,
      banner: [],
      carHeadList: [
        {
          checked: !1,
          license_plate_code: "A",
          province_small: "云",
          id: 1,
          create_date: "2021-04-29 01:13:58",
          update_date: "2021-04-29 01:13:58",
        },
        {
          checked: !1,
          create_date: "2021-04-29 01:13:58",
          id: 2,
          license_plate_code: "A,C,E,F,H,J,K,L,M",
          province_small: "京",
          update_date: "2021-04-29 01:13:58",
        },
        {
          checked: !1,
          create_date: "2021-04-29 01:13:58",
          id: 3,
          license_plate_code: "A,B,C,D,E,F,G,H,J,R,T",
          province_small: "冀",
          update_date: "2021-04-29 01:13:58",
        },
        {
          checked: !1,
          create_date: "2021-04-29 01:13:58",
          id: 4,
          license_plate_code: "A,B,C,D,E,F,G,H,J,K,L,M",
          province_small: "内蒙古",
          update_date: "2021-04-29 01:13:58",
        },
        {
          checked: !1,
          create_date: "2021-04-29 01:13:58",
          id: 5,
          license_plate_code: "A,B,C,D,E,F,G,H,J,K",
          province_small: "吉",
          update_date: "2021-04-29 01:13:58",
        },
        {
          checked: !1,
          create_date: "2021-04-29 01:13:58",
          id: 6,
          license_plate_code: "A,B,C,D,E",
          province_small: "宁",
          update_date: "2021-04-29 01:13:58",
        },
        {
          checked: !1,
          create_date: "2021-04-29 01:13:58",
          id: 7,
          license_plate_code: "A,B,C,D,E,F,H,J,K,L,M,Q,R,S,T,U,V,W,X,Y,Z",
          province_small: "川",
          update_date: "2021-04-29 01:13:58",
        },
        {
          checked: !1,
          create_date: "2021-04-29 01:13:58",
          id: 8,
          license_plate_code: "A,B,C,D,E,F,J,K,L,M,N,Q",
          province_small: "新",
          update_date: "2021-04-29 01:13:58",
        },
        {
          checked: !1,
          create_date: "2021-04-29 01:13:58",
          id: 9,
          license_plate_code: "A,B,C,D,E,F,G,J,K,L,M,N,P,R",
          province_small: "桂",
          update_date: "2021-04-29 01:13:58",
        },
        {
          checked: !1,
          create_date: "2021-04-29 01:13:58",
          id: 10,
          license_plate_code: "A,B",
          province_small: "沪",
          update_date: "2021-04-29 01:13:58",
        },
        {
          checked: !1,
          create_date: "2021-04-29 01:13:58",
          id: 11,
          license_plate_code: "A",
          province_small: "津",
          update_date: "2021-04-29 01:13:58",
        },
        {
          checked: !1,
          create_date: "2021-04-29 01:13:58",
          id: 12,
          license_plate_code: "A,B,C,D,E,F,G,H,J,K,L",
          province_small: "浙",
          update_date: "2021-04-29 01:13:58",
        },
        {
          checked: !1,
          create_date: "2021-04-29 01:13:58",
          id: 13,
          license_plate_code: "A,D",
          province_small: "渝",
          update_date: "2021-04-29 01:13:58",
        },
        {
          checked: !1,
          create_date: "2021-04-29 01:13:58",
          id: 14,
          license_plate_code: "A,B,C,D,E,F,G,H,J,K,L,M,N,U",
          province_small: "湘",
          update_date: "2021-04-29 01:13:58",
        },
        {
          checked: !1,
          create_date: "2021-04-29 01:13:58",
          id: 15,
          license_plate_code: "A,B",
          province_small: "琼",
          update_date: "2021-04-29 01:13:58",
        },
        {
          checked: !1,
          create_date: "2021-04-29 01:13:58",
          id: 16,
          license_plate_code: "A,B,C,D,E,F,G,H,J,K,L,M,N,P",
          province_small: "甘",
          update_date: "2021-04-29 01:13:58",
        },
        {
          checked: !1,
          create_date: "2021-04-29 01:13:58",
          id: 17,
          license_plate_code: "A,B,D,E,F,H,K,L,M,P,R",
          province_small: "皖",
          update_date: "2021-04-29 01:13:58",
        },
        {
          checked: !1,
          create_date: "2021-04-29 01:13:58",
          id: 18,
          license_plate_code: "A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S,T,U,V,W",
          province_small: "粤",
          update_date: "2021-04-29 01:13:58",
        },
        {
          checked: !1,
          create_date: "2021-04-29 01:13:58",
          id: 19,
          license_plate_code: "A,B,C,D,E,F,G,H,J,K,L,M,N,U",
          province_small: "苏",
          update_date: "2021-04-29 01:13:58",
        },
        {
          checked: !1,
          create_date: "2021-04-29 01:13:58",
          id: 20,
          license_plate_code: "A",
          province_small: "藏",
          update_date: "2021-04-29 01:13:58",
        },
        {
          checked: !1,
          create_date: "2021-04-29 01:13:58",
          id: 21,
          license_plate_code: "A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R",
          province_small: "豫",
          update_date: "2021-04-29 01:13:58",
        },
        {
          checked: !1,
          create_date: "2021-04-29 01:13:58",
          id: 22,
          license_plate_code: "A,B,C,D,E,F,G,H,J",
          province_small: "贵",
          update_date: "2021-04-29 01:13:58",
        },
        {
          checked: !1,
          create_date: "2021-04-29 01:13:58",
          id: 23,
          license_plate_code: "A,B,C,D,E,F,G,H,J,K,L",
          province_small: "赣",
          update_date: "2021-04-29 01:13:58",
        },
        {
          checked: !1,
          create_date: "2021-04-29 01:13:58",
          id: 24,
          license_plate_code: "A,B,C,D,E,F,G,H,J,K,M,N",
          province_small: "辽",
          update_date: "2021-04-29 01:13:58",
        },
        {
          checked: !1,
          create_date: "2021-04-29 01:13:58",
          id: 25,
          license_plate_code: "A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S",
          province_small: "鄂",
          update_date: "2021-04-29 01:13:58",
        },
        {
          checked: !1,
          create_date: "2021-04-29 01:13:58",
          id: 26,
          license_plate_code: "A,B,C,D,E,F,G",
          province_small: "闽",
          update_date: "2021-04-29 01:13:58",
        },
        {
          checked: !1,
          create_date: "2021-04-29 01:13:58",
          id: 27,
          license_plate_code: "A,B,C,D,E,G,H,J,K,U",
          province_small: "陕",
          update_date: "2021-04-29 01:13:58",
        },
        {
          checked: !1,
          create_date: "2021-04-29 01:13:58",
          id: 28,
          license_plate_code: "A,B,C,D,E,F,H",
          province_small: "青",
          update_date: "2021-04-29 01:13:58",
        },
        {
          checked: !1,
          create_date: "2021-04-29 01:13:58",
          id: 29,
          license_plate_code: "A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,V",
          province_small: "鲁",
          update_date: "2021-04-29 01:13:58",
        },
        {
          checked: !1,
          create_date: "2021-04-29 01:13:58",
          id: 30,
          license_plate_code: "A,B,C,D,E,F,G,H,J,K,M,N,P",
          province_small: "黑",
          update_date: "2021-04-29 01:13:58",
        },
      ],
      carKind: [
        { id: "02", checked: !1, title: "小型轿车" },
        { id: "02", checked: !1, title: "小型普通客车" },
        { id: "52", checked: !1, title: "新能源小型车" },
        { id: "01", checked: !1, title: "大型货车" },
        { id: "01", checked: !1, title: "中型客车" },
      ],
      circular: 1500,
      conditions: [{ checked: !1, title: "不含4" }],
      hot_type: "任意号码",
      isAuthorized: !0,
      isHighBol: !1,
      letter: [
        { checked: !1, title: "A" },
        { checked: !1, title: "B" },
        { checked: !1, title: "C" },
        { checked: !1, title: "D" },
        { checked: !1, title: "E" },
        { checked: !1, title: "F" },
        { checked: !1, title: "G" },
        { checked: !1, title: "H" },
        { checked: !1, title: "J" },
        { checked: !1, title: "K" },
        { checked: !1, title: "L" },
        { checked: !1, title: "M" },
        { checked: !1, title: "N" },
        { checked: !1, title: "P" },
        { checked: !1, title: "Q" },
        { checked: !1, title: "R" },
        { checked: !1, title: "S" },
        { checked: !1, title: "T" },
        { checked: !1, title: "U" },
        { checked: !1, title: "V" },
        { checked: !1, title: "W" },
        { checked: !1, title: "X" },
        { checked: !1, title: "Y" },
      ],
      license_plate_type: "",
      pickerArray: [],
      pickerBol: !1,
      piclerNum: [],
      query: {
        hot_type: "",
        lazy_typ: 0,
        license_plate: "",
        license_plate_code: "",
        license_plate_type: "",
        not_four_type: 1,
        pageIndex: 1,
        pageSize: 10,
        province_small: "",
      },
      rules: [
        { checked: !1, id: "", title: "任意号码" },
        { checked: !1, id: "1", title: "豹子号,如:666、888" },
        { checked: !1, id: "2", title: "顺子号,如:123、789" },
        { checked: !1, id: "3", title: "规则AAAA,如:8888" },
        { checked: !1, id: "4", title: "规则AABB,如:6688" },
        { checked: !1, id: "5", title: "规则ABAB,如:1212" },
        { checked: !1, id: "6", title: "规则ABBA,如:8998" },
        { checked: !1, id: "7", title: "规则ABA,如:868" },
        { checked: !1, id: "8", title: "规则AA,如:88、99" },
      ],
      typeName: { num: 0, title: "" },
    },
    onHide: function () {},
    onUnload: function () {},
    onPullDownRefresh: function () {},
    onReachBottom: function () {},
    onShareAppMessage: function () {},
  });
})();