2025-08-21 09:35:13 +08:00
|
|
|
<template>
|
|
|
|
|
<view class="container">
|
2025-08-25 17:56:17 +08:00
|
|
|
<view v-for="item in list" :key="item.id" class="item">
|
2025-08-21 09:35:13 +08:00
|
|
|
<uni-card :extra="item.createTime" :title="item.title" @click="detail(item)"></uni-card>
|
|
|
|
|
</view>
|
2025-08-25 17:56:17 +08:00
|
|
|
|
2025-08-26 09:25:40 +08:00
|
|
|
<!-- 分页组件 -->
|
|
|
|
|
<pagination
|
|
|
|
|
:current-page="pagination.currentPage"
|
|
|
|
|
:list="list"
|
|
|
|
|
:loading="loading"
|
|
|
|
|
:mode="'loadMore'"
|
|
|
|
|
:no-more="noMore"
|
|
|
|
|
:page-size="pagination.pageSize"
|
|
|
|
|
:total="pagination.total"
|
|
|
|
|
@page-change="handlePageChange"
|
|
|
|
|
/>
|
2025-08-21 09:35:13 +08:00
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup>
|
2025-08-26 09:25:40 +08:00
|
|
|
import { onMounted } from 'vue'
|
2025-08-21 09:35:13 +08:00
|
|
|
import { getArticleList } from '@/api/article/article.js'
|
2025-08-26 09:25:40 +08:00
|
|
|
import { onReachBottom } from '@dcloudio/uni-app'
|
|
|
|
|
import { usePagination } from '@/composables/usePagination.js'
|
2025-08-26 09:38:47 +08:00
|
|
|
import Pagination from '@/components/pagination/pagination.vue'
|
2025-08-26 09:25:40 +08:00
|
|
|
|
|
|
|
|
// 使用分页组合式函数
|
|
|
|
|
const { list, loading, noMore, pagination, getList, loadMore } = usePagination({
|
|
|
|
|
fetchData: getArticleList,
|
|
|
|
|
defaultParams: {},
|
|
|
|
|
mode: 'loadMore',
|
2025-08-26 10:57:33 +08:00
|
|
|
pageSize: 15,
|
2025-08-26 09:25:40 +08:00
|
|
|
})
|
2025-08-21 09:35:13 +08:00
|
|
|
|
2025-08-25 17:56:17 +08:00
|
|
|
const detail = item => {
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
url: `/pages/announcementList/announcementDetail?id=${item.id}&title=${encodeURIComponent(item.title)}&content=${encodeURIComponent(item.content)}&createTime=${encodeURIComponent(item.createTime)}`,
|
2025-08-21 09:35:13 +08:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 页面加载时获取数据
|
|
|
|
|
onMounted(() => {
|
2025-08-25 17:56:17 +08:00
|
|
|
getList()
|
|
|
|
|
})
|
|
|
|
|
|
2025-08-26 09:25:40 +08:00
|
|
|
// 上拉加载更多
|
2025-08-25 17:56:17 +08:00
|
|
|
onReachBottom(() => {
|
2025-08-26 10:57:33 +08:00
|
|
|
console.log('触发上拉加载更多,当前状态:', {
|
|
|
|
|
loading: loading.value,
|
|
|
|
|
noMore: noMore.value,
|
2025-08-26 09:38:47 +08:00
|
|
|
listLength: list.value.length,
|
2025-08-26 10:57:33 +08:00
|
|
|
total: pagination.value.total,
|
2025-08-26 09:38:47 +08:00
|
|
|
})
|
2025-08-26 09:25:40 +08:00
|
|
|
loadMore()
|
2025-08-21 09:35:13 +08:00
|
|
|
})
|
2025-08-26 09:25:40 +08:00
|
|
|
|
|
|
|
|
// 处理页码变化
|
|
|
|
|
const handlePageChange = page => {
|
|
|
|
|
console.log('页码变化:', page)
|
|
|
|
|
}
|
2025-08-21 09:35:13 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.container {
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
padding: 20rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.item {
|
|
|
|
|
margin-bottom: 20rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.uni-body {
|
|
|
|
|
font-size: 28rpx;
|
|
|
|
|
line-height: 1.6;
|
|
|
|
|
color: #666;
|
|
|
|
|
}
|
2025-08-25 17:56:17 +08:00
|
|
|
|
|
|
|
|
.load-more {
|
|
|
|
|
margin-top: 20rpx;
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
|
|
|
|
.no-more-text {
|
|
|
|
|
font-size: 24rpx;
|
|
|
|
|
color: #999;
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-08-21 09:35:13 +08:00
|
|
|
</style>
|