tabbar.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <template>
  2. <view class="tabbar">
  3. <view v-for="(item,index) in list" :key="index" class="items" @click="changeMethods(item.pagePath,index)">
  4. <u-image class="icon" width="56rpx" height="56rpx"
  5. :src="item.id == currentIndex ? item.selectedIconPath :item.iconPath" style="margin: auto;"></u-image>
  6. <view :class="{'actives':item.id== currentIndex}">{{item.text}}</view>
  7. </view>
  8. </view>
  9. </template>
  10. <script>
  11. /*
  12. * 自定义底部导航栏
  13. */
  14. export default {
  15. name: "tabbar",
  16. props: ['currentIndex'],
  17. data() {
  18. return {
  19. list: [{
  20. pagePath: "/pages/index/index",
  21. iconPath: "/static/icons/home.png",
  22. selectedIconPath: "/static/icons/home_active.png",
  23. text: this.lang.home,
  24. id: '1'
  25. },
  26. {
  27. pagePath: "/pages/trade/index",
  28. iconPath: "/static/icons/switch.png",
  29. selectedIconPath: "/static/icons/switch_active.png",
  30. text: this.lang.trade,
  31. id: '2'
  32. },
  33. {
  34. pagePath: "/pages/center/capital",
  35. iconPath: "/static/icons/capital.png",
  36. selectedIconPath: "/static/icons/capital_active.png",
  37. text: this.lang.capital,
  38. id: '3'
  39. }
  40. ],
  41. list2: [{
  42. pagePath: "/pages/index/index",
  43. iconPath: "/static/icons/home.png",
  44. selectedIconPath: "/static/icons/home_active.png",
  45. text: this.lang.home,
  46. id: '1'
  47. },
  48. {
  49. pagePath: "/pages/center/capital",
  50. iconPath: "/static/icons/capital.png",
  51. selectedIconPath: "/static/icons/capital_active.png",
  52. text: this.lang.capital,
  53. id: '3'
  54. },
  55. {
  56. pagePath: "/pages/trade/advert",
  57. iconPath: "/static/icons/advert.png",
  58. selectedIconPath: "/static/icons/advert_active.png",
  59. text: this.lang.advert,
  60. id: '4'
  61. }
  62. ],
  63. };
  64. },
  65. created() {
  66. let user_type = uni.getStorageSync('otc.user_type')
  67. user_type = typeof(user_type) != 'undefined' ? user_type : 1;
  68. user_type = user_type > 0 ? user_type : 1;
  69. console.log(user_type)
  70. if (user_type != 1) {
  71. this.list = this.list2
  72. this.$forceUpdate()
  73. }
  74. },
  75. methods: {
  76. //底部导航选择操作
  77. changeMethods(path, index) {
  78. uni.navigateTo({
  79. url: path
  80. })
  81. }
  82. }
  83. }
  84. </script>
  85. <style lang="scss">
  86. .tabbar {
  87. background-color: #32302e;
  88. color: #FFFFFF;
  89. padding: 30rpx;
  90. position: fixed;
  91. bottom: 0px;
  92. width: 100%;
  93. height: 180rpx;
  94. border-top-left-radius: 22rpx;
  95. border-top-right-radius: 22rpx;
  96. text-align: center;
  97. display: flex;
  98. z-index: 99;
  99. }
  100. .u-image {
  101. height: 44rpx !important;
  102. width: 44rpx !important;
  103. margin-bottom: 16rpx !important;
  104. }
  105. .items {
  106. width: 33.3%;
  107. color: #6e6c6b;
  108. text-align: center;
  109. // float: left;
  110. }
  111. .actives {
  112. color: #bb955e;
  113. }
  114. </style>