index.vue 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <template>
  2. <view class="navbar-box" :style="{'height': (navbarHeight < defaultLogoHeight ? (defaultLogoHeight + 10) : navbarHeight) + 'px', 'paddingTop': statusBarHeight + 'px'}">
  3. <image src="https://minio.citupro.com/dev/menduner/poster.png" class="navbar-box-logo" :style="{'height': defaultLogoHeight + 'px'}"></image>
  4. <!-- <view class="navbar-box-title">{{ title }}</view> -->
  5. </view>
  6. </template>
  7. <script setup>
  8. import { ref } from 'vue'
  9. import { onLoad } from '@dcloudio/uni-app'
  10. defineProps({
  11. title: {
  12. type: String,
  13. default: '门墩儿'
  14. }
  15. })
  16. const defaultLogoHeight = 45
  17. const navbarHeight = ref(0)
  18. const statusBarHeight = ref(0)
  19. onLoad(() => {
  20. const systemInfo = uni.getSystemInfoSync()
  21. statusBarHeight.value = systemInfo.statusBarHeight
  22. const menuButtonInfo = uni.getMenuButtonBoundingClientRect()
  23. navbarHeight.value = menuButtonInfo.height + ((menuButtonInfo.top - statusBarHeight.value) * 2) + 15
  24. })
  25. </script>
  26. <style scoped lang="scss">
  27. .navbar-box {
  28. width: 100%;
  29. position: relative;
  30. background: linear-gradient(90deg, #66BB6A 0, #64FFDA 100%);
  31. &-logo {
  32. position: absolute;
  33. left: 50%;
  34. transform: translateX(-50%);
  35. width: 100px;
  36. }
  37. // &-title {
  38. // position: absolute;
  39. // top: 50%;
  40. // left: 50%;
  41. // transform: translate(-30%, 0);
  42. // color: #fff;
  43. // }
  44. }
  45. </style>