优化全局下拉刷新
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<view class="contentStyle" style="">
|
||||
|
||||
<scroll-view class="page" scroll-y="true" @scrolltolower="getList" refresher-enabled="true" :refresher-triggered="isRefreshing" @refresherrefresh="onRefresh">
|
||||
<view class="page">
|
||||
<view v-if="carList.length === 0" class="empty-state">
|
||||
<uni-icons type="info" size="60" color="#ccc"></uni-icons>
|
||||
<text class="empty-text">暂无数据</text>
|
||||
@@ -22,7 +22,7 @@
|
||||
{{ item.certificationStatus }}
|
||||
</view> -->
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
<view class="bottom-btn">
|
||||
<button class="confirm-btn" @click="addCar">添加车辆</button>
|
||||
</view>
|
||||
@@ -38,27 +38,27 @@
|
||||
getMyCarList
|
||||
} from '@/pageSubPack/api/apiSub.js'
|
||||
import {
|
||||
onShow
|
||||
onShow,
|
||||
onPullDownRefresh,
|
||||
onReachBottom
|
||||
} from '@dcloudio/uni-app'
|
||||
const statusBarHeight = ref(20)
|
||||
const defaultCarImg = "http://47.104.199.163:9090/images/propertyImgs/defaultCarImg.png"
|
||||
const carList = ref([])
|
||||
const loadingMore = ref(false)
|
||||
const noMoreData = ref(false)
|
||||
const isRefreshing = ref(false)
|
||||
|
||||
const pageNum = ref(1)
|
||||
const pageSize = ref(10)
|
||||
|
||||
// ==================== 下拉刷新 ====================
|
||||
const onRefresh = () => {
|
||||
isRefreshing.value = true
|
||||
onPullDownRefresh(() => {
|
||||
pageNum.value = 1
|
||||
noMoreData.value = false
|
||||
carList.value = []
|
||||
loadingMore.value = false
|
||||
getList()
|
||||
}
|
||||
})
|
||||
|
||||
// 页面加载时请求第一页
|
||||
onMounted(() => {
|
||||
@@ -107,14 +107,16 @@
|
||||
console.error('列表接口报错:', err)
|
||||
} finally {
|
||||
loadingMore.value = false
|
||||
// 关闭 refresher 下拉刷新状态
|
||||
if (isRefreshing.value) {
|
||||
isRefreshing.value = false
|
||||
}
|
||||
uni.stopPullDownRefresh()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ==================== 上拉加载更多 ====================
|
||||
onReachBottom(() => {
|
||||
getList()
|
||||
})
|
||||
|
||||
const getStatusText = (status) => {
|
||||
if (status === 0) return '未绑定'
|
||||
if (status === 1) return '已绑定'
|
||||
@@ -144,24 +146,16 @@
|
||||
<style lang="scss">
|
||||
page {
|
||||
background: #F3F8FD;
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style scoped>
|
||||
.contentStyle {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100vh;
|
||||
overflow: hidden;
|
||||
min-height: 100vh;
|
||||
background-color: #f5f7fa;
|
||||
}
|
||||
|
||||
.page {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
height: 0;
|
||||
overflow-y: auto;
|
||||
padding: 0px 40rpx 140rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user