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