From 0ab1535f7f0b67f78ba0bf7ed7c0a8ef031947d2 Mon Sep 17 00:00:00 2001
From: cr <423803750@qq.com>
Date: Sat, 25 Apr 2026 22:10:33 +0800
Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=B8=90=E5=8F=98?=
=?UTF-8?q?=E8=83=8C=E6=99=AF=E5=AE=9A=E4=BD=8D=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pages/sub/activity/list.vue | 8 +++---
pages/sub/community/dynamics-detail.vue | 33 ++++++++++++++++++-------
pages/sub/community/dynamics.vue | 11 ++++-----
pages/sub/knowledge/classroom.vue | 21 ++++++++--------
pages/sub/knowledge/detail.vue | 19 +++++++++-----
pages/sub/notice/detail.vue | 26 ++++++++++---------
6 files changed, 70 insertions(+), 48 deletions(-)
diff --git a/pages/sub/activity/list.vue b/pages/sub/activity/list.vue
index 38640be..086debe 100644
--- a/pages/sub/activity/list.vue
+++ b/pages/sub/activity/list.vue
@@ -178,15 +178,15 @@ function handleFloatBtn() {
position: relative;
}
-/* 渐变背景装饰 - 覆盖导航栏到内容区 */
+/* 渐变背景装饰 */
.gradient-bg {
position: absolute;
- top: -176rpx; /* 向上延伸覆盖inner-navbar */
+ top: 0;
left: 0;
right: 0;
- height: calc(100% + 176rpx);
+ height: 100%;
background: linear-gradient(180deg, #F8EDE8 0%, #FFFFFF 30%);
- z-index: -1; /* 在内容层下方 */
+ z-index: -1;
}
/* 固定头部区域 */
diff --git a/pages/sub/community/dynamics-detail.vue b/pages/sub/community/dynamics-detail.vue
index a66441e..90fe247 100644
--- a/pages/sub/community/dynamics-detail.vue
+++ b/pages/sub/community/dynamics-detail.vue
@@ -1,11 +1,12 @@
-
-
-
+
+
+
+
-
-
@@ -55,6 +57,9 @@ const scrollHeight = ref(0);
// 滚动区域距离顶部距离
const scrollTop = ref(0);
+// 导航栏高度(px),用于固定头部避开导航栏
+const navbarHeight = sheep.$platform.navbar;
+
// 页面加载
onLoad((options) => {
if (options.id) {
@@ -69,13 +74,14 @@ const calcScrollHeight = () => {
const sysInfo = uni.getSystemInfoSync();
const query = uni.createSelectorQuery().in(instance);
- // 获取头部区域高度和位置
+ // 获取头部区域高度
query.select('.detail-header').boundingClientRect();
query.exec((res) => {
const headerRect = res[0];
if (headerRect) {
const safeBottom = sysInfo.safeAreaInsets?.bottom || 0;
- scrollTop.value = headerRect.height + headerRect.top;
+ // scroll-view 顶部 = 导航栏高度 + 头部高度,不再依赖 headerRect.top(fixed 元素在不同平台表现不一致)
+ scrollTop.value = navbarHeight + headerRect.height;
scrollHeight.value = sysInfo.windowHeight - scrollTop.value - safeBottom;
}
});
@@ -99,15 +105,24 @@ async function loadDetail(id) {
content: data.content || '',
};
- setTimeout(calcScrollHeight, 100);
+ // 等 Vue DOM 更新完成后再计算高度,避免网络延迟导致拿到旧尺寸
+ nextTick(() => {
+ calcScrollHeight();
+ });
}
}