diff --git a/src/components/CustomNavbar/index.module.scss b/src/components/CustomNavbar/index.module.scss index fab7c1d..2e0c6a1 100644 --- a/src/components/CustomNavbar/index.module.scss +++ b/src/components/CustomNavbar/index.module.scss @@ -5,5 +5,5 @@ overflow: hidden; z-index: 9991; width: 100%; - background-color: #fff; + // 背景颜色通过 style 动态设置,默认透明 } diff --git a/src/components/CustomNavbar/index.tsx b/src/components/CustomNavbar/index.tsx index 650459c..858e5a0 100644 --- a/src/components/CustomNavbar/index.tsx +++ b/src/components/CustomNavbar/index.tsx @@ -4,17 +4,22 @@ import { useGlobalState } from "@/store/global"; interface IProps { children: any; + backgroundColor?: string; // 背景颜色,不设置则透明 } const CustomNavbar = (props: IProps) => { - const { children } = props; + const { children, backgroundColor } = props; const { statusNavbarHeightInfo } = useGlobalState(); const { statusBarHeight, navBarHeight } = statusNavbarHeightInfo; return ( {children} diff --git a/src/user_pages/other/index.config.ts b/src/user_pages/other/index.config.ts index bc1e99b..625ecd5 100644 --- a/src/user_pages/other/index.config.ts +++ b/src/user_pages/other/index.config.ts @@ -1,4 +1,4 @@ export default definePageConfig({ - navigationBarTitleText: '用户主页', + navigationBarTitleText: '', navigationStyle: 'custom', }) \ No newline at end of file diff --git a/src/user_pages/other/index.scss b/src/user_pages/other/index.scss index 076db5a..ce7cd78 100644 --- a/src/user_pages/other/index.scss +++ b/src/user_pages/other/index.scss @@ -11,43 +11,50 @@ /* 100px 处开始淡化 */ #fafafa 300px, /* 到 200px 变成白色 */ #fafafa 100% /* 200px 以下全白 */ ); -} -.custom-navbar { - height: 56px; - /* 通常与原生导航栏高度一致 */ - display: flex; - align-items: center; - justify-content: center; - background: transparent; - color: #000; - padding-top: 44px; - /* 适配状态栏 */ - position: sticky; - top: 0; - z-index: 100; - overflow: hidden; -} - -.detail-navigator { - height: 30px; - width: 80px; - border-radius: 15px; - position: absolute; - left: 12px; - box-sizing: border-box; - display: flex; - align-items: center; - - .detail-navigator-back { - height: 32px; - width: 50%; + // 导航栏内容 + .navbar_content { display: flex; - justify-content: center; + justify-content: space-between; + align-items: center; + width: 100%; + height: 44px; - & > .detail-navigator-back-icon { + .navbar_back { + display: flex; + align-items: center; + justify-content: center; width: 32px; height: 32px; + margin-left: 10px; + cursor: pointer; + + .back_icon { + height: 16px; + width: 8px; + background: url("../../static/userInfo/back_icon.svg") no-repeat center; + background-size: contain; + } + } + + .navbar_title { + font-family: PingFang SC; + font-weight: 600; + font-size: 20px; + line-height: 28px; + letter-spacing: 1.9%; + color: #000000; + position: absolute; + left: 50px; + } + + .navbar_action { + display: flex; + align-items: center; + justify-content: center; + width: 83px; + height: 30px; + margin-right: 7px; } } } @@ -55,14 +62,12 @@ // 主要内容区域 .main_content { position: relative; - z-index: 5; flex: 1; - margin-top: 0; + margin-top: 11px; box-sizing: border-box; overflow-y: auto; padding: 15px 15px 15px; - padding-top: 98px; // 用户信息区域 .user_info_section { diff --git a/src/user_pages/other/index.tsx b/src/user_pages/other/index.tsx index 114a636..c2540fa 100644 --- a/src/user_pages/other/index.tsx +++ b/src/user_pages/other/index.tsx @@ -14,6 +14,8 @@ import { } from "@/components/UserInfo"; import { UserService, UserInfoType } from "@/services/userService"; import * as LoginService from "@/services/loginService"; +import CustomNavbar from "@/components/CustomNavbar"; +import { useGlobalState } from "@/store/global"; const OtherUserPage: React.FC = () => { // 获取页面参数 @@ -28,6 +30,10 @@ const OtherUserPage: React.FC = () => { Taro.navigateBack(); } + // 获取导航栏高度信息 + const { statusNavbarHeightInfo } = useGlobalState() || {}; + const { totalHeight = 98 } = statusNavbarHeightInfo || {}; + // 模拟用户数据 const [user_info, setUserInfo] = useState>({ id: parseInt(user_id || "1") || 1, @@ -209,23 +215,19 @@ const OtherUserPage: React.FC = () => { return ( - - - { - Taro.navigateBack(); - }} - > - + + + Taro.navigateBack()}> + + + + + {/* 右侧占位,保持标题居中 */} - + {/* 主要内容 */} - + {/* 用户信息区域 */}