"use strict";
const common_vendor = require("../../common/vendor.js");
const utils_util = require("../../utils/util.js");
const api_user = require("../../api/user.js");
const pageSize = 10;
const _sfc_main = {
  __name: "in-out",
  setup(__props) {
    const list = common_vendor.ref([]);
    const loading = common_vendor.ref(false);
    const finished = common_vendor.ref(false);
    const page = common_vendor.ref(1);
    const studentId = common_vendor.ref(0);
    async function fetchData() {
      if (loading.value || finished.value)
        return;
      loading.value = true;
      try {
        const res = await api_user.userApi.getStudentRecordLog({
          studentId: studentId.value,
          index: page.value,
          size: pageSize
        });
        list.value = [...list.value, ...res.list];
        if (list.value.length >= res.total) {
          finished.value = true;
        }
        page.value++;
      } catch (error) {
        common_vendor.index.__f__("error", "at pages/parent/in-out.vue:68", "获取进出记录失败：", error);
        common_vendor.index.showToast({
          title: "获取数据失败",
          icon: "none"
        });
      } finally {
        loading.value = false;
      }
    }
    async function onRefresh() {
      page.value = 1;
      list.value = [];
      total.value = 0;
      finished.value = false;
      await fetchData();
      common_vendor.index.stopPullDownRefresh();
    }
    common_vendor.onLoad((options) => {
      if (options && options.studentId) {
        studentId.value = options.studentId;
      }
      fetchData();
    });
    common_vendor.onPullDownRefresh(() => {
      onRefresh();
    });
    common_vendor.onReachBottom(() => {
      fetchData();
    });
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: common_vendor.f(list.value, (item, index, i0) => {
          return {
            a: common_vendor.t(item.status === 1 ? "进" : "出"),
            b: common_vendor.n(item.status === 1 ? "in" : "out"),
            c: common_vendor.t(common_vendor.unref(utils_util.formatTime)(item.createTime, "MM月dd日 HH:mm:ss")),
            d: index
          };
        }),
        b: loading.value
      }, loading.value ? {} : {}, {
        c: finished.value && list.value.length
      }, finished.value && list.value.length ? {} : {}, {
        d: !loading.value && !list.value.length
      }, !loading.value && !list.value.length ? {} : {}, {
        e: common_vendor.gei(_ctx, "")
      });
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-5e87232f"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/parent/in-out.js.map
