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.

139 lines
2.3 KiB

3 years ago
  1. <template>
  2. <view class="nav-bar b-b">
  3. <view
  4. class="nav-item"
  5. v-for="(item, index) in navs"
  6. :key="index"
  7. @click="navChange(index)"
  8. >
  9. <view class="tit-wrap">
  10. <text class="tit" :class="{'active': current == index}">{{ item.name }}</text>
  11. <text v-if="counts.length > index && counts[index] > 0" class="number">{{ counts[index] }}</text>
  12. </view>
  13. <view class="line" :class="{'line--show': current === index}"></view>
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. /**
  19. * 顶部tab栏
  20. */
  21. export default {
  22. data(){
  23. return {
  24. countList: [],
  25. }
  26. },
  27. props: {
  28. navs: {
  29. type: Array,
  30. default(){
  31. return [];
  32. }
  33. },
  34. current: {
  35. type: Number,
  36. default: 0
  37. },
  38. counts: {
  39. type: Array,
  40. default(){
  41. return [];
  42. }
  43. }
  44. },
  45. watch: {
  46. },
  47. methods: {
  48. navChange(index){
  49. this.$emit('onChange', index);
  50. }
  51. }
  52. }
  53. </script>
  54. <style scoped lang='scss'>
  55. /* #ifndef APP-NVUE */
  56. view{
  57. display: flex;
  58. flex-direction: column;
  59. }
  60. /* #endif */
  61. .fill-view{
  62. height: 84rpx;
  63. width: 100%;
  64. }
  65. .nav-bar{
  66. /* #ifndef APP-NVUE */
  67. display: flex;
  68. /* #endif */
  69. flex-direction: row;
  70. align-items: center;
  71. justify-content: space-around;
  72. width: 750rpx;
  73. height: 84rpx;
  74. background-color: #fff;
  75. z-index: 90;
  76. position: fixed;
  77. left: 0;
  78. top: 0;
  79. /* #ifdef H5 */
  80. top: var(--window-top);
  81. /* #endif */
  82. &:after{
  83. border-color: #f7f7f7;
  84. }
  85. }
  86. .nav-item{
  87. flex: 1;
  88. align-items: center;
  89. justify-content: center;
  90. height: 84rpx;
  91. padding-top: 4rpx;
  92. position: relative;
  93. }
  94. .tit-wrap{
  95. flex: 1;
  96. flex-direction: row;
  97. align-items: center;
  98. justify-content: center;
  99. position: relative;
  100. }
  101. .number{
  102. position: absolute;
  103. right: -20rpx;
  104. top: 0px;
  105. min-width: 36rpx;
  106. height: 36rpx;
  107. padding: 0 6rpx;
  108. text-align: center;
  109. line-height: 28rpx;
  110. border: 4rpx solid #fff;
  111. background-color: $base-color;
  112. border-radius: 100rpx;
  113. font-size: 20rpx;
  114. color: #fff;
  115. }
  116. .tit{
  117. font-size: 30rpx;
  118. color: #333;
  119. }
  120. .active{
  121. color: #ff4443;
  122. font-weight: 700;
  123. }
  124. .line{
  125. width: 34rpx;
  126. height: 4rpx;
  127. border-radius: 100rpx;
  128. background-color: #ff4443;
  129. opacity: 0;
  130. &--show{
  131. opacity: 1;
  132. }
  133. }
  134. </style>