app-tab-nav.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <template>
  2. <view>
  3. <view
  4. :class="[shadow ? `main-between app-nav shadow` : 'main-between app-nav']"
  5. :style="[
  6. {
  7. 'line-height': `${setHeight ? setHeight : 90}rpx`,
  8. 'font-size': `${fontSize ? fontSize : 28}rpx`,
  9. 'height': `${setHeight ? setHeight : 90}rpx`,
  10. 'top': `${setTop > 0 ? setTop + 'rpx' : '0'}`,
  11. 'backgroundColor': `${background ? background : '#fff'}`,
  12. }
  13. ]"
  14. >
  15. <view @click="handleClick" v-for="(item) in tabList" :key="item.id" :data-id="item.id" class="box-grow-1 nav-item"
  16. :style="[
  17. {
  18. 'borderBottom': `${border ? 1 : 0}rpx solid #e2e2e2`,
  19. }
  20. ]"
  21. >
  22. <text
  23. :class="[item.id == activeItem ? `active-text` : '']"
  24. :style="[
  25. {
  26. 'color': `${ item.id == activeItem ? theme.color : '#353535'}`,
  27. 'border-color': `${ item.id == activeItem ? theme.color : ''}`,
  28. 'height': `${setHeight ? setHeight : 90}rpx`,
  29. 'padding': `0 ${padding}rpx`,
  30. }
  31. ]"
  32. >{{item.name}}</text>
  33. </view>
  34. </view>
  35. <view
  36. :style="[
  37. {'height': `${placeHeight ? placeHeight : 90}rpx`}
  38. ]"
  39. >
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. export default {
  45. name: 'app-tab-nav',
  46. props: {
  47. background: String,
  48. setTop: {
  49. type: [Number, String]
  50. },
  51. padding: {
  52. default: 45,
  53. type: [Number, String],
  54. },
  55. setHeight: Number,
  56. placeHeight: Number,
  57. fontSize: Number,
  58. theme: {
  59. type: Object,
  60. },
  61. border: {
  62. default: true,
  63. type: Boolean,
  64. },
  65. shadow: {
  66. default: true,
  67. type: Boolean,
  68. },
  69. activeItem: {
  70. type: [Number, String]
  71. },
  72. tabList: Array
  73. },
  74. methods: {
  75. handleClick(e) {
  76. this.$emit('click', e);
  77. }
  78. },
  79. }
  80. </script>
  81. <style scoped lang="scss">
  82. .app-nav {
  83. color: #353535;
  84. width: 100%;
  85. position: fixed;
  86. left: 0;
  87. background-color: #fff;
  88. z-index: 11;
  89. .nav-item {
  90. text-align: center;
  91. text {
  92. display: inline-block;
  93. }
  94. }
  95. .active-text {
  96. color: #ff4544;
  97. border-bottom: #{4rpx} solid #ff4544;
  98. }
  99. }
  100. .app-nav.shadow {
  101. box-shadow: 0 #{2rpx} #{10rpx} rgba(0, 0, 0, 0.06);
  102. }
  103. .blue-m-text {
  104. color: #446dfd;
  105. }
  106. </style>