优化全局下拉刷新

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,18 +1,8 @@
<template>
<view class="repair-page">
<!-- <view class="status_bar" :style="{ height: statusBarHeight + 'px' }"></view> -->
<!-- 顶部导航栏 -->
<!-- <view class="nav-bar">
<view class="nav-left" @tap="goBack">
<image src="https://wuyeadmin.bugtc.com/images/home/arr-left.png" style="width: 18px; height: 18px;"></image>
</view>
<view class="nav-title">在线报修</view>
<view class="nav-right"></view>
</view> -->
<!-- 报修类型Tab -->
<scroll-view class="scroll-container" scroll-y="true"
:lower-threshold="100" @scrolltolower="loadMore">
<view class="scroll-container">
<view class="repair-type-tabs">
<view
class="type-tab"
@@ -108,13 +98,13 @@
<text v-if="loading">加载中...</text>
<text v-else-if="!hasMoreData">没有更多数据了</text>
</view>
</scroll-view>
</view>
</view>
</template>
<script setup>
import { ref, watch, computed } from 'vue';
import { onLoad, onShow, onUnload } from '@dcloudio/uni-app';
import { onLoad, onShow, onUnload, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app';
import { getQueryRepair } from '../api/api.js';
// 报修类型public:公共报修personal:个人报修)
@@ -192,6 +182,7 @@ const fetchRepairList = async (reset = false) => {
uni.showToast({ title: '网络异常', icon: 'none' });
} finally {
loading.value = false;
uni.stopPullDownRefresh();
}
};
@@ -202,6 +193,16 @@ const loadMore = () => {
fetchRepairList();
};
// 下拉刷新
onPullDownRefresh(() => {
fetchRepairList(true);
});
// 上拉加载更多
onReachBottom(() => {
loadMore();
});
// 监听状态变化自动刷新(切换 tab 时重置到第一页)
watch(activeStatus, () => {
fetchRepairList(true);
@@ -259,10 +260,8 @@ onUnload(() =>{
/* 页面整体样式 */
.repair-page {
background: linear-gradient(to bottom left, #E2F0FF 0%, #f9f9f9 50%);
height: 100vh;
min-height: 100vh;
padding: 0 40rpx;
display: flex;
flex-direction: column;
}
.status_bar {
height: var(--status-bar-height);
@@ -307,9 +306,7 @@ onUnload(() =>{
}
/* 滚动区域 */
.scroll-container {
flex: 1;
width: 100%;
overflow-y: auto;
box-sizing: border-box;
}
/* 报修类型Tab */
@@ -324,7 +321,7 @@ onUnload(() =>{
flex-direction: column;
align-items: center;
justify-content: center;
height: 100px;
height: 85px;
border-radius: 8px;
color: #fff;
font-size: 14px;
@@ -474,10 +471,10 @@ onUnload(() =>{
display: flex;
flex-wrap: wrap;
margin: -6rpx;
margin-bottom: 4px;
margin-bottom: 16px;
}
.img-placeholder {
width: 80px;
width: 95px;
height: 80px;
background-color: #f5f5f5;
border-radius: 4px;

View File

@@ -654,9 +654,10 @@ textarea {
.time-item {
height: 80rpx;
line-height: 80rpx;
font-size: 28rpx;
font-size: 26rpx;
color: #BBBCBE;
position: relative;
white-space: nowrap;
}
/* 选中项样式(高亮) */

View File

@@ -274,7 +274,7 @@ const previewImage = (url) => {
}
.photo-item {
width: 80px;
width: 95px;
height: 80px;
border-radius: 4px;
display: flex;