"use strict";
const common_vendor = require("../../common/vendor.js");
const utils_api = require("../../utils/api.js");
const utils_previewImage = require("../../utils/previewImage.js");
if (!Math) {
  NoData();
}
const NoData = () => "../../components/noData.js";
const _sfc_main = {
  __name: "msgWarn",
  setup(__props) {
    common_vendor.onLoad(() => {
      let token = common_vendor.index.getStorageSync("token");
      if (token) {
        getData();
      } else {
        common_vendor.index.reLaunch({
          url: "/pages/index/index"
        });
      }
    });
    common_vendor.onReachBottom(() => {
      if (list.value.length < total.value) {
        currentPage.value++;
        getData();
      } else {
        common_vendor.index.showToast({
          title: "没有更多数据了",
          icon: "none"
        });
      }
    });
    const currentPage = common_vendor.ref(1);
    const pageCount = common_vendor.ref(5);
    const total = common_vendor.ref(0);
    const currentIndex = common_vendor.ref(0);
    const array = common_vendor.ref(["全部通知", "预警推送", "学生轨迹"]);
    const list = common_vendor.ref([]);
    const getData = async () => {
      const res = await utils_api.myRequest({
        url: "/wanzai/api/smart-notification/remindingList",
        data: {
          id: common_vendor.index.getStorageSync("userInfo").id,
          currentPage: currentPage.value,
          pageCount: pageCount.value,
          type: currentIndex.value == 0 ? "" : currentIndex.value
        }
      });
      if (res.code == 200) {
        list.value = [...list.value, ...res.data.list];
        total.value = res.data.totalCount;
      }
    };
    const bindPickerChange = (e) => {
      currentIndex.value = e.detail.value;
      list.value = [];
      currentPage.value = 1;
      getData();
    };
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: common_vendor.t(array.value[currentIndex.value]),
        b: common_vendor.o(bindPickerChange),
        c: currentIndex.value,
        d: array.value,
        e: common_vendor.f(list.value, (item, k0, i0) => {
          return common_vendor.e({
            a: common_vendor.t(item.dateTime),
            b: common_vendor.t(item.type == 1 ? "预警推送" : "学生轨迹"),
            c: item.userName
          }, item.userName ? {
            d: common_vendor.t(item.userName)
          } : {}, {
            e: item.typeName
          }, item.typeName ? {
            f: common_vendor.t(item.typeName)
          } : {}, {
            g: item.location
          }, item.location ? {
            h: common_vendor.t(item.location)
          } : {}, {
            i: item.image
          }, item.image ? {
            j: item.image,
            k: common_vendor.o(($event) => common_vendor.unref(utils_previewImage.previewImage)(item.image), item.id)
          } : {}, {
            l: item.id
          });
        }),
        f: !list.value.length
      }, !list.value.length ? {} : {});
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-b8003fe3"], ["__file", "E:/workSpace/WanZai_School_app/pages/msgWarn/msgWarn.vue"]]);
wx.createPage(MiniProgramPage);
