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