"use strict";
const common_vendor = require("../../common/vendor.js");
const api_api = require("../../api/api.js");
if (!Array) {
  const _easycom_statusBar2 = common_vendor.resolveComponent("statusBar");
  const _easycom_z_paging2 = common_vendor.resolveComponent("z-paging");
  const _easycom_cc_myTabbar2 = common_vendor.resolveComponent("cc-myTabbar");
  (_easycom_statusBar2 + _easycom_z_paging2 + _easycom_cc_myTabbar2)();
}
const _easycom_statusBar = () => "../../components/statusBar/statusBar.js";
const _easycom_z_paging = () => "../../uni_modules/z-paging/components/z-paging/z-paging.js";
const _easycom_cc_myTabbar = () => "../../uni_modules/cc-myTabbar/components/cc-myTabbar/cc-myTabbar.js";
if (!Math) {
  (_easycom_statusBar + _easycom_z_paging + _easycom_cc_myTabbar)();
}
const _sfc_main = {
  __name: "order",
  setup(__props) {
    const paging = common_vendor.ref(null);
    let dataList = common_vendor.ref([]);
    common_vendor.ref([]);
    let status = common_vendor.ref(1);
    let status_list = common_vendor.ref([
      {
        name: "全部",
        type: ""
      },
      {
        name: "进行中",
        type: 1
      },
      {
        name: "已完成",
        type: 2
      },
      {
        name: "待支付",
        type: 3
      }
    ]);
    let chanStatus = (e) => {
      status.value = e;
      paging.value.reload();
    };
    common_vendor.onLoad(async () => {
    });
    let toLink = (e) => {
      if (e.status == 2 || e.status == 3 || e.status == 4) {
        common_vendor.index.navigateTo({
          url: `/pageOrder/recharge/recharge?transactionNo=${e.transactionNo}&type=order`
        });
      }
    };
    let isPagingRefNotFound = () => {
      return !paging.value;
    };
    common_vendor.onPullDownRefresh(() => {
      if (isPagingRefNotFound())
        return;
      paging.value.reload().catch(() => {
      });
    });
    common_vendor.onPageScroll((e) => {
      if (isPagingRefNotFound())
        return;
      paging.value.updatePageScrollTop(e.scrollTop);
      e.scrollTop < 10 && paging.value.doChatRecordLoadMore();
    });
    common_vendor.onReachBottom(() => {
      if (isPagingRefNotFound())
        return;
      paging.value.pageReachBottom();
    });
    const queryList = (pageNo, pageSize) => {
      const params = {
        current: pageNo,
        pageSize,
        type: status.value
      };
      api_api.ordersList(params).then((res) => {
        paging.value.complete(res);
      }).catch((res) => {
        paging.value.complete(false);
      });
    };
    return (_ctx, _cache) => {
      return {
        a: common_vendor.f(common_vendor.unref(status_list), (item, index, i0) => {
          return common_vendor.e({
            a: common_vendor.t(item.name),
            b: item.type == common_vendor.unref(status)
          }, item.type == common_vendor.unref(status) ? {} : {}, {
            c: common_vendor.o(($event) => common_vendor.unref(chanStatus)(item.type), index),
            d: index,
            e: common_vendor.n(common_vendor.unref(status) == item.type ? "order_header_active" : "")
          });
        }),
        b: common_vendor.f(common_vendor.unref(dataList), (item, index, i0) => {
          return {
            a: common_vendor.t(item.orderNo),
            b: common_vendor.t(item.startTime),
            c: common_vendor.t(item.endTime),
            d: common_vendor.t(item.useDegree),
            e: common_vendor.t(item.serviceAmount),
            f: common_vendor.t(item.electricityAmount),
            g: common_vendor.t(item.preAmount),
            h: common_vendor.t(item.actuallyAmount),
            i: index,
            j: common_vendor.o(($event) => common_vendor.unref(toLink)(item), index)
          };
        }),
        c: common_vendor.sr(paging, "93207a4f-0", {
          "k": "paging"
        }),
        d: common_vendor.o(queryList),
        e: common_vendor.o(($event) => common_vendor.isRef(dataList) ? dataList.value = $event : dataList = $event),
        f: common_vendor.p({
          ["use-page-scroll"]: true,
          modelValue: common_vendor.unref(dataList)
        }),
        g: common_vendor.p({
          tabBarShow: 3
        })
      };
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-93207a4f"]]);
_sfc_main.__runtimeHooks = 1;
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/order/order.js.map
