workNavBar.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <template>
  2. <view class="navbar">
  3. <view class="content" :style="{ background: isScrolling ? '#fff' : bagColor }">
  4. <view :style="{ height: `${getHeight.barTop}px` }"></view>
  5. <view class="acea-row row-center-wrapper bar" :style="{ height: `${getHeight.barHeight}px` }">
  6. <view class="back-icon acea-row row-center-wrapper">
  7. <view v-show="showBack" @click="back" class="iconfont icon-xiangzuo back-icon"
  8. :style="{ color: `${iconColor}`}"></view>
  9. </view>
  10. <view class="title"
  11. :style="{ color: `${textColor}`, fontSize: `${textSize}`, fontWeight: `${textWeight}` }"><slot></slot>
  12. </view>
  13. <view class="right-icon acea-row row-center-wrapper">
  14. <view v-show="showRight" class="right-icon"></view>
  15. </view>
  16. </view>
  17. </view>
  18. <view class="placeholder">
  19. <view :style="{ height: `${getHeight.barTop}px` }"></view>
  20. <view :style="{ height: `${getHeight.barHeight}px` }"></view>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. export default {
  26. name: 'navbar',
  27. props: {
  28. // 滚动至下部
  29. isScrolling: {
  30. type: Boolean,
  31. default: false
  32. },
  33. // 是否显示返回icon
  34. showBack: {
  35. type: Boolean,
  36. default: false
  37. },
  38. // Title
  39. titleText: {
  40. type: String,
  41. default: ''
  42. },
  43. // icon 颜色
  44. iconColor: {
  45. type: String,
  46. default: '#000000'
  47. },
  48. // icon 字号
  49. iconSize: {
  50. type: String,
  51. default: '40rpx'
  52. },
  53. // icon 字重
  54. iconWeight: {
  55. type: String,
  56. default: 'bold'
  57. },
  58. // Title 颜色
  59. textColor: {
  60. type: String,
  61. default: '#333'
  62. },
  63. // Title 字号
  64. textSize: {
  65. type: String,
  66. default: '34rpx'
  67. },
  68. // Title 字重
  69. textWeight: {
  70. type: String,
  71. default: '500'
  72. },
  73. // 背景色
  74. bagColor: {
  75. type: String,
  76. default: 'transparent'
  77. }
  78. },
  79. data() {
  80. return {
  81. getHeight: this.$util.getWXStatusHeight()
  82. };
  83. },
  84. methods: {
  85. back() {
  86. uni.switchTab({
  87. url:'/pages/user/index'
  88. })
  89. }
  90. }
  91. };
  92. </script>
  93. <style lang="scss">
  94. .navbar {
  95. position: relative;
  96. color: #333;
  97. .content {
  98. position: fixed;
  99. top: 0;
  100. right: 0;
  101. left: 0;
  102. z-index: 998;
  103. background-color: var(--view-theme);
  104. font-weight: 500;
  105. font-size: 34rpx;
  106. color: #ffffff;
  107. .back-icon,
  108. .right-icon {
  109. width: 40rpx;
  110. height: 40rpx;
  111. }
  112. .bar {
  113. padding: 0 30rpx;
  114. }
  115. .title {
  116. flex: 1;
  117. text-align: center;
  118. }
  119. }
  120. }
  121. </style>