优化全局下拉刷新

This commit is contained in:
zhouyanli
2026-08-20 15:41:27 +08:00
parent 325813c67e
commit ec66ed3076
19 changed files with 258 additions and 338 deletions

View File

@@ -1,20 +1,8 @@
<template>
<view class="page">
<!-- 滚动区域 -->
<pull-refresh-scroll
custom-class="scroll-box"
:refreshing="refreshing"
:loading-more="loadingMore"
:no-more-data="noMoreData"
:empty="revenueList.length === 0 && !loading"
empty-text="暂无通知"
no-more-text="没有更多通知了"
@refresh="onRefresh"
@load-more="loadMore"
>
<view class="list-wrap">
<!-- 列表 -->
<!-- 列表 -->
<view class="list-wrap">
<view
v-for="revenue in revenueList"
:key="revenue.noticeId"
@@ -30,18 +18,16 @@
<uni-icons type="right" size="13" color="#007AFF"/>
</view>
</view>
</view>
</pull-refresh-scroll>
</view>
</view>
</template>
<script setup>
import { ref } from 'vue'
import { onLoad ,onShow,onUnload} from '@dcloudio/uni-app'
import { onLoad, onShow, onUnload, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
import { getRevenueList } from '../api/apiSub.js'
const revenueList = ref([])
const refreshing = ref(false)
const loadingMore = ref(false)
const noMoreData = ref(false)
const loading = ref(false)
@@ -73,8 +59,8 @@ const loadRevenue = async (isRefresh = false) => {
} catch (e) {}
finally {
loading.value = false
refreshing.value = false
loadingMore.value = false
uni.stopPullDownRefresh()
}
}
// 更新单条已读状态
@@ -93,10 +79,13 @@ onShow(() =>{
loadRevenue(true)
})
const onRefresh = () => {
refreshing.value = true
onPullDownRefresh(() => {
loadRevenue(true)
}
})
onReachBottom(() => {
loadMore()
})
const loadMore = () => {
if (noMoreData.value || loadingMore.value) return
@@ -123,21 +112,7 @@ page {
background: #f9f9f9;
}
.page {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
display: flex;
flex-direction: column;
}
.status_bar {
width: 100%;
flex-shrink: 0;
}
.scroll-box {
flex: 1;
height: 0; /* 让滚动区域生效 */
min-height: 100vh;
}
.list-wrap {
padding: 50rpx 40rpx;