修复个人页问题

This commit is contained in:
张成
2025-11-08 14:28:06 +08:00
parent c6ca2269f9
commit 40ea0f2eed
5 changed files with 65 additions and 53 deletions

View File

@@ -5,5 +5,5 @@
overflow: hidden;
z-index: 9991;
width: 100%;
background-color: #fff;
// 背景颜色通过 style 动态设置,默认透明
}

View File

@@ -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 (
<View
className={styles.customerNavbar}
style={{ height: `${navBarHeight}px`, paddingTop: `${statusBarHeight}px`, }}
style={{
height: `${navBarHeight}px`,
paddingTop: `${statusBarHeight}px`,
backgroundColor: backgroundColor || 'transparent'
}}
>
{children}
</View>

View File

@@ -1,4 +1,4 @@
export default definePageConfig({
navigationBarTitleText: '用户主页',
navigationBarTitleText: '',
navigationStyle: 'custom',
})

View File

@@ -11,43 +11,50 @@
/* 100px 处开始淡化 */ #fafafa 300px,
/* 到 200px 变成白色 */ #fafafa 100% /* 200px 以下全白 */
);
}
.custom-navbar {
height: 56px;
/* 通常与原生导航栏高度一致 */
// 导航栏内容
.navbar_content {
display: flex;
justify-content: space-between;
align-items: center;
width: 100%;
height: 44px;
.navbar_back {
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%;
display: flex;
justify-content: center;
& > .detail-navigator-back-icon {
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 {

View File

@@ -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<Partial<UserInfoType>>({
id: parseInt(user_id || "1") || 1,
@@ -209,23 +215,19 @@ const OtherUserPage: React.FC = () => {
return (
<View className="other_user_page">
<View className="custom-navbar">
<View className="detail-navigator">
<View
className="detail-navigator-back"
onClick={() => {
Taro.navigateBack();
}}
>
<Image
className="detail-navigator-back-icon"
src={img.ICON_NAVIGATOR_BACK}
/>
</View>
<CustomNavbar>
<View className="navbar_content">
<View className="navbar_back" onClick={() => Taro.navigateBack()}>
<View className="back_icon" />
</View>
<Text className="navbar_title"></Text>
<View className="navbar_action">
{/* 右侧占位,保持标题居中 */}
</View>
</View>
</CustomNavbar>
{/* 主要内容 */}
<View className="main_content">
<View className="main_content" style={{ paddingTop: `${totalHeight}px` }}>
{/* 用户信息区域 */}
<View className="user_info_section">
<UserInfoCard