1
This commit is contained in:
@@ -236,21 +236,24 @@ const ListPageContent: React.FC<ListPageContentProps> = ({
|
||||
});
|
||||
|
||||
// 地址发生变化或不一致,重新加载数据和球局数量
|
||||
const promises: Promise<any>[] = [];
|
||||
if (refreshBothLists) {
|
||||
promises.push(refreshBothLists(currentArea));
|
||||
}
|
||||
if (fetchGetGamesCount) {
|
||||
promises.push(fetchGetGamesCount(currentArea));
|
||||
}
|
||||
Promise.all(promises).then(() => {
|
||||
// 数据加载完成后,更新记录的城市(记录为上一次在列表页加载数据时的城市)
|
||||
if (currentArea) {
|
||||
lastLoadedAreaRef.current = [...currentArea] as [string, string];
|
||||
// 先调用列表接口,然后在列表接口完成后调用数量接口
|
||||
(async () => {
|
||||
try {
|
||||
if (refreshBothLists) {
|
||||
await refreshBothLists();
|
||||
}
|
||||
// 列表接口完成后,再调用数量接口
|
||||
if (fetchGetGamesCount) {
|
||||
await fetchGetGamesCount();
|
||||
}
|
||||
// 数据加载完成后,更新记录的城市(记录为上一次在列表页加载数据时的城市)
|
||||
if (currentArea) {
|
||||
lastLoadedAreaRef.current = [...currentArea] as [string, string];
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("重新加载数据失败:", error);
|
||||
}
|
||||
}).catch((error) => {
|
||||
console.error("重新加载数据失败:", error);
|
||||
});
|
||||
})();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -312,9 +315,10 @@ const ListPageContent: React.FC<ListPageContentProps> = ({
|
||||
console.error("更新用户位置失败:", error);
|
||||
}
|
||||
}
|
||||
// 传入当前的 area,确保接口请求的地址与界面显示一致
|
||||
await fetchGetGamesCount(area);
|
||||
// 先调用列表接口
|
||||
await getMatchesData();
|
||||
// 列表接口完成后,再调用数量接口
|
||||
await fetchGetGamesCount();
|
||||
// 初始数据加载完成后,记录当前城市
|
||||
if (area && isActive) {
|
||||
lastLoadedAreaRef.current = [...area] as [string, string];
|
||||
|
||||
@@ -96,6 +96,12 @@ const MainPage: React.FC = () => {
|
||||
if (code === currentTab) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 切换标签时关闭城市选择器
|
||||
if (isCityPickerVisible) {
|
||||
setIsCityPickerVisible(false);
|
||||
}
|
||||
|
||||
setCurrentTab(code as TabType);
|
||||
// 切换标签时滚动到顶部
|
||||
(Taro as any).pageScrollTo({
|
||||
@@ -103,7 +109,7 @@ const MainPage: React.FC = () => {
|
||||
duration: 300,
|
||||
});
|
||||
},
|
||||
[currentTab]
|
||||
[currentTab, isCityPickerVisible]
|
||||
);
|
||||
|
||||
// 处理发布菜单显示/隐藏
|
||||
|
||||
Reference in New Issue
Block a user