tab-bar.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <template>
  2. <van-tabbar class="u-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. import VanTabbar from '@/wxcomponents/vant/tabbar/index'
  26. import VanTabbarItem from '@/wxcomponents/vant/tabbar-item/index'
  27. export default {
  28. options: {
  29. styleIsolation: 'shared'
  30. },
  31. components: {
  32. VanTabbar,
  33. VanTabbarItem
  34. },
  35. props: {
  36. active: String
  37. },
  38. watch: {
  39. active(val) {
  40. this.tabbarActive = val
  41. }
  42. },
  43. data() {
  44. return {
  45. tabbarActive: 'home',
  46. list: [{
  47. name: 'home',
  48. icon: 'home',
  49. text: '首页',
  50. url: '/pages/index'
  51. }, {
  52. name: 'exhibitor',
  53. icon: 'exhibitor',
  54. text: '展商',
  55. url: '/pages/signup/signup'
  56. },
  57. {
  58. name: 'registration',
  59. icon: 'registration',
  60. text: '观众预登记',
  61. url: '/pages/test'
  62. },
  63. {
  64. name: 'activity',
  65. icon: 'activity',
  66. text: '同期活动',
  67. url: '/pages/test'
  68. },
  69. {
  70. name: 'user',
  71. icon: 'user',
  72. text: '个人中心',
  73. url: '/pages/test'
  74. }
  75. ]
  76. }
  77. },
  78. created() {
  79. this.tabbarActive = this.active
  80. },
  81. methods: {
  82. onChange(active) {
  83. this.tabbarActive = active
  84. this.$emit('update:active', active)
  85. this.$emit('change', active)
  86. },
  87. onClickCenter() {
  88. uni.navigateTo({
  89. url: '/pages/components/index'
  90. })
  91. }
  92. }
  93. }
  94. </script>
  95. <style lang="scss">
  96. .u-tabbar{
  97. .van-tabbar-item__text {
  98. font-size: $fontSize2;
  99. color: #7D7D7D;
  100. }
  101. .van-tabbar-item--active {
  102. .van-tabbar-item__text {
  103. color: $textActionColor;
  104. }
  105. }
  106. .tabbar-center-item {
  107. position: relative;
  108. top: -50rpx;
  109. z-index: 1;
  110. flex: 1;
  111. &.active {
  112. .tabbar-center-text {
  113. color: $textActionColor;
  114. }
  115. }
  116. }
  117. .tabbar-center-text {
  118. font-size: $fontSize2;
  119. color: #7D7D7D;
  120. margin-top: 10rpx;
  121. text-align: center;
  122. }
  123. .tabbar-center-round {
  124. @include display-flex-center;
  125. width: 100rpx;
  126. height: 100rpx;
  127. border-radius: 50%;
  128. background-color: $buttonPrimaryColor;
  129. margin: auto;
  130. &>view {
  131. @include display-flex-center;
  132. width: 96rpx;
  133. height: 96rpx;
  134. border-radius: 50%;
  135. border: 1rpx solid #FFFFFF;
  136. color: #FFFFFF;
  137. background-color: $buttonPrimaryColor;
  138. .tabbar-icon {
  139. font-size: 60rpx;
  140. }
  141. }
  142. }
  143. .tabbar-icon-activity {
  144. font-size: 40rpx;
  145. }
  146. .tabbar-icon-user {
  147. font-size: 48rpx;
  148. }
  149. }
  150. </style>