|
@@ -12,16 +12,14 @@
|
|
|
:left-icon="showBack ? 'arrow-left' : ''"
|
|
|
@clickLeft="onBack"
|
|
|
:border="false"
|
|
|
- title="导航栏组件"
|
|
|
+ :title="title"
|
|
|
fixed
|
|
|
:backgroundColor="bgColor"
|
|
|
/>
|
|
|
</view>
|
|
|
<scroll-view
|
|
|
- :class="['scroll-view', scrollX ? 'topic-scroll' : '']"
|
|
|
:scroll-y="scrollY"
|
|
|
:scroll-with-animation="true"
|
|
|
- :scroll-into-view-within-extent="true"
|
|
|
:enable-flex="true"
|
|
|
:enable-passive="true"
|
|
|
:enhanced="true"
|
|
@@ -30,15 +28,18 @@
|
|
|
:show-scrollbar="false"
|
|
|
:scroll-x="scrollX"
|
|
|
:scroll-into-view="scrollIntoView"
|
|
|
- :style="{
|
|
|
- // 24是内边距
|
|
|
- // width: `${safeArea.width}px`,
|
|
|
- // 减去底部高度
|
|
|
- height: `${safeArea.height}px`,
|
|
|
- whiteSpace: scrollX ? 'nowrap' : 'normal',
|
|
|
- }"
|
|
|
+ enable-back-to-top
|
|
|
+ scroll-anchoring
|
|
|
>
|
|
|
- <slot></slot>
|
|
|
+ <view
|
|
|
+ :class="['scroll-view', scrollX ? 'topic-scroll' : '']"
|
|
|
+ :style="{
|
|
|
+ height: `${safeArea.height}px`,
|
|
|
+ whiteSpace: scrollX ? 'nowrap' : 'normal',
|
|
|
+ }"
|
|
|
+ >
|
|
|
+ <slot></slot>
|
|
|
+ </view>
|
|
|
<!-- 底部文字 -->
|
|
|
<view v-if="showBottom && bottomText" class="bottom-text">
|
|
|
{{ bottomText }}
|
|
@@ -57,8 +58,9 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
+import pages from '@/pages.json'
|
|
|
import { ref, onMounted, watchEffect } from "vue";
|
|
|
-import { router } from "../../utils/router";
|
|
|
+import { getRoute, router } from "../../utils/router";
|
|
|
import { getRect } from "../../utils/utils";
|
|
|
import { getCurrentInstance } from "vue";
|
|
|
|
|
@@ -104,6 +106,7 @@ const props = defineProps({
|
|
|
type: String,
|
|
|
default: "#fff",
|
|
|
},
|
|
|
+ title: String
|
|
|
});
|
|
|
|
|
|
const emit = defineEmits(["onSafeAreaChange"]);
|
|
@@ -124,8 +127,19 @@ const safeArea = ref({
|
|
|
const footerHeight = ref(0);
|
|
|
|
|
|
onMounted(() => {
|
|
|
- const systemInfo = uni.getSystemInfoSync();
|
|
|
- safeArea.value = systemInfo.safeArea;
|
|
|
+ const systemInfo = uni.getWindowInfo();
|
|
|
+ // 判断是否为tabbar页面
|
|
|
+ safeArea.value = {
|
|
|
+ ...systemInfo.safeArea,
|
|
|
+ source: systemInfo.safeArea,
|
|
|
+ };
|
|
|
+ const isTarbarPage = pages.tabBar.list.map(item => item.pagePath).includes(getRoute().routeList[0].path)
|
|
|
+ if (isTarbarPage) {
|
|
|
+ // 高度再减掉tabbar高度
|
|
|
+ safeArea.value.height -= 50;
|
|
|
+ // 减去系统导航栏高度
|
|
|
+ safeArea.value.height -= (systemInfo.statusBarHeight - 18);
|
|
|
+ }
|
|
|
// 24是内边距
|
|
|
safeArea.value.width -= 24;
|
|
|
|
|
@@ -155,7 +169,6 @@ onMounted(() => {
|
|
|
|
|
|
watchEffect(() => {
|
|
|
emit("onSafeAreaChange", safeArea.value);
|
|
|
- console.log(safeArea.value);
|
|
|
});
|
|
|
|
|
|
defineExpose({
|