tab-bar.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <template>
  2. <van-tabbar :active="tabbarActive" @change="onChange" :placeholder="true" active-color="#E57519"
  3. inactive-color="#7D7D7D">
  4. <template v-for="(item, index) in list">
  5. <van-tabbar-item v-if="index !== 2" :name="item.name" :key="index" :icon="item.icon" icon-prefix="tabbar-icon">
  6. {{ item.text }}
  7. </van-tabbar-item>
  8. <template v-else>
  9. <view class="tabbar-center-item" :class="{ 'active': tabbarActive === item.name } " hover-class="active"
  10. @click="onClickCenter">
  11. <view class="tabbar-center-round">
  12. <view>
  13. <van-icon :name="item.icon" class-prefix="tabbar-icon" />
  14. </view>
  15. </view>
  16. <view class="tabbar-center-text">
  17. {{ item.text }}
  18. </view>
  19. </view>
  20. </template>
  21. </template>
  22. </van-tabbar>
  23. </template>
  24. <script>
  25. export default {
  26. options: {
  27. styleIsolation: 'shared'
  28. },
  29. props: {
  30. active: String
  31. },
  32. data() {
  33. return {
  34. tabbarActive: 'home',
  35. list: [{
  36. name: 'home',
  37. icon: 'home',
  38. text: '首页',
  39. url: '/pages/index'
  40. }, {
  41. name: 'exhibitor',
  42. icon: 'exhibitor',
  43. text: '展商',
  44. url: '/pages/signup/signup'
  45. },
  46. {
  47. name: 'registration',
  48. icon: 'registration',
  49. text: '观众预登记',
  50. url: '/pages/test'
  51. },
  52. {
  53. name: 'activity',
  54. icon: 'activity',
  55. text: '同期活动',
  56. url: '/pages/test'
  57. },
  58. {
  59. name: 'user',
  60. icon: 'user',
  61. text: '个人中心',
  62. url: '/pages/test'
  63. }
  64. ]
  65. }
  66. },
  67. created() {
  68. this.tabbarActive = this.active
  69. },
  70. methods: {
  71. onChange(e) {
  72. this.tabbarActive = e.detail
  73. this.$emit('update:active', e.detail)
  74. this.$emit('change', e.detail)
  75. },
  76. onClickCenter() {
  77. uni.navigateTo({
  78. url: '/pages/components/index'
  79. })
  80. }
  81. }
  82. }
  83. </script>
  84. <style lang="scss">
  85. .van-tabbar-item__text {
  86. font-size: $fontSize2;
  87. color: #7D7D7D;
  88. }
  89. .van-tabbar-item--active {
  90. .van-tabbar-item__text {
  91. color: $textActionColor;
  92. }
  93. }
  94. .tabbar-center-item {
  95. position: relative;
  96. top: -50rpx;
  97. z-index: 1;
  98. flex: 1;
  99. &.active {
  100. .tabbar-center-text {
  101. color: $textActionColor;
  102. }
  103. }
  104. }
  105. .tabbar-center-text {
  106. font-size: $fontSize2;
  107. color: #7D7D7D;
  108. margin-top: 10rpx;
  109. text-align: center;
  110. }
  111. .tabbar-center-round {
  112. @extend .display-flex-center;
  113. width: 100rpx;
  114. height: 100rpx;
  115. border-radius: 50%;
  116. background-color: $buttonPrimaryColor;
  117. margin: auto;
  118. &>view {
  119. @extend .display-flex-center;
  120. width: 96rpx;
  121. height: 96rpx;
  122. border-radius: 50%;
  123. border: 1rpx solid #FFFFFF;
  124. color: #FFFFFF;
  125. background-color: $buttonPrimaryColor;
  126. .tabbar-icon {
  127. font-size: 60rpx;
  128. }
  129. }
  130. }
  131. .tabbar-icon-activity {
  132. font-size: 40rpx;
  133. }
  134. .tabbar-icon-user {
  135. font-size: 48rpx;
  136. }
  137. </style>