index.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <template>
  2. <view
  3. class="navbar-box"
  4. :style="{
  5. 'height': (navbarHeight < defaultLogoHeight ? (defaultLogoHeight + 10) : navbarHeight) + 'px',
  6. 'line-height': (navbarHeight < defaultLogoHeight ? (defaultLogoHeight + 10) : navbarHeight) + 'px',
  7. 'paddingTop': statusBarHeight + 'px'
  8. }"
  9. >
  10. <image
  11. v-if="showLogo"
  12. src="https://minio.menduner.com/dev/fe9890be9b1176f84f2aa282b0f6adce300b133f65eb3d7b45ae057aa5698324.png"
  13. class="navbar-box-logo"
  14. :style="{'height': defaultLogoHeight + 'px'}"
  15. ></image>
  16. <view v-else class="navbar-box-title MiSans-Semibold">{{ title }}</view>
  17. </view>
  18. </template>
  19. <script setup>
  20. import { ref } from 'vue'
  21. import { onLoad } from '@dcloudio/uni-app'
  22. defineProps({
  23. title: {
  24. type: String,
  25. default: '门墩儿'
  26. },
  27. showLogo: {
  28. type: Boolean,
  29. default: false
  30. }
  31. })
  32. const defaultLogoHeight = 40
  33. const navbarHeight = ref(0)
  34. const statusBarHeight = ref(0)
  35. onLoad(() => {
  36. const systemInfo = uni.getSystemInfoSync()
  37. statusBarHeight.value = systemInfo.statusBarHeight
  38. const menuButtonInfo = uni.getMenuButtonBoundingClientRect()
  39. navbarHeight.value = menuButtonInfo.height + ((menuButtonInfo.top - statusBarHeight.value) * 2) + 15
  40. })
  41. </script>
  42. <style scoped lang="scss">
  43. .navbar-box {
  44. width: 100%;
  45. position: relative;
  46. background: linear-gradient(180deg, #9bfece, #BCFEDE);
  47. &-logo {
  48. position: absolute;
  49. left: 10px;
  50. width: 95px;
  51. }
  52. &-title {
  53. position: absolute;
  54. left: 10px;
  55. width: 158px;
  56. height: 51px;
  57. font-family: MiSans, MiSans;
  58. font-weight: 600;
  59. font-size: 38rpx;
  60. color: #0E100F;
  61. font-style: normal;
  62. text-transform: none;
  63. }
  64. }
  65. </style>