1
This commit is contained in:
@@ -28,7 +28,7 @@ const GeneralNavbar: React.FC<GeneralNavbarProps> = ({
|
|||||||
titleClassName = '',
|
titleClassName = '',
|
||||||
leftContent,
|
leftContent,
|
||||||
rightContent,
|
rightContent,
|
||||||
backgroundColor = '#fafafa', // 默认背景色改为 #fafafa
|
backgroundColor = 'transparent', // 默认背景色为透明
|
||||||
showBack = true,
|
showBack = true,
|
||||||
showLeft = true,
|
showLeft = true,
|
||||||
showAvatar = false,
|
showAvatar = false,
|
||||||
@@ -106,11 +106,16 @@ const GeneralNavbar: React.FC<GeneralNavbarProps> = ({
|
|||||||
className={`${styles.customNavbar} ${className}`}
|
className={`${styles.customNavbar} ${className}`}
|
||||||
style={{
|
style={{
|
||||||
height: `${totalHeight}px`,
|
height: `${totalHeight}px`,
|
||||||
paddingTop: `${statusBarHeight}px`,
|
|
||||||
backgroundColor: backgroundColor || 'transparent'
|
backgroundColor: backgroundColor || 'transparent'
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<View className={styles.navbarContent} style={{ height: `${navBarHeight}px` }}>
|
<View
|
||||||
|
className={styles.navbarContent}
|
||||||
|
style={{
|
||||||
|
height: `${navBarHeight}px`,
|
||||||
|
marginTop: `${statusBarHeight}px`
|
||||||
|
}}
|
||||||
|
>
|
||||||
<View className={styles.leftSection}>
|
<View className={styles.leftSection}>
|
||||||
{renderLeftContent()}
|
{renderLeftContent()}
|
||||||
{titlePosition === 'left' && renderTitle()}
|
{titlePosition === 'left' && renderTitle()}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import img from "@/config/images";
|
|||||||
import { useGlobalState } from "@/store/global";
|
import { useGlobalState } from "@/store/global";
|
||||||
import { useUserInfo } from "@/store/userStore";
|
import { useUserInfo } from "@/store/userStore";
|
||||||
import { useListState } from "@/store/listStore";
|
import { useListState } from "@/store/listStore";
|
||||||
import CustomNavbar from "@/components/CustomNavbar";
|
|
||||||
import { Input } from "@nutui/nutui-react-taro";
|
import { Input } from "@nutui/nutui-react-taro";
|
||||||
import Taro from "@tarojs/taro";
|
import Taro from "@tarojs/taro";
|
||||||
import "./index.scss";
|
import "./index.scss";
|
||||||
@@ -52,12 +51,19 @@ function CityPicker(props) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const ListHeader = (props: IProps) => {
|
/**
|
||||||
|
* 首页专用导航栏组件
|
||||||
|
* 支持三种模式:
|
||||||
|
* 1. Logo + 城市选择 + 球局数量(默认模式)
|
||||||
|
* 2. 搜索输入框模式(showInput = true)
|
||||||
|
* 3. 标题模式(showTitle = true,用于"我的"页面等)
|
||||||
|
*/
|
||||||
|
const HomeNavbar = (props: IProps) => {
|
||||||
const { config, onCityPickerVisibleChange, onScrollToTop } = props;
|
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 { getLocationLoading, statusNavbarHeightInfo } = useGlobalState();
|
||||||
const { gamesNum, searchValue, cities, area, updateArea, getMatchesData, fetchGetGamesCount, refreshBothLists } = useListState();
|
const { gamesNum, searchValue, cities, area, updateArea, fetchGetGamesCount, refreshBothLists } = useListState();
|
||||||
const { navBarHeight } = statusNavbarHeightInfo;
|
const { statusBarHeight = 0, navBarHeight = 44 } = statusNavbarHeightInfo || {};
|
||||||
|
|
||||||
const [cityPopupVisible, setCityPopupVisible] = useState(false);
|
const [cityPopupVisible, setCityPopupVisible] = useState(false);
|
||||||
|
|
||||||
@@ -80,9 +86,9 @@ const ListHeader = (props: IProps) => {
|
|||||||
const handleInputClick = () => {
|
const handleInputClick = () => {
|
||||||
const currentPagePath = getCurrentFullPath();
|
const currentPagePath = getCurrentFullPath();
|
||||||
if (currentPagePath === "/game_pages/searchResult/index") {
|
if (currentPagePath === "/game_pages/searchResult/index") {
|
||||||
Taro.navigateBack();
|
(Taro as any).navigateBack();
|
||||||
} else {
|
} else {
|
||||||
Taro.navigateTo({
|
(Taro as any).navigateTo({
|
||||||
url: "/game_pages/search/index",
|
url: "/game_pages/search/index",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -97,13 +103,13 @@ const ListHeader = (props: IProps) => {
|
|||||||
onScrollToTop();
|
onScrollToTop();
|
||||||
} else {
|
} else {
|
||||||
// 降级方案:使用页面滚动(兼容旧版本)
|
// 降级方案:使用页面滚动(兼容旧版本)
|
||||||
Taro.pageScrollTo({
|
(Taro as any).pageScrollTo({
|
||||||
scrollTop: 0,
|
scrollTop: 0,
|
||||||
duration: 300,
|
duration: 300,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Taro.redirectTo({
|
(Taro as any).redirectTo({
|
||||||
url: "game_pages/list/index", // 列表页
|
url: "game_pages/list/index", // 列表页
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -127,7 +133,7 @@ const ListHeader = (props: IProps) => {
|
|||||||
const area_city = area.at(-1);
|
const area_city = area.at(-1);
|
||||||
|
|
||||||
// 处理城市切换
|
// 处理城市切换
|
||||||
const handleCityChange = async (newArea: any) => {
|
const handleCityChange = async (_newArea: any) => {
|
||||||
// 切换城市后,同时更新两个列表接口获取数据
|
// 切换城市后,同时更新两个列表接口获取数据
|
||||||
if (refreshBothLists) {
|
if (refreshBothLists) {
|
||||||
await refreshBothLists();
|
await refreshBothLists();
|
||||||
@@ -139,7 +145,19 @@ const ListHeader = (props: IProps) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CustomNavbar backgroundColor="#fafafa">
|
<View
|
||||||
|
className="homeNavbar"
|
||||||
|
style={{
|
||||||
|
position: 'fixed',
|
||||||
|
top: 0,
|
||||||
|
left: 0,
|
||||||
|
width: '100%',
|
||||||
|
height: `${statusBarHeight + navBarHeight}px`,
|
||||||
|
paddingTop: `${statusBarHeight}px`,
|
||||||
|
backgroundColor: 'transparent',
|
||||||
|
zIndex: 99,
|
||||||
|
}}
|
||||||
|
>
|
||||||
<View className="listNavWrapper">
|
<View className="listNavWrapper">
|
||||||
{/* 标题模式(用于"我的"页面等) */}
|
{/* 标题模式(用于"我的"页面等) */}
|
||||||
{showTitle && (
|
{showTitle && (
|
||||||
@@ -203,7 +221,7 @@ const ListHeader = (props: IProps) => {
|
|||||||
src={img.ICON_LIST_SEARCH_SEARCH}
|
src={img.ICON_LIST_SEARCH_SEARCH}
|
||||||
/>
|
/>
|
||||||
<Input
|
<Input
|
||||||
placeholder="搜索上海的球局和场地"
|
placeholder="搜索球局和场地"
|
||||||
className="navbarInput"
|
className="navbarInput"
|
||||||
clearable={false}
|
clearable={false}
|
||||||
disabled
|
disabled
|
||||||
@@ -225,8 +243,8 @@ const ListHeader = (props: IProps) => {
|
|||||||
onCityChange={handleCityChange}
|
onCityChange={handleCityChange}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</CustomNavbar>
|
</View>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ListHeader;
|
export default HomeNavbar;
|
||||||
@@ -6,7 +6,7 @@ import Taro from "@tarojs/taro";
|
|||||||
import { useListStore } from "@/store/listStore";
|
import { useListStore } from "@/store/listStore";
|
||||||
import { useGlobalState } from "@/store/global";
|
import { useGlobalState } from "@/store/global";
|
||||||
import { View, Image, Text, ScrollView } from "@tarojs/components";
|
import { View, Image, Text, ScrollView } from "@tarojs/components";
|
||||||
import CustomerNavBar from "@/container/listCustomNavbar";
|
import HomeNavbar from "@/components/HomeNavbar";
|
||||||
import GuideBar from "@/components/GuideBar";
|
import GuideBar from "@/components/GuideBar";
|
||||||
import ListContainer from "@/container/listContainer";
|
import ListContainer from "@/container/listContainer";
|
||||||
import DistanceQuickFilter from "@/components/DistanceQuickFilter";
|
import DistanceQuickFilter from "@/components/DistanceQuickFilter";
|
||||||
@@ -435,7 +435,7 @@ const ListPage = () => {
|
|||||||
<>
|
<>
|
||||||
|
|
||||||
{/* 自定义导航 */}
|
{/* 自定义导航 */}
|
||||||
<CustomerNavBar
|
<HomeNavbar
|
||||||
config={{
|
config={{
|
||||||
showInput: isShowInputCustomerNavBar,
|
showInput: isShowInputCustomerNavBar,
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { useListStore } from "@/store/listStore";
|
|||||||
import { useGlobalState } from "@/store/global";
|
import { useGlobalState } from "@/store/global";
|
||||||
import ListContainer from "@/container/listContainer";
|
import ListContainer from "@/container/listContainer";
|
||||||
import img from "@/config/images";
|
import img from "@/config/images";
|
||||||
import CustomerNavBar from "@/container/listCustomNavbar";
|
import HomeNavbar from "@/components/HomeNavbar";
|
||||||
import DistanceQuickFilter from "@/components/DistanceQuickFilter";
|
import DistanceQuickFilter from "@/components/DistanceQuickFilter";
|
||||||
import { withAuth } from "@/components";
|
import { withAuth } from "@/components";
|
||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
@@ -107,7 +107,7 @@ const SearchResult = () => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{/* 自定义导航 */}
|
{/* 自定义导航 */}
|
||||||
<CustomerNavBar
|
<HomeNavbar
|
||||||
config={{
|
config={{
|
||||||
showInput: true,
|
showInput: true,
|
||||||
inputLeftIcon: img.ICON_LIST_SEARCH_BACK,
|
inputLeftIcon: img.ICON_LIST_SEARCH_BACK,
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { check_login_status } from "@/services/loginService";
|
|||||||
import { useUserActions } from "@/store/userStore";
|
import { useUserActions } from "@/store/userStore";
|
||||||
import GuideBar from "@/components/GuideBar";
|
import GuideBar from "@/components/GuideBar";
|
||||||
import { withAuth, GeneralNavbar } from "@/components";
|
import { withAuth, GeneralNavbar } from "@/components";
|
||||||
import CustomerNavBar from "@/container/listCustomNavbar";
|
import HomeNavbar from "@/components/HomeNavbar";
|
||||||
import ListPageContent from "./components/ListPageContent";
|
import ListPageContent from "./components/ListPageContent";
|
||||||
import MessagePageContent from "./components/MessagePageContent";
|
import MessagePageContent from "./components/MessagePageContent";
|
||||||
import MyselfPageContent from "./components/MyselfPageContent";
|
import MyselfPageContent from "./components/MyselfPageContent";
|
||||||
@@ -113,9 +113,9 @@ const MainPage: React.FC = () => {
|
|||||||
// 渲染自定义导航栏(参考原始页面的实现)
|
// 渲染自定义导航栏(参考原始页面的实现)
|
||||||
const renderCustomNavbar = () => {
|
const renderCustomNavbar = () => {
|
||||||
if (currentTab === "list") {
|
if (currentTab === "list") {
|
||||||
// 列表页:使用 CustomerNavBar(与原始列表页一致)
|
// 列表页:使用 HomeNavbar(与原始列表页一致)
|
||||||
return (
|
return (
|
||||||
<CustomerNavBar
|
<HomeNavbar
|
||||||
config={{
|
config={{
|
||||||
showInput: isShowInputCustomerNavBar,
|
showInput: isShowInputCustomerNavBar,
|
||||||
}}
|
}}
|
||||||
@@ -132,13 +132,12 @@ const MainPage: React.FC = () => {
|
|||||||
<GeneralNavbar title="消息" />
|
<GeneralNavbar title="消息" />
|
||||||
);
|
);
|
||||||
} else if (currentTab === "personal") {
|
} else if (currentTab === "personal") {
|
||||||
// 我的页:使用 CustomerNavBar 显示标题
|
// 我的页:使用 GeneralNavbar 显示标题
|
||||||
return (
|
return (
|
||||||
<CustomerNavBar
|
<GeneralNavbar
|
||||||
config={{
|
title=""
|
||||||
showTitle: true,
|
titlePosition="left"
|
||||||
title: "我的",
|
showBack={false}
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user