"use strict";
const common_vendor = require("../../common/vendor.js");
const api_apis = require("../../api/apis.js");
if (!Array) {
  const _easycom_uni_load_more2 = common_vendor.resolveComponent("uni-load-more");
  _easycom_uni_load_more2();
}
const _easycom_uni_load_more = () => "../../uni_modules/uni-load-more/components/uni-load-more/uni-load-more.js";
if (!Math) {
  _easycom_uni_load_more();
}
const _sfc_main = {
  __name: "classlist",
  setup(__props) {
    const classList = common_vendor.ref([]);
    const noData = common_vendor.ref(false);
    const queryParams = {
      pageNum: 1,
      pageSize: 12
    };
    let pageName;
    common_vendor.onLoad((e) => {
      let { id = null, name = null, type = null } = e;
      if (id) {
        queryParams.id = id;
      }
      if (type) {
        queryParams.type = type;
      }
      pageName = name;
      common_vendor.index.setNavigationBarTitle({
        title: name
      });
      getClassList();
    });
    common_vendor.onUnload(() => {
      common_vendor.index.removeStorageSync("storgClassList");
    });
    common_vendor.onReachBottom(() => {
      if (noData.value) {
        return;
      }
      queryParams.pageNum++;
      getClassList();
    });
    const getClassList = async () => {
      let res;
      if (queryParams.id) {
        res = await api_apis.apiGetClassList({
          // queryParams
          classid: queryParams.id,
          pageNum: queryParams.pageNum,
          pageSize: queryParams.pageSize
          // classid:"6524ace7213929cbcee72e4d"
        });
      }
      if (queryParams.type) {
        res = await api_apis.apiGetHistoryList({
          // queryParams
          type: queryParams.type,
          pageNum: queryParams.pageNum,
          pageSize: queryParams.pageSize
        });
      }
      classList.value = [...classList.value, ...res.data];
      if (queryParams.pageSize > res.data.length) {
        noData.value = true;
      }
      common_vendor.index.setStorageSync("storgClassList", classList.value);
    };
    common_vendor.onShareAppMessage((e) => {
      return {
        title: "hzb壁纸-" + pageName,
        // 必须传递id进去，否则进不去内部页面
        path: "/pages/classlist/classlist?id=" + queryParams.id + "&name=" + pageName
      };
    });
    common_vendor.onShareTimeline(() => {
      return {
        // 标题
        title: "hzb壁纸~~~",
        // 分享时候的图片地址。可以本地也可以网络图
        // imageUrl:"/static/images/logo2.jpg"
        //要想看朋友圈这个，需要带的query参数
        query: "id=" + queryParams.id + "&name=" + pageName
      };
    });
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: !classList.value.length && !noData.value
      }, !classList.value.length && !noData.value ? {
        b: common_vendor.p({
          status: "loading"
        })
      } : {}, {
        c: common_vendor.f(classList.value, (item, k0, i0) => {
          return {
            a: item.smallPicurl,
            b: "/pages/preview/preview?id=" + item._id,
            c: item._id
          };
        }),
        d: classList.value.length || noData.value
      }, classList.value.length || noData.value ? {
        e: common_vendor.p({
          status: noData.value ? "noMore" : "loading"
        })
      } : {});
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-bd381383"]]);
_sfc_main.__runtimeHooks = 6;
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/classlist/classlist.js.map
