Newer
Older
XiaoGanWXMini / unpackage / dist / dev / mp-weixin / pages / forum / index.js
@zhangdeliang zhangdeliang on 29 Jul 3 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: "index",
  setup(__props) {
    const forumData = common_vendor.ref([]);
    const triggered = common_vendor.ref(false);
    const pageNum = common_vendor.ref(1);
    const pageSize = common_vendor.ref(4);
    const total = common_vendor.ref(0);
    function scrolltolower() {
      console.log("向上加载--");
      if (forumData.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;
      forumData.value = [];
      getDataList();
      setTimeout(() => {
        triggered.value = false;
      }, 1e3);
    }
    function getDataList() {
      utils_homeApi.wechartSuggestList({ pageNum: pageNum.value, pageSize: pageSize.value }).then((res) => {
        forumData.value = forumData.value.concat(res.data || []);
        total.value = res.total;
      });
    }
    function previewImg(url) {
      common_vendor.index.previewImage({
        urls: [url]
        //需要预览的图片http链接列表,多张的时候,url直接写在后面就行了
      });
    }
    common_vendor.onLoad((e) => {
      forumData.value = [];
      getDataList();
    });
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: forumData.value.length > 0
      }, forumData.value.length > 0 ? {
        b: common_vendor.f(forumData.value, (item, index, i0) => {
          return common_vendor.e({
            a: item.orderStatus == 0
          }, item.orderStatus == 0 ? {
            b: common_assets._imports_0$2
          } : {}, {
            c: item.orderStatus == 1
          }, item.orderStatus == 1 ? {
            d: common_assets._imports_1
          } : {}, {
            e: item.headImg ? item.headImg : common_vendor.unref(common_assets.defaultHeadImg),
            f: common_vendor.t(item.nickName),
            g: common_vendor.t(item.happenTime),
            h: common_vendor.t(item.describ),
            i: item.complaintPhotosFileList.length > 0
          }, item.complaintPhotosFileList.length > 0 ? {
            j: common_vendor.f(item.complaintPhotosFileList, (img, k1, i1) => {
              return {
                a: img.url,
                b: img.id,
                c: common_vendor.o(($event) => previewImg(img.url), img.id)
              };
            })
          } : {}, {
            k: index
          });
        }),
        c: common_vendor.o(scrolltolower),
        d: triggered.value,
        e: common_vendor.o(onRefresh)
      } : {}, {
        f: forumData.value.length == 0
      }, forumData.value.length == 0 ? {
        g: common_assets._imports_0
      } : {});
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "E:/项目/孝感海绵城市/XiaoGanWXMini/pages/forum/index.vue"]]);
wx.createPage(MiniProgramPage);