Newer
Older
XiaoGanWXMini / unpackage / dist / dev / mp-weixin / pages / projectHM / project.js
@zhangdeliang zhangdeliang on 29 Jul 2 KB 迁移
"use strict";
const common_vendor = require("../../common/vendor.js");
const common_assets = require("../../common/assets.js");
const utils_homeApi = require("../../utils/homeApi.js");
const _sfc_main = {
  __name: "project",
  setup(__props) {
    const projectList = common_vendor.ref([]);
    const triggered = common_vendor.ref(false);
    const pageNum = common_vendor.ref(1);
    const pageSize = common_vendor.ref(8);
    const total = common_vendor.ref(0);
    function scrolltolower() {
      console.log("向上加载--");
      if (projectList.value.length < total.value) {
        pageNum.value += 1;
        getDataList();
      } else {
        common_vendor.index.showToast({
          title: "已经到底,没有更多了",
          icon: "none"
        });
        return;
      }
    }
    function onRefresh() {
      console.log("下拉刷新--");
      triggered.value = true;
      pageNum.value = 1;
      projectList.value = [];
      getDataList();
      setTimeout(() => {
        triggered.value = false;
      }, 1e3);
    }
    function getDataList() {
      utils_homeApi.projectInfoPage({ pageNum: pageNum.value, pageSize: pageSize.value, wechatMiniuserId: common_vendor.index.getStorageSync("userIdXGWXMN") }).then((res) => {
        projectList.value = projectList.value.concat(res.data || []);
        total.value = res.total;
      });
    }
    function checkDetail(item) {
      let obj = {
        sysFileList: item.sysFileList,
        projectName: item.projectName,
        projectOverview: item.projectOverview,
        projectLocation: item.projectLocation,
        collectStatus: item.collectStatus,
        id: item.id
      };
      localStorage.setItem("xgProjectObj", JSON.stringify(obj));
      common_vendor.index.navigateTo({
        url: `./detail`
      });
    }
    common_vendor.onShow(() => {
      projectList.value = [];
      getDataList();
    });
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: projectList.value.length > 0
      }, projectList.value.length > 0 ? {
        b: common_vendor.f(projectList.value, (item, k0, i0) => {
          return {
            a: item.sysFileList.length > 0 ? item.sysFileList[0].url : "",
            b: common_vendor.t(item.projectName),
            c: item.id,
            d: common_vendor.o(($event) => checkDetail(item), item.id)
          };
        }),
        c: common_vendor.o(scrolltolower),
        d: triggered.value,
        e: common_vendor.o(onRefresh)
      } : {}, {
        f: projectList.value.length == 0
      }, projectList.value.length == 0 ? {
        g: common_assets._imports_0
      } : {});
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "E:/项目/孝感海绵城市/XiaoGanWXMini/pages/projectHM/project.vue"]]);
wx.createPage(MiniProgramPage);