tab-bar.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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: 'iconfont icon-bishi',
  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.$store.commit('SET_PAGE', active)
  84. this.tabbarActive = active
  85. if (this.tabbarActive === 'home') {
  86. uni.setNavigationBarTitle({
  87. title: '慕尼黑上海电子生产设备展'
  88. });
  89. } else if (this.tabbarActive === 'exhibitor') {
  90. uni.setNavigationBarTitle({
  91. title: '展商'
  92. });
  93. } else if (this.tabbarActive === 'activity') {
  94. uni.setNavigationBarTitle({
  95. title: '同期活动'
  96. });
  97. } else if (this.tabbarActive === 'user') {
  98. uni.setNavigationBarTitle({
  99. title: '个人中心'
  100. });
  101. }
  102. this.$emit('update:active', active)
  103. this.$emit('change', active)
  104. },
  105. onClickCenter() {
  106. this.navigateTo('https://pc.global-eservice.com/h5/?lang=cn&channel=xcx#/')
  107. }
  108. }
  109. }
  110. </script>
  111. <style lang="scss">
  112. .u-tabbar{
  113. .van-tabbar{
  114. height: 118rpx;
  115. }
  116. .van-tabbar-item{
  117. display: flex;
  118. flex-direction: column;
  119. justify-content: space-between;
  120. padding-top: 16rpx;
  121. padding-bottom: 16rpx;
  122. }
  123. .van-tabbar-item__icon{
  124. margin-bottom: 0;
  125. }
  126. .van-tabbar-item__text {
  127. font-size: $fontSize1;
  128. color: #7D7D7D;
  129. }
  130. .van-tabbar-item--active {
  131. .van-tabbar-item__text {
  132. color: $textActionColor;
  133. }
  134. }
  135. .tabbar-center-item {
  136. position: relative;
  137. top: -50rpx;
  138. z-index: 1;
  139. flex: 1;
  140. &.active {
  141. .tabbar-center-text {
  142. color: $textActionColor;
  143. }
  144. }
  145. }
  146. .tabbar-center-text {
  147. font-size: $fontSize2;
  148. color: #7D7D7D;
  149. margin-top: 18rpx;
  150. text-align: center;
  151. }
  152. .tabbar-center-round {
  153. @include display-flex-center;
  154. width: 100rpx;
  155. height: 100rpx;
  156. border-radius: 50%;
  157. background-color: $buttonPrimaryColor;
  158. margin: auto;
  159. &>view {
  160. @include display-flex-center;
  161. width: 96rpx;
  162. height: 96rpx;
  163. border-radius: 50%;
  164. border: 1rpx solid #FFFFFF;
  165. color: #FFFFFF;
  166. background-color: $buttonPrimaryColor;
  167. .tabbar-icon {
  168. font-size: 60rpx;
  169. }
  170. }
  171. }
  172. .tabbar-icon-activity {
  173. font-size: 40rpx;
  174. }
  175. .tabbar-icon-user {
  176. font-size: 46rpx;
  177. }
  178. }
  179. </style>