wupengfei
2025-02-14 4bc9cf48154b5666d4c928f32182bcbb92eca6c5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<template>
  <NavBar v-bind="props" dark class="transparent-navigation-bar" :style="wrapperStyle">
    <div :class="['common-navigation-bar-wrapper', { dark: mode == 'dark' }]" :style="barStyle">
      <slot name="left">
        <div
          class="menu-btn-wrapper"
          v-if="(!isLastPage || !isTabbarPage) && showLeftArrow"
          @click="goBack()"
        >
          <img v-if="props.navigationArrowWhite" class="menu-btn" :src="IconArrowWhite" />
          <img v-else class="menu-btn" :src="IconArrow" />
        </div>
      </slot>
      <span class="common-navigation-bar-title">{{ title }}</span>
    </div>
  </NavBar>
</template>
 
<script setup lang="ts">
import NavBar from './NavBar.vue';
import { commonNavigationBarProps } from './commonNavigationBar';
import { useSystemStore } from '@/stores/modules/system';
import { CSSProperties } from 'vue';
import IconArrow from '@/assets/common/icon-navi-arrow.png';
import IconArrowWhite from '@/assets/common/icon-navi-arrow-white.png';
import Taro from '@tarojs/taro';
import { goBack } from '@/utils';
import { TabBarPageRouter } from '@/constants';
 
defineOptions({
  name: 'TransparentNavigationBar',
});
 
const systemStore = useSystemStore();
 
const props = defineProps(commonNavigationBarProps);
 
const router = Taro.useRouter();
 
const isLastPage = computed(() => {
  const pages = Taro.getCurrentPages();
  return pages.length <= 1;
});
 
const isTabbarPage = computed(() =>
  Object.values(TabBarPageRouter).some((x) => x.toLowerCase() === router.path.toLowerCase())
);
 
const barStyle = computed(() => {
  const distance = systemStore.menuButtonWidth + systemStore.menuButtonRightDistance + 4;
  return {
    paddingLeft: `${distance}px`,
    paddingRight: `${distance}px`,
    height: systemStore.navigationBarHeight + 'px',
  } as CSSProperties;
});
 
const wrapperStyle = computed(() => {
  return props.isAbsolute
    ? ({
        position: 'absolute',
      } as CSSProperties)
    : {};
});
</script>
 
<style lang="scss">
.transparent-navigation-bar.navigation-bar-wrapper {
  background-color: transparent;
  /* position: absolute; */
  width: 100%;
 
  .common-navigation-bar-title {
    height: 36px;
  }
}
</style>