var e = require("../../common/vendor.js"),
  u = require("../../hooks/onMounted.js"),
  t = require("../../hooks/onShow.js"),
  n = require("../../hooks/onShareAppMessage.js"),
  r = require("../../service/index.js"),
  o = require("../../enums/index.js"),
  a = require("../../utils/util.js"),
  s = require("../../utils/navigate.js"),
  i = require("../../utils/common.js");
require("../../hooks/useState.js"),
  require("../../store/app/index.js"),
  require("../../data/index.js"),
  require("../../config/index.js"),
  require("../../constant/index.js"),
  require("../../utils/request.js"),
  Array || e.resolveComponent("uni-load-more")();
Math ||
  (
    e.unref(v) +
    function () {
      return "../../uni_modules/uni-load-more/components/uni-load-more/uni-load-more.js";
    } +
    e.unref(p) +
    e.unref(f) +
    e.unref(l) +
    e.unref(d) +
    e.unref(c)
  )();
var d = function () {
    return "../../components/popup-upload-tips/index.js";
  },
  c = function () {
    return "../../components/popup-pay-again/index.js";
  },
  f = function () {
    return "../../components/float-refresh/index.js";
  },
  l = function () {
    return "../../components/float-back-to-top/index.js";
  },
  p = function () {
    return "../../components/empty/index.js";
  },
  v = function () {
    return "../../components/vehicle-number/index.js";
  },
  m = {
    __name: "index",
    setup: function (d) {
      var c = e.ref(!0),
        f = e.ref(!1),
        l = e.ref(!1),
        p = e.ref(1),
        v = e.ref(o.PageStatusEnum.LOADING),
        m = e.ref([]),
        E = e.ref(!1),
        _ = e.ref(!1),
        S = e.ref(!1),
        g = e.ref(null),
        N = function () {
          var e = _.value || S.value;
          return "height: 100%; overflow: "
            .concat(e ? "hidden" : "visible", "; position: ")
            .concat(e ? "fixed" : "relative");
        },
        h = function (u) {
          return e._.find(u.productList, function (e) {
            return e.status === o.ProductStatusEnum.TO_BE_UPLOADED;
          });
        },
        P = function (e) {
          var u = e.order_no,
            t = e.product_id,
            n = e.status;
          i.openReport({ orderNo: u, productId: t, status: n });
        },
        I = function () {
          a.showToast("已经帮您催了，请耐心等待一会儿...");
        },
        A = function () {
          i.queryWithoutDrivingLicense({ orderNo: g.value.order_no }).then(
            function () {
              s.navigateTo({ url: "/pages/upload-success/index" }),
                (_.value = !1);
            }
          );
        },
        T = function () {
          _.value = !1;
        },
        O = function () {
          S.value = !1;
        },
        x = function (e) {
          y(e), (S.value = !1);
        },
        y = function (e) {
          a.showLoading("支付中"),
            r
              .payOrderAgain({ payMethod: e, order_no: g.value.order_no })
              .then(function (u) {
                i.payForOrder({ payMethod: e, data: u })
                  .then(function (e) {
                    var u = e.orderNo;
                    s.navigateTo({
                      url: "/pages/pay-success/index",
                      params: { orderNo: u },
                    });
                  })
                  .catch(function (e) {
                    var u = e.orderNo;
                    s.navigateTo({
                      url: "/pages/pay-fail/index",
                      params: { orderNo: u },
                    });
                  });
              });
        },
        D = function () {
          return v.value === o.PageStatusEnum.NOMORE
            ? Promise.resolve()
            : ((v.value = o.PageStatusEnum.LOADING),
              r
                .getOrderList({ page: p.value, status: 0 })
                .then(function (u) {
                  var t = u.data,
                    n = u.per_page;
                  0 === t.length && 0 === m.value.length
                    ? (l.value = !0)
                    : ((l.value = !1),
                      t.length < n && (v.value = o.PageStatusEnum.NOMORE),
                      1 === p.value
                        ? (m.value = t)
                        : (m.value = e._.concat(m.value, t)));
                })
                .catch(function () {
                  l.value = !0;
                })
                .finally(function () {
                  a.hideLoading(), e.index.stopPullDownRefresh();
                }));
        },
        L = function () {
          a.showLoading(),
            (E.value = !0),
            (v.value = ""),
            (p.value = 1),
            D().then(function () {
              (E.value = !1),
                a.hideLoading(),
                e.index.stopPullDownRefresh(),
                e.index.pageScrollTo({ scrollTop: 0, duration: 100 });
            });
        };
      return (
        u.onMounted(function () {
          e.index.$on("updateOrderList", function (u) {
            return (function (u) {
              var t = e._.findIndex(m.value, function (e) {
                return e.order_no === u;
              });
              -1 === t
                ? L()
                : r.getOrderDetail({ order_no: u }).then(function (e) {
                    var u = m.value[t];
                    (u.vin = e.vin),
                      (u.car_no = e.car_no),
                      (u.status = e.status),
                      (u.productList = e.productList),
                      (m.value[t] = u);
                  });
            })(u);
          }),
            D().then(function () {
              (c.value = !1),
                a.hideLoading(),
                e.index.pageScrollTo({ scrollTop: 0, duration: 100 });
            });
        }),
        e.onPullDownRefresh(function () {
          L();
        }),
        e.onReachBottom(function () {
          p.value++, D();
        }),
        e.onPageScroll(function (u) {
          var t = u.scrollTop;
          f.value = t >= e.index.getSystemInfoSync().windowHeight / 3;
        }),
        t.onShow(),
        n.onShareAppMessage(),
        function (u, t) {
          return e.e(
            { a: N(), b: !c.value },
            c.value
              ? {}
              : e.e(
                  { c: !l.value },
                  l.value
                    ? {}
                    : {
                        d: e.f(m.value, function (u, t, n) {
                          return e.e(
                            {
                              a: e.t(
                                e.unref(i.getProduct)(u.product_id).product_name
                              ),
                              b: u.status === e.unref(o.OrderStatusEnum).UNPAID,
                            },
                            (u.status, e.unref(o.OrderStatusEnum).UNPAID, {}),
                            { c: u.status === e.unref(o.OrderStatusEnum).PAID },
                            u.status === e.unref(o.OrderStatusEnum).PAID
                              ? {
                                  d: e.t(
                                    e.unref(i.getOrderStatus)(u.productList)
                                  ),
                                }
                              : {},
                            {
                              e: u.status === e.unref(o.OrderStatusEnum).REFUND,
                            },
                            (u.status, e.unref(o.OrderStatusEnum).REFUND, {}),
                            {
                              f:
                                u.status ===
                                e.unref(o.OrderStatusEnum).COMPLETE,
                            },
                            (u.status, e.unref(o.OrderStatusEnum).COMPLETE, {}),
                            { g: e.t(u.order_no), h: u.car_name },
                            u.car_name ? { i: e.t(u.car_name) } : {},
                            { j: u.car_no },
                            u.car_no
                              ? {
                                  k: "2f990aa7-0-" + n,
                                  l: e.p({ data: u.car_no }),
                                }
                              : {},
                            { m: u.vin },
                            u.vin
                              ? {
                                  n: e.t(
                                    (u.vin || "")
                                      .toString()
                                      .replace(/^(.{5}).{6}/, "$1******")
                                  ),
                                }
                              : {},
                            { o: e.t(u.create_time), p: u.productList },
                            u.productList
                              ? {
                                  q: e.f(u.productList, function (t, r, a) {
                                    return e.e(
                                      {
                                        a: e.t(
                                          e.unref(i.getProduct)(t.product_id)
                                            .product_name
                                        ),
                                        b: e.t(
                                          e.unref(i.getProduct)(t.product_id)
                                            .product_desc
                                        ),
                                        c:
                                          u.status !==
                                            e.unref(o.OrderStatusEnum).REFUND &&
                                          t.status ===
                                            e.unref(o.ProductStatusEnum)
                                              .IN_QUERY,
                                      },
                                      u.status !==
                                        e.unref(o.OrderStatusEnum).REFUND &&
                                        t.status ===
                                          e.unref(o.ProductStatusEnum).IN_QUERY
                                        ? {
                                            d: "2f990aa7-1-" + n + "-" + a,
                                            e: e.p({
                                              iconType: "snow",
                                              iconSize: 20,
                                              status: "loading",
                                              showText: !1,
                                            }),
                                          }
                                        : {},
                                      u.status !==
                                        e.unref(o.OrderStatusEnum).REFUND
                                        ? e.e(
                                            {
                                              f:
                                                t.status ===
                                                e.unref(o.ProductStatusEnum)
                                                  .SUCCESS,
                                            },
                                            t.status ===
                                              e.unref(o.ProductStatusEnum)
                                                .SUCCESS
                                              ? {
                                                  g: e.o(function (e) {
                                                    return P(t);
                                                  }, t.id),
                                                }
                                              : {},
                                            {
                                              h:
                                                t.status ===
                                                  e.unref(o.ProductStatusEnum)
                                                    .FAIL &&
                                                (t.product_id ==
                                                  e.unref(o.ProductTypeEnum)
                                                    .INSURANCE_MAINTAIN ||
                                                  t.product_id ===
                                                    e.unref(o.ProductTypeEnum)
                                                      .ACCIDENT),
                                            },
                                            t.status !==
                                              e.unref(o.ProductStatusEnum)
                                                .FAIL ||
                                              (t.product_id !=
                                                e.unref(o.ProductTypeEnum)
                                                  .INSURANCE_MAINTAIN &&
                                                t.product_id !==
                                                  e.unref(o.ProductTypeEnum)
                                                    .ACCIDENT)
                                              ? {}
                                              : {
                                                  i: e.o(function (e) {
                                                    return P(t);
                                                  }, t.id),
                                                },
                                            {
                                              j:
                                                t.status ===
                                                e.unref(o.ProductStatusEnum)
                                                  .IN_QUERY,
                                            },
                                            t.status ===
                                              e.unref(o.ProductStatusEnum)
                                                .IN_QUERY
                                              ? { k: e.o(I, t.id) }
                                              : {},
                                            {
                                              l:
                                                t.status ===
                                                  e.unref(o.ProductStatusEnum)
                                                    .FAIL &&
                                                t.product_id !==
                                                  e.unref(o.ProductTypeEnum)
                                                    .INSURANCE_MAINTAIN &&
                                                t.product_id !==
                                                  e.unref(o.ProductTypeEnum)
                                                    .ACCIDENT,
                                            },
                                            (t.status ===
                                              e.unref(o.ProductStatusEnum)
                                                .FAIL &&
                                              t.product_id !==
                                                e.unref(o.ProductTypeEnum)
                                                  .INSURANCE_MAINTAIN &&
                                              (t.product_id,
                                              e.unref(o.ProductTypeEnum)
                                                .ACCIDENT),
                                            {})
                                          )
                                        : {},
                                      { m: t.id }
                                    );
                                  }),
                                  r:
                                    u.status !==
                                    e.unref(o.OrderStatusEnum).REFUND,
                                }
                              : {},
                            {
                              s: u.status !== e.unref(o.OrderStatusEnum).REFUND,
                            },
                            u.status !== e.unref(o.OrderStatusEnum).REFUND
                              ? e.e(
                                  {
                                    t:
                                      u.status ===
                                      e.unref(o.OrderStatusEnum).UNPAID,
                                  },
                                  u.status === e.unref(o.OrderStatusEnum).UNPAID
                                    ? {
                                        v: e.o(function (e) {
                                          return (
                                            (t = u),
                                            (g.value = t),
                                            void y(o.PayMethodEnum.WECHAT_PAY)
                                          );
                                          var t;
                                        }, u.order_no),
                                      }
                                    : {},
                                  { w: h(u) },
                                  h(u)
                                    ? e.e(
                                        {
                                          x: e.o(function (e) {
                                            return (
                                              (t = u),
                                              void i
                                                .chooseDrivingLicense({
                                                  orderNo: t.order_no,
                                                })
                                                .then(function () {
                                                  s.navigateTo({
                                                    url: "/pages/upload-success/index",
                                                  });
                                                })
                                            );
                                            var t;
                                          }, u.order_no),
                                          y:
                                            u.vin ||
                                            u.type ===
                                              e.unref(o.ProductTypeEnum)
                                                .VIOLATION,
                                        },
                                        u.vin ||
                                          u.type ===
                                            e.unref(o.ProductTypeEnum).VIOLATION
                                          ? {
                                              z: e.o(function (e) {
                                                return (
                                                  (t = u),
                                                  (_.value = !0),
                                                  void (g.value = t)
                                                );
                                                var t;
                                              }, u.order_no),
                                            }
                                          : {}
                                      )
                                    : {}
                                )
                              : {},
                            {
                              A: u.order_no,
                              B: e.o(function (e) {
                                return (function (e) {
                                  var u = e.order_no,
                                    t = e.product_id;
                                  s.navigateTo({
                                    url: "/pages/order-detail/index",
                                    params: {
                                      orderNo: u,
                                      productName: i.getProduct(t).product_name,
                                    },
                                  });
                                })(u);
                              }, u.order_no),
                            }
                          );
                        }),
                        e: m.value.length,
                        f: e.p({ iconType: "snow", status: v.value }),
                      },
                  { g: l.value },
                  l.value ? { h: e.p({ info: "暂无订单记录" }) } : {},
                  {
                    i: e.o(L),
                    j: e.p({ loading: E.value }),
                    k: e.p({ visible: f.value }),
                    l: e.o(T),
                    m: e.o(A),
                    n: e.p({ visible: _.value }),
                    o: e.o(O),
                    p: e.o(x),
                    q: e.p({ visible: S.value }),
                  }
                )
          );
        }
      );
    },
  },
  E = e._export_sfc(m, [["__scopeId", "data-v-2f990aa7"]]);
(m.__runtimeHooks = 3), wx.createPage(E);
