!(function () {
  var e = getApp(),
    t = 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 });
    },
    name: function (e) {
      var t = e.detail.value;
      this.setData({ name: 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 });
    },
    openPick: function (e) {
      var t = this,
        a = this.data,
        c = a.carHeadList,
        i = a.letter,
        d = a.carKind,
        n = a.rules,
        l = 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(n);
            break;
          case 4:
            o.forEach(function (e) {
              e.forEach(function (e) {
                e.checked = !1;
              });
            }),
              l.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 () {
      this.tongzhi();
      var t = this.data.query;
      if (t.license_plate)
        if (18 == t.license_plate.length)
          if (this.data.name)
            if ("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("点击取消回调");
                },
              });
            else {
              var a = this,
                c = {
                  content:
                    a.data.mileage +
                    a.data.engine +
                    a.data.chepai +
                    a.data.name +
                    a.data.query.license_plate,
                };
              e.getdata(c, "checkContent").then((e) => {
                console.log("文本回调数据：", e),
                  0 == e.errcode
                    ? a.queryVin()
                    : wx.showModal({
                        title: "温馨提示",
                        content:
                          "你输入的文本检测存在违规，请检测文本内容后重新输入。",
                        success: function (e) {
                          e.confirm || console.log("点击取消回调");
                        },
                      });
              });
            }
          else
            wx.showToast({
              title: "请输入车主姓名",
              icon: "none",
              duration: 2e3,
            });
        else
          wx.showToast({
            title: "身份证号码长度错误",
            icon: "none",
            duration: 2e3,
          });
      else
        wx.showToast({
          title: "请输入身份证号码",
          icon: "none",
          duration: 2e3,
        });
    },
    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 });
    },
    queryVin: function () {
      if (wx.getStorageSync("uid")) {
        var e = this;
        e.orderid(),
          console.log(wx.getStorageSync("uid")),
          wx.getStorageSync("uid")
            ? (console.log(wx.getStorageSync("uid")),
              t.util.request({
                url: "entry/wxapp/paynum",
                method: "post",
                dataType: "json",
                data: {
                  m: "monai_market",
                  type: "sfzhy_money",
                  orderid: e.data.orderid,
                  uid: wx.getStorageSync("uid"),
                  postcardata: JSON.stringify(e.data),
                },
                success: function (a) {
                  a.data && a.data.data && 1e3 == a.data.message
                    ? t.util.request({
                        url: "entry/wxapp/Api",
                        data: {
                          m: "monai_market",
                          uid: wx.getStorageSync("uid"),
                          r: "home.weizhang.paynum",
                          orderid: a.data.data.orderid,
                        },
                        success: function (t) {
                          wx.showModal({ content: t.data.message }),
                            e.setData({
                              weizhang_num: 1 * e.data.weizhang_num + 10,
                            }),
                            e.getDetailpay();
                        },
                      })
                    : a.data &&
                      a.data.data &&
                      !a.data.errno &&
                      wx.requestPayment({
                        timeStamp: a.data.data.timeStamp,
                        nonceStr: a.data.data.nonceStr,
                        package: a.data.data.package,
                        signType: "MD5",
                        paySign: a.data.data.paySign,
                        success: function (c) {
                          t.util.request({
                            url: "entry/wxapp/Api",
                            data: {
                              m: "monai_market",
                              uid: wx.getStorageSync("uid"),
                              r: "home.weizhang.paynum",
                              orderid: a.data.data.orderid,
                            },
                            success: function (t) {
                              e.setData({
                                weizhang_num: 1 * e.data.weizhang_num + 10,
                              }),
                                wx.showModal({ content: t.data.message }),
                                e.getDetailpay();
                            },
                          });
                        },
                      });
                },
              }))
            : wx.showModal({
                title: "温馨提醒",
                content: "使用本功能请先登录后在使用~",
                showCancel: !1,
                success: function (e) {
                  e.confirm && wx.reLaunch({ url: "/pages/mine/index" });
                },
              });
      } else
        wx.showModal({
          title: "温馨提示",
          content: "请去个人中心授权登录用户信息",
          success: function (e) {
            e.confirm
              ? wx.reLaunch({ url: "/pages/mine/index" })
              : console.log("点击取消回调");
          },
        });
    },
    getDetailpay: function () {
      var t = this;
      this.setData({
        "query.uid": wx.getStorageSync("uid"),
        "query.orderid": t.data.orderid,
        "query.name": t.data.name,
      });
      var a = this.data.query;
      e.getdata(a, "sfzhy").then((e) => {
        console.log("年检回调数据：", e.data),
          wx.navigateTo({ url: "../sfzhy/carcxjl?orderid=" + t.data.orderid }),
          (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: "../sfzhy/carcxjl?orderid=D167040592841545146692" });
    },
    toSelectCar: function () {
      wx.navigateTo({ url: "/pages/selectCar/selectCar" });
    },
    toSelectCity: function () {
      wx.navigateTo({ url: "/pages/selectCity/selectCity" });
    },
    toSelectTime: function () {
      wx.navigateTo({ url: "/pages/selectTime/selectTime" });
    },
    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(), this.getDetail(1);
      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),
        });
        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"),
        n = wx.getStorageSync("carprov"),
        l = wx.getStorageSync("carcity"),
        r = wx.getStorageSync("cartime"),
        o = "";
      "" != l && null != l && (o = n.name + "-" + l.name),
        console.log("" == d),
        "" != d &&
          "" != r &&
          parseInt(r.split("-")[0]) < parseInt(d.makeyear) &&
          (r = ""),
        this.setData({
          carName: d.salesdesc,
          cityName: o,
          regdate: r,
          cityid: l.id,
          provid: n.id,
          carId: d.autohomeid,
        });
    },
    data: {
      page: 1,
      type: "21",
      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: "" },
    },
    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 (t) {
      var a = this,
        c = { uid: wx.getStorageSync("uid"), type: a.data.type, page: t };
      e.getdata(c, "carqxcx").then((e) => {
        if ((console.log("回调数据：", e), e.data && 0 == e.errno))
          if (1 == t) a.setData({ repairList: e.data, page: a.data.page + 1 });
          else {
            var c = a.data.repairList;
            c.push.apply(c, e.data),
              a.setData({ repairList: c, page: a.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 (e) {
      var t = e.currentTarget.dataset.orderid;
      wx.navigateTo({
        url: "/packageA/pages/sfzhy/carcxjl?orderid=" + t,
        success: function () {},
      });
    },
  });
})();
