tab-bar.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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. this.showAlertDialog('功能未开通')
  89. }
  90. }
  91. }
  92. </script>
  93. <style lang="scss">
  94. .u-tabbar{
  95. .van-tabbar{
  96. height: 118rpx;
  97. }
  98. .van-tabbar-item{
  99. display: flex;
  100. flex-direction: column;
  101. justify-content: space-between;
  102. padding-top: 16rpx;
  103. padding-bottom: 16rpx;
  104. }
  105. .van-tabbar-item__icon{
  106. margin-bottom: 0;
  107. }
  108. .van-tabbar-item__text {
  109. font-size: $fontSize3;
  110. color: #7D7D7D;
  111. }
  112. .van-tabbar-item--active {
  113. .van-tabbar-item__text {
  114. color: $textActionColor;
  115. }
  116. }
  117. .tabbar-center-item {
  118. position: relative;
  119. top: -50rpx;
  120. z-index: 1;
  121. flex: 1;
  122. &.active {
  123. .tabbar-center-text {
  124. color: $textActionColor;
  125. }
  126. }
  127. }
  128. .tabbar-center-text {
  129. font-size: $fontSize3;
  130. color: #7D7D7D;
  131. margin-top: 18rpx;
  132. text-align: center;
  133. }
  134. .tabbar-center-round {
  135. @include display-flex-center;
  136. width: 100rpx;
  137. height: 100rpx;
  138. border-radius: 50%;
  139. background-color: $buttonPrimaryColor;
  140. margin: auto;
  141. &>view {
  142. @include display-flex-center;
  143. width: 96rpx;
  144. height: 96rpx;
  145. border-radius: 50%;
  146. border: 1rpx solid #FFFFFF;
  147. color: #FFFFFF;
  148. background-color: $buttonPrimaryColor;
  149. .tabbar-icon {
  150. font-size: 60rpx;
  151. }
  152. }
  153. }
  154. .tabbar-icon-activity {
  155. font-size: 40rpx;
  156. }
  157. .tabbar-icon-user {
  158. font-size: 46rpx;
  159. }
  160. }
  161. </style>