From 49f53d60edb0718d5d05443076f7a4cc5ae856af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E7=91=9E?= Date: Fri, 6 Feb 2026 22:37:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86=E5=88=97=E8=A1=A8=E8=AF=B7?= =?UTF-8?q?=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main_pages/components/ListPageContent.tsx | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/main_pages/components/ListPageContent.tsx b/src/main_pages/components/ListPageContent.tsx index 986fbf7..2c6d20f 100644 --- a/src/main_pages/components/ListPageContent.tsx +++ b/src/main_pages/components/ListPageContent.tsx @@ -63,6 +63,7 @@ const ListPageContent: React.FC = ({ area, cityQrCode, districts, + fetchMatches, gamesNum, // 新增:获取球局数量 } = store; @@ -77,6 +78,7 @@ const ListPageContent: React.FC = ({ pageOption, isShowNoData, } = listPageState || {}; + console.log('===matches', matches) const scrollContextRef = useRef(null); const scrollViewRef = useRef(null); @@ -92,6 +94,8 @@ const ListPageContent: React.FC = ({ // 记录上一次加载数据时的城市,用于检测城市变化 const lastLoadedAreaRef = useRef<[string, string] | null>(null); const prevIsActiveRef = useRef(isActive); + // 首次加载标记:避免切回 tab 时使用 isRefresh 导致智能排序顺序抖动 + const hasLoadedOnceRef = useRef(false); // 处理距离筛选显示/隐藏 const handleDistanceFilterVisibleChange = useCallback( @@ -230,9 +234,16 @@ const ListPageContent: React.FC = ({ // 只有当页面激活时才加载位置和列表数据 if (isActive) { - getLocation().catch((error) => { - console.error('获取位置信息失败:', error); - }); + const firstLoad = !hasLoadedOnceRef.current; + getLocation(firstLoad) + .then(() => { + if (firstLoad) { + hasLoadedOnceRef.current = true; + } + }) + .catch((error) => { + console.error('获取位置信息失败:', error); + }); } }, [isActive]); @@ -359,7 +370,7 @@ const ListPageContent: React.FC = ({ }; }, []); - const getLocation = async () => { + const getLocation = async (useRefresh = true) => { const location = await getCurrentLocationInfo(); updateState({ location }); if (location && location.latitude && location.longitude) { @@ -370,7 +381,7 @@ const ListPageContent: React.FC = ({ } } // 先调用列表接口 - await getMatchesData(); + await fetchMatches({}, useRefresh); // 列表接口完成后,再调用数量接口 await fetchGetGamesCount(); // 初始数据加载完成后,记录当前城市