|
@@ -3,8 +3,8 @@
|
|
|
class="navbar"
|
|
|
:class="{'gradientBgc': !noBgColor}"
|
|
|
:style="{
|
|
|
- 'height': (navbarHeight < defaultLogoHeight ? (defaultLogoHeight + 10) : navbarHeight + 10) + 'px',
|
|
|
- 'line-height': (navbarHeight < defaultLogoHeight ? (defaultLogoHeight + 10) : navbarHeight + 10) + 'px',
|
|
|
+ 'height': height + 'px',
|
|
|
+ 'line-height': height + 'px',
|
|
|
}"
|
|
|
>
|
|
|
<view class="navbar-box" :style="{'paddingTop': statusBarHeight + 'px'}">
|
|
@@ -14,8 +14,8 @@
|
|
|
class="navbar-box-logo"
|
|
|
:style="{'height': defaultLogoHeight + 'px'}"
|
|
|
></image>
|
|
|
- <view v-else class="nav-box-title">
|
|
|
- <uni-icons type="left" size="25" class="ss-m-l-20" color="#0E100F" @tap="goBack"></uni-icons>
|
|
|
+ <view v-else class="nav-box-title" :style="{'height': height ? (height - statusBarHeight) + 'px' : '100%'}">
|
|
|
+ <uni-icons v-if="!textLeft" type="left" size="25" class="ss-m-l-20" color="#0E100F" @tap="goBack"></uni-icons>
|
|
|
<view class="title-text" :class="[{'text-left': textLeft}, {'text-center': !textLeft}]">{{ title }}</view>
|
|
|
</view>
|
|
|
</view>
|
|
@@ -50,8 +50,9 @@ defineProps({
|
|
|
const defaultLogoHeight = 40
|
|
|
const navbarHeight = ref(0)
|
|
|
const statusBarHeight = ref(0)
|
|
|
+const height = ref(0)
|
|
|
|
|
|
-onLoad(() => {
|
|
|
+onLoad(async () => {
|
|
|
try {
|
|
|
const systemInfo = uni.getSystemInfoSync()
|
|
|
statusBarHeight.value = systemInfo.statusBarHeight
|
|
@@ -65,18 +66,25 @@ onLoad(() => {
|
|
|
navbarHeight.value = defaultLogoHeight + 10
|
|
|
}
|
|
|
|
|
|
- // 将 navbarHeight 存入本地缓存
|
|
|
- const height = navbarHeight.value < defaultLogoHeight ? (defaultLogoHeight + 10) : navbarHeight.value + 10
|
|
|
- uni.setStorageSync('navbarHeight', height)
|
|
|
+ height.value = navbarHeight.value < defaultLogoHeight ? (defaultLogoHeight + 10) : navbarHeight.value + 10
|
|
|
+ await new Promise((resolve, reject) => {
|
|
|
+ uni.setStorage({
|
|
|
+ key: 'navbarHeight',
|
|
|
+ data: height.value,
|
|
|
+ success: resolve,
|
|
|
+ fail: reject
|
|
|
+ })
|
|
|
+ })
|
|
|
} catch (error) {
|
|
|
console.error('获取系统信息或菜单按钮信息时出错:', error)
|
|
|
}
|
|
|
})
|
|
|
|
|
|
+// 返回上一页
|
|
|
const goBack = () => {
|
|
|
uni.navigateBack({
|
|
|
delta: 1
|
|
|
- });
|
|
|
+ })
|
|
|
}
|
|
|
</script>
|
|
|
|
|
@@ -104,7 +112,6 @@ const goBack = () => {
|
|
|
.nav-box-title {
|
|
|
position: relative;
|
|
|
width: 100%;
|
|
|
- height: 100%;
|
|
|
display: flex;
|
|
|
align-items: center;
|
|
|
.title-text {
|