81 lines
2.8 KiB
JavaScript
Raw Permalink Normal View History

2025-12-15 18:27:46 +08:00
"use strict";
const common_vendor = require("../../vendor.js");
if (!Array) {
const _easycom_hs_empty2 = common_vendor.resolveComponent("hs-empty");
const _easycom_u_loading_icon2 = common_vendor.resolveComponent("u-loading-icon");
(_easycom_hs_empty2 + _easycom_u_loading_icon2)();
}
const _easycom_hs_empty = () => "../../../components/hs-empty/hs-empty.js";
const _easycom_u_loading_icon = () => "../../../node-modules/uview-plus/components/u-loading-icon/u-loading-icon.js";
if (!Math) {
(_easycom_hs_empty + _easycom_u_loading_icon)();
}
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
__name: "cc-scroll-loading",
props: {
meta: {
type: Object,
default: {}
// 参数
},
showLoad: {
type: Boolean,
default: true
// 是否显示加载状态
}
},
emits: ["load"],
setup(__props, { emit }) {
const props = __props;
const loadingStatusTest = common_vendor.ref("");
const loadingStatus = common_vendor.ref(false);
const params = common_vendor.ref({
page: 1,
perPage: 20
});
common_vendor.watch(
() => props == null ? void 0 : props.meta,
() => {
const { current_page, last_page } = props.meta;
const hasNextPage = current_page < last_page;
loadingStatus.value = hasNextPage;
loadingStatusTest.value = hasNextPage ? "上拉加载更多" : "已经到底啦~";
console.log(props == null ? void 0 : props.meta, "meta数据变化");
}
);
const handleLoad = () => {
const { current_page, last_page } = props.meta;
const hasNextPage = current_page < last_page;
loadingStatus.value = hasNextPage;
loadingStatusTest.value = hasNextPage ? "上拉加载更多" : "已经到底啦~";
if (hasNextPage) {
params.value.page = current_page + 1;
emit("load", params.value);
setTimeout(() => {
loadingStatus.value = false;
loadingStatusTest.value = "";
}, 1e3);
}
};
common_vendor.onReachBottom(handleLoad);
return (_ctx, _cache) => {
var _a, _b;
return common_vendor.e({
a: !((_a = props.meta) == null ? void 0 : _a.total)
}, !((_b = props.meta) == null ? void 0 : _b.total) ? {} : common_vendor.e({
b: common_vendor.p({
text: loadingStatusTest.value,
mode: "circle",
size: "30rpx",
show: loadingStatus.value
}),
c: !loadingStatus.value
}, !loadingStatus.value ? {
d: common_vendor.t(loadingStatusTest.value)
} : {}));
};
}
});
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-60d51fde"], ["__file", "/Users/zsq/Sources/github/2025property-pay/pay-employee/src/common/components/cc-scroll-loading/cc-scroll-loading.vue"]]);
wx.createComponent(Component);