diff --git a/hook/usePagination.js b/hook/usePagination.js index 1c1cda8..4152262 100644 --- a/hook/usePagination.js +++ b/hook/usePagination.js @@ -86,8 +86,7 @@ export function usePagination( const res = await requestFn(params) const rawData = res[dataKey] - const total = res[totalKey] || 99999999 - console.log(total, rawData) + const data = typeof transformFn === 'function' ? transformFn(rawData) : rawData if (type === 'refresh') { @@ -96,9 +95,9 @@ export function usePagination( list.value.push(...data) } + const total = res[totalKey] || list.value?.length pageState.total = total pageState.maxPage = Math.ceil(total / pageState.pageSize) - finished.value = list.value.length >= total empty.value = list.value.length === 0 } catch (err) { diff --git a/pages/index/components/index-two.vue b/pages/index/components/index-two.vue index e0ba7ea..686af83 100644 --- a/pages/index/components/index-two.vue +++ b/pages/index/components/index-two.vue @@ -93,7 +93,7 @@ const state = reactive({ // 响应式搜索条件(可以被修改) const searchParams = ref({}); const pageSize = ref(10); -const { list, loading, refresh, loadMore } = usePagination( +const { list, loading, refresh, loadMore,finished } = usePagination( (params) => $api.createRequest('/app/job/littleVideo', params), dataToImg, // 转换函数 { @@ -107,7 +107,10 @@ const { list, loading, refresh, loadMore } = usePagination( ); function imageloaded() { - loadmoreRef.value?.change('more'); + if(finished.value) loadmoreRef.value?.change('noMore'); + else loadmoreRef.value?.change('more'); + + } const { columnCount, columnSpace } = useColumnCount(() => {