You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

11 miesięcy temu
11 miesięcy temu
11 miesięcy temu
11 miesięcy temu
11 miesięcy temu
11 miesięcy temu
11 miesięcy temu
11 miesięcy temu
11 miesięcy temu
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <view class="nav-bar" :style="{height:navHeight+'px',background:bgColor,color:fontColor}">
  3. <view class="title"
  4. :style="{paddingTop:searchMarginTop+'px',height:searchHeight+'px',lineHeight:searchHeight+'px'}">
  5. <view @click="back" v-if="isBack && !isAlipay" class="back" :style="{height:searchHeight+'px',width:searchHeight+'px'}">
  6. <image :src="`/static/image/icon-back.png`" mode="aspectFill"
  7. :style="{height:searchHeight+'px',width:searchHeight+'px'}" v-if='!backImgWhite'></image>
  8. <image src="/static/image/icon-back-white.png" mode="aspectFill"
  9. :style="{height:searchHeight+'px',width:searchHeight+'px'}" v-else></image>
  10. </view>
  11. <text>{{title}}</text>
  12. </view>
  13. </view>
  14. <view class="blank" :style="{height:navHeight+'px'}"></view>
  15. </template>
  16. <script setup lang="ts">
  17. import {
  18. onMounted,
  19. ref
  20. } from "vue";
  21. const navHeight = ref(null)
  22. const searchMarginTop = ref(null)
  23. const searchHeight = ref(32)
  24. const searchWidth = ref(32)
  25. const isAlipay = ref(false)
  26. onMounted(() => {
  27. const menuButtonInfo = uni.getMenuButtonBoundingClientRect()
  28. const type = uni.getSystemInfoSync().uniPlatform
  29. isAlipay.value = type === 'mp-alipay'
  30. const {
  31. top,
  32. width,
  33. height,
  34. right
  35. } = menuButtonInfo
  36. uni.getSystemInfo({
  37. success: (res) => {
  38. const {
  39. statusBarHeight
  40. } = res
  41. const margin = top - statusBarHeight
  42. navHeight.value = (height + statusBarHeight + (margin * 2)) //导航栏总高
  43. searchMarginTop.value = statusBarHeight + margin // 状态栏 + 胶囊按钮边距
  44. searchHeight.value = height // 与胶囊按钮同高
  45. searchWidth.value = right - width // 胶囊按钮右边坐标 - 胶囊按钮宽度 = 按钮左边可使用宽度
  46. },
  47. })
  48. })
  49. const props = defineProps({
  50. title: {
  51. type: String,
  52. default: ''
  53. },
  54. isBack: {
  55. type: Boolean,
  56. default: true
  57. },
  58. bgColor: {
  59. type: String,
  60. default: 'linear-gradient(to left, #43A1E0 0%, #13E7C1 100%);'
  61. },
  62. fontColor:{
  63. type: String,
  64. default: '#000'
  65. },
  66. backImgWhite:{
  67. type: Boolean,
  68. default: false
  69. }
  70. })
  71. const back = () => {
  72. uni.navigateBack({
  73. delta: 1
  74. })
  75. }
  76. </script>
  77. <style scoped>
  78. .blank {
  79. width: 100%;
  80. }
  81. .nav-bar {
  82. background: linear-gradient(to left, #43A1E0 0%, #13E7C1 100%);
  83. position: fixed;
  84. width: 100%;
  85. z-index: 999;
  86. }
  87. .nav-bar .title {
  88. text-align: center;
  89. width: 100%;
  90. font-size: 28rpx;
  91. font-weight: bold;
  92. position: relative;
  93. }
  94. .back {
  95. position: absolute;
  96. left: 10rpx;
  97. }
  98. </style>