فهرست منبع

fix: 修复数据统计页面下拉刷新回弹失效问题

将下拉刷新从 ScrollView 组件级刷新改为 Taro 页面级 API:
- 移除 refresherTriggered 状态控制
- 使用 Taro.usePullDownRefresh() 钩子监听下拉刷新事件
- 使用 Taro.stopPullDownRefresh() 停止刷新动画
- 移除 ScrollView 的 refresher 相关属性

页面配置已启用 enablePullDownRefresh: true,使用微信小程序原生
控制刷新回弹,避免回弹失效问题。

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
yourname 1 روز پیش
والد
کامیت
351500a7f3
1فایلهای تغییر یافته به همراه7 افزوده شده و 8 حذف شده
  1. 7 8
      mini/src/pages/yongren/statistics/index.tsx

+ 7 - 8
mini/src/pages/yongren/statistics/index.tsx

@@ -1,5 +1,6 @@
 import React, { useState, useEffect, memo } from 'react'
 import { View, Text, ScrollView } from '@tarojs/components'
+import Taro from '@tarojs/taro'
 import { useQuery, useQueryClient } from '@tanstack/react-query'
 import { YongrenTabBarLayout } from '@/components/YongrenTabBarLayout'
 import { Navbar } from '@d8d/mini-shared-ui-components/components/navbar'
@@ -96,9 +97,6 @@ const Statistics: React.FC<StatisticsProps> = () => {
     return isSuccessfulResponse(data) ? data.stats : []
   }
 
-  // 状态:下拉刷新控制
-  const [refresherTriggered, setRefresherTriggered] = useState(false)
-
   // 图表懒加载效果:逐步加载其他图表
   useEffect(() => {
     const timer1 = setTimeout(() => {
@@ -115,6 +113,11 @@ const Statistics: React.FC<StatisticsProps> = () => {
     }
   }, [])
 
+  // 使用 Taro 页面级下拉刷新钩子
+  Taro.usePullDownRefresh(async () => {
+    await handleRefresh()
+  })
+
   // 下拉刷新处理函数:刷新所有统计数据
   const handleRefresh = async () => {
     console.log('🔄 [下拉刷新] 开始刷新所有统计数据...')
@@ -136,7 +139,7 @@ const Statistics: React.FC<StatisticsProps> = () => {
       console.error('🔄 [下拉刷新] 发生错误:', error)
     } finally {
       console.log('🔄 [下拉刷新] 结束刷新状态')
-      setRefresherTriggered(false)
+      Taro.stopPullDownRefresh()
     }
   }
 
@@ -250,10 +253,6 @@ const Statistics: React.FC<StatisticsProps> = () => {
       <ScrollView
         className="h-[calc(100%-60px)] overflow-y-auto px-4 pb-16 pt-0"
         scrollY
-        refresherEnabled
-        refresherTriggered={refresherTriggered}
-        onRefresherRefresh={handleRefresh}
-        refresherBackground="#f5f5f5"
       >
         {/* 导航栏 */}
         <Navbar