优化全局下拉刷新
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
<!-- <view class="status-bar"></view>
|
||||
<uni-nav-bar title="我的车位" left-icon="left" @clickLeft="goBack" backgroundColor="transparent" :border="false">
|
||||
</uni-nav-bar> -->
|
||||
<scroll-view class="page" scroll-y="true" @scrolltolower="getList" refresher-enabled="true" :refresher-triggered="isRefreshing" @refresherrefresh="onRefresh">
|
||||
<view class="page">
|
||||
<view v-if="parkingSpaceList.length === 0" class="empty-state">
|
||||
<uni-icons type="info" size="60" color="#ccc"></uni-icons>
|
||||
<text class="empty-text">暂无数据</text>
|
||||
@@ -54,7 +54,7 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
<view class="bottom-btn">
|
||||
<button class="add-btn" @click="addParkingSpace">添加车位</button>
|
||||
</view>
|
||||
@@ -66,7 +66,9 @@
|
||||
ref
|
||||
} from 'vue'
|
||||
import {
|
||||
onShow
|
||||
onShow,
|
||||
onPullDownRefresh,
|
||||
onReachBottom
|
||||
} from '@dcloudio/uni-app'
|
||||
import {
|
||||
getCarList
|
||||
@@ -76,14 +78,13 @@
|
||||
const parkingSpaceList = ref([])
|
||||
|
||||
// ==================== 下拉刷新 ====================
|
||||
const onRefresh = () => {
|
||||
isRefreshing.value = true
|
||||
onPullDownRefresh(() => {
|
||||
pageNum.value = 1
|
||||
noMoreData.value = false
|
||||
parkingSpaceList.value = []
|
||||
loadingMore.value = false
|
||||
getList()
|
||||
}
|
||||
})
|
||||
|
||||
// 页面显示时请求第一页(首次进入和从详情/修改页返回时都会刷新)
|
||||
onShow(() => {
|
||||
@@ -96,7 +97,6 @@
|
||||
|
||||
const loadingMore = ref(false)
|
||||
const noMoreData = ref(false)
|
||||
const isRefreshing = ref(false)
|
||||
|
||||
const pageNum = ref(1)
|
||||
const pageSize = ref(10)
|
||||
@@ -148,13 +148,15 @@
|
||||
console.error('列表接口报错:', err)
|
||||
} finally {
|
||||
loadingMore.value = false
|
||||
// 关闭 refresher 下拉刷新状态
|
||||
if (isRefreshing.value) {
|
||||
isRefreshing.value = false
|
||||
}
|
||||
uni.stopPullDownRefresh()
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 上拉加载更多 ====================
|
||||
onReachBottom(() => {
|
||||
getList()
|
||||
})
|
||||
|
||||
const tapParkingSpace = (item) => {
|
||||
console.log(item);
|
||||
uni.navigateTo({
|
||||
@@ -187,15 +189,11 @@
|
||||
}
|
||||
|
||||
.contentStyle {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100vh;
|
||||
min-height: 100vh;
|
||||
background-color: #f5f7fa;
|
||||
}
|
||||
|
||||
.page {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 0px 40rpx 140rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user