优化全局下拉刷新

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

@@ -13,7 +13,7 @@
<view class="page">
<view class="container">
<!-- /电费列表 -->
<scroll-view class="details-scroll" scroll-y="true" @scrolltolower="onPayLoadMore" :style="{ height: paymentList.length ? '550rpx' : '180rpx' }">
<scroll-view class="details-scroll" scroll-y="true" @scrolltolower="onPayLoadMore">
<view class="bill-list">
<template v-if="paymentList.length != 0">
<view class="bill-item" @click="goToBill(item)" v-for="item,index in paymentList" :key="index">
@@ -45,7 +45,7 @@
</view>
</scroll-view>
<!-- 物业费/垃圾处理费列表 -->
<scroll-view class="details-scroll-bill" scroll-y="true" @scrolltolower="onLoadMore" :style="{ height: detailslist.length ? '550rpx' : '180rpx' }">
<scroll-view class="details-scroll-bill" scroll-y="true" @scrolltolower="onLoadMore">
<view class="bill-list">
<template v-if="detailslist.length != 0">
<view class="bill-item" :class="{ 'bill-paid': !item.amount }" @click="!item.amount ? null : goToBill(item)" v-for="item,index in detailslist" :key="index">
@@ -100,7 +100,7 @@
<script setup>
import { ref } from 'vue'
import { onShow, onLoad, onBackPress, onUnload } from '@dcloudio/uni-app'
import { onShow, onLoad, onBackPress, onUnload, onPullDownRefresh } from '@dcloudio/uni-app'
import { getTopUpDetails, getTopUpSelectByResident } from '/pageSubPack/api/apiSub.js'
import { getCurrentVillage } from '/pageSubPack/api/api.js'
@@ -266,6 +266,8 @@ const getBillDetails = (isLoadMore = false) => {
pageNum.value--
loadingMore.value = false
}
}).finally(() => {
uni.stopPullDownRefresh();
})
}
const onLoadMore = () => {
@@ -307,12 +309,20 @@ const getPayList = async (isLoadMore = false) => {
title: err.msg || '网络异常',
icon: 'none'
})
} finally {
uni.stopPullDownRefresh();
}
}
const onPayLoadMore = () => {
getPayList(true)
}
// 下拉刷新:同时刷新水电费和物业费列表
onPullDownRefresh(() => {
getBillDetails();
getPayList();
});
</script>
<style lang="scss">
@@ -391,6 +401,8 @@ page {
background-color: #fff;
padding: 30rpx;
border-radius: 10rpx;
min-height: 550rpx;
box-sizing: border-box;
}
.bill-item {
@@ -576,7 +588,7 @@ page {
flex-direction: column;
align-items: center;
justify-content: center;
height: 120rpx;
height: 490rpx;
}
.empty-text {