优化城市选择死循环

This commit is contained in:
2025-11-19 16:53:40 +08:00
parent 5ecb352d1b
commit 07c41e7fa9

View File

@@ -60,17 +60,32 @@ function CityPicker(props) {
*/
const HomeNavbar = (props: IProps) => {
const { config, onCityPickerVisibleChange, onScrollToTop } = props;
const { showInput = false, inputLeftIcon, leftIconClick, title, showTitle = false } = config || {};
const {
showInput = false,
inputLeftIcon,
leftIconClick,
title,
showTitle = false,
} = config || {};
const { getLocationLoading, statusNavbarHeightInfo } = useGlobalState();
const { gamesNum, searchValue, cities, area, updateArea, fetchGetGamesCount, refreshBothLists } = useListState();
const { statusBarHeight = 0, navBarHeight = 44 } = statusNavbarHeightInfo || {};
const {
gamesNum,
searchValue,
cities,
area,
updateArea,
fetchGetGamesCount,
refreshBothLists,
} = useListState();
const { statusBarHeight = 0, navBarHeight = 44 } =
statusNavbarHeightInfo || {};
const [cityPopupVisible, setCityPopupVisible] = useState(false);
// 监听城市选择器状态变化,通知父组件
useEffect(() => {
onCityPickerVisibleChange?.(cityPopupVisible);
}, [cityPopupVisible, onCityPickerVisibleChange]);
}, [cityPopupVisible]);
const userInfo = useUserInfo();
const province = (userInfo as any)?.province || "";
@@ -148,13 +163,13 @@ const HomeNavbar = (props: IProps) => {
<View
className="homeNavbar"
style={{
position: 'fixed',
position: "fixed",
top: 0,
left: 0,
width: '100%',
height: `${ navBarHeight}px`,
width: "100%",
height: `${navBarHeight}px`,
paddingTop: `${statusBarHeight}px`,
backgroundColor: 'transparent',
backgroundColor: "transparent",
zIndex: 99,
}}
>
@@ -167,7 +182,7 @@ const HomeNavbar = (props: IProps) => {
</View>
</View>
)}
{/* 首页logo 导航*/}
{!showTitle && (
<View
@@ -175,30 +190,30 @@ const HomeNavbar = (props: IProps) => {
${!showInput ? "visible" : ""}`}
style={navbarStyle}
>
<View className="listNavContentWrapper">
{/* logo */}
<Image
src={img.ICON_LOGO}
className="listNavLogo"
onClick={handleLogoClick}
/>
<View className="listNavLine" />
<View className="listNavContent">
<View className="listNavCityWrapper" onClick={handleToggleCity}>
{/* 位置 */}
<Text className="listNavCity">{area_city}</Text>
{!getLocationLoading && area_city && (
<Image src={img.ICON_CHANGE} className="listNavChange" />
)}
</View>
<View className="listNavInfoWrapper">
<Text className="listNavInfo">{gamesNum}</Text>
<View className="listNavContentWrapper">
{/* logo */}
<Image
src={img.ICON_LOGO}
className="listNavLogo"
onClick={handleLogoClick}
/>
<View className="listNavLine" />
<View className="listNavContent">
<View className="listNavCityWrapper" onClick={handleToggleCity}>
{/* 位置 */}
<Text className="listNavCity">{area_city}</Text>
{!getLocationLoading && area_city && (
<Image src={img.ICON_CHANGE} className="listNavChange" />
)}
</View>
<View className="listNavInfoWrapper">
<Text className="listNavInfo">{gamesNum}</Text>
</View>
</View>
</View>
</View>
</View>
)}
{/* 搜索导航 */}
{!showTitle && (
<View
@@ -207,30 +222,30 @@ const HomeNavbar = (props: IProps) => {
} ${showInput ? "inputCustomerNavbarShowInput" : ""}`}
style={navbarStyle}
>
<View className="navContent">
{/* logo */}
<Image
src={inputLeftIcon || img.ICON_LIST_INPUT_LOGO}
className="logo"
onClick={handleInputLeftIconClick}
/>
{/* 搜索框 */}
<View className="searchContainer">
<View className="navContent">
{/* logo */}
<Image
className="searchIcon icon16"
src={img.ICON_LIST_SEARCH_SEARCH}
/>
<Input
placeholder="搜索球局和场地"
className="navbarInput"
clearable={false}
disabled
value={searchValue}
onClick={handleInputClick}
src={inputLeftIcon || img.ICON_LIST_INPUT_LOGO}
className="logo"
onClick={handleInputLeftIconClick}
/>
{/* 搜索框 */}
<View className="searchContainer">
<Image
className="searchIcon icon16"
src={img.ICON_LIST_SEARCH_SEARCH}
/>
<Input
placeholder="搜索球局和场地"
className="navbarInput"
clearable={false}
disabled
value={searchValue}
onClick={handleInputClick}
/>
</View>
</View>
</View>
</View>
)}
</View>
{cityPopupVisible && !showTitle && (