分页下拉新增数据
This commit is contained in:
parent
2fe44259ae
commit
a6fcf0a629
|
|
@ -102,11 +102,7 @@
|
|||
</view>
|
||||
|
||||
<!-- 项目列表 -->
|
||||
<scroll-view
|
||||
class="project-scroll"
|
||||
scroll-y
|
||||
@scrolltolower="handleScrollToLower"
|
||||
>
|
||||
<view class="project-scroll">
|
||||
<view class="project-container">
|
||||
<view
|
||||
class="project-card"
|
||||
|
|
@ -197,13 +193,13 @@
|
|||
<text class="load-more-text">没有更多数据了</text>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, watch, onMounted, nextTick } from 'vue';
|
||||
import { onLoad } from '@dcloudio/uni-app';
|
||||
import { onLoad, onReachBottom, onPullDownRefresh } from '@dcloudio/uni-app';
|
||||
import { getProjectList, getUserList } from '@/api';
|
||||
import { usePagination } from '@/composables';
|
||||
import { useDictStore } from '@/store/dict';
|
||||
|
|
@ -513,8 +509,8 @@ const handleMemberChange = (e) => {
|
|||
|
||||
// 搜索
|
||||
const handleSearch = () => {
|
||||
reset();
|
||||
getList();
|
||||
// 使用 updateParams 更新查询参数,会自动重置页码并重新加载数据
|
||||
updateParams({});
|
||||
};
|
||||
|
||||
// 重置
|
||||
|
|
@ -528,15 +524,27 @@ const handleReset = () => {
|
|||
};
|
||||
selectedMemberName.value = '';
|
||||
activeStatusTab.value = 'IN_PROGRESS';
|
||||
handleSearch();
|
||||
// 使用 updateParams 更新查询参数,会自动重置页码并重新加载数据
|
||||
updateParams({});
|
||||
};
|
||||
|
||||
// 处理滚动到底部
|
||||
const handleScrollToLower = () => {
|
||||
// 上拉加载更多 - 使用 uniapp 的 onReachBottom
|
||||
onReachBottom(() => {
|
||||
if (!noMore.value && !loading.value) {
|
||||
loadMore();
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
// 下拉刷新 - 使用 uniapp 的 onPullDownRefresh
|
||||
onPullDownRefresh(async () => {
|
||||
try {
|
||||
// 重置并刷新数据
|
||||
await refresh();
|
||||
} finally {
|
||||
// 停止下拉刷新动画
|
||||
uni.stopPullDownRefresh();
|
||||
}
|
||||
});
|
||||
|
||||
// 跳转到项目详情
|
||||
const goToProjectDetail = (project) => {
|
||||
|
|
@ -581,7 +589,8 @@ onMounted(() => {
|
|||
onLoad(() => {
|
||||
nextTick(() => {
|
||||
isInitialized.value = true;
|
||||
handleSearch();
|
||||
// 初始化时直接调用 getList,使用 reset=true 重置列表
|
||||
getList(true);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user