index copy.vue 1.9 KB

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