优化全局下拉刷新

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

@@ -9,7 +9,7 @@
</view>
<!-- 列表区域 -->
<scroll-view class="page" scroll-y>
<view class="page">
<view class="page-container">
<view v-if="dataList.length === 0" class="empty-state">
<uni-icons type="info" size="30" color="#ccc"></uni-icons>
@@ -42,7 +42,7 @@
</view>
</view>
</view>
</scroll-view>
</view>
<!-- 底部按钮 -->
<view class="bottom-btn-wrap">
@@ -53,7 +53,7 @@
<script setup>
import { ref, onMounted } from 'vue'
import {onLoad, onShow} from '@dcloudio/uni-app'
import {onLoad, onShow, onPullDownRefresh} from '@dcloudio/uni-app'
import {getComplainList} from '../api/apiSub.js'
// 分段器
@@ -111,6 +111,8 @@ const getComplainListData = async () =>{
}catch(err){
// console.log('dess',err)
uni.showToast({title:err.msg || '网络异常',icon:'error'})
}finally{
uni.stopPullDownRefresh();
}
}
onLoad(() =>{
@@ -118,7 +120,11 @@ onLoad(() =>{
})
onShow(() => {
getComplainListData()
})
});
onPullDownRefresh(() => {
getComplainListData();
});
// 跳转到详情
const turnToDetail = (item) => {
@@ -149,16 +155,12 @@ const addComplaintsSuggestions = () => {
<style scoped>
.contentStyle {
display: flex;
flex-direction: column;
height: 100%;
min-height: 100vh;
background: linear-gradient(to left bottom, #e2efff 0%, #f9f9f9 50%);
}
.page {
flex: 1;
overflow-y: auto;
padding: 0px 40rpx;
padding: 0px 40rpx 200rpx;
box-sizing: border-box;
}
@@ -183,6 +185,10 @@ const addComplaintsSuggestions = () => {
}
.tab-wrap {
position: sticky;
top: 0;
z-index: 10;
background: #e2efff;
display: flex;
justify-content: flex-start;
align-items: center;
@@ -310,9 +316,15 @@ const addComplaintsSuggestions = () => {
}
.bottom-btn-wrap {
position: fixed;
bottom: 0;
left: 0;
right: 0;
z-index: 10;
padding: 20rpx 30rpx 40rpx;
display: flex;
gap: 20rpx;
background: #f9f9f9;
}
.next-btn {

View File

@@ -6,7 +6,7 @@
</view>
<!-- 表单区域 -->
<scroll-view class="page" scroll-y>
<view class="page">
<view class="list-container">
<view v-if="currentList.length === 0" class="empty-state">
<uni-icons type="info" size="30" color="#ccc"></uni-icons>
@@ -43,13 +43,13 @@
</view>
</view>
<view style="width: 100%;height:2rpx;"></view>
</scroll-view>
</view>
</view>
</template>
<script setup>
import { ref, computed } from 'vue'
import { onShow } from '@dcloudio/uni-app'
import { onShow,onPullDownRefresh } from '@dcloudio/uni-app'
import {getQuestionnaireList} from '../api/apiSub.js'
// 状态栏高度
@@ -102,7 +102,9 @@
}
}catch(err){
uni.showToast({ title: err.msg ||'网络异常', icon: 'none' })
}
}finally{
uni.stopPullDownRefresh();
}
}
// 列表项点击index 控制高亮)
@@ -131,10 +133,13 @@
})
}
// 生命周期:每次显示时刷新数据
onShow(() => {
getDataList()
})
// 下拉刷新
onPullDownRefresh(() => {
getDataList();
});
</script>
<style lang="scss">
@@ -145,9 +150,10 @@
<style lang="scss" scoped>
.contentStyle {
display: flex;
flex-direction: column;
height: 100%;
// display: flex;
// flex-direction: column;
min-height: 100%;
// height: 100%;
background: linear-gradient(to left bottom, #e2efff 0%, #f9f9f9 50%);
}