en-tab.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <template>
  2. <view class="">
  3. <view class="tab-box tab_height sys-background-fff">
  4. <view class="tab-item " :class="{'tab-check':tabIndex==index}" @click="setTab(item.path,index)"
  5. v-for="(item,index) in tabList" :key="index">
  6. <view class="tab-content">
  7. <image class="tab-img"
  8. :src="`https://wealfavor-1257406827.cos.ap-beijing.myqcloud.com/new-xcx/tabBar/${tabIndex==index?item.selectedIconPath:item.iconPath}.png`">
  9. </image>
  10. <view class="tab-text sys-size-24 text-color-dominant">{{item.name}}</view>
  11. </view>
  12. </view>
  13. <!-- <view class="tab-item" :class="{'tab-check':tabIndex===2}" @click="setTab(2)">
  14. <view class="tab-content">
  15. <image v-if="tabIndex===2" class="tab-img" src="https://wealfavor-1257406827.cos.ap-beijing.myqcloud.com/new-xcx/tabBar/task-select.png"></image>
  16. <image v-else class="tab-img" src="https://wealfavor-1257406827.cos.ap-beijing.myqcloud.com/new-xcx/tabBar/task-default.png"></image>
  17. <view class="tab-text sys-size-24 text-color-dominant">任务</view>
  18. </view>
  19. </view>
  20. <view class="tab-item" :class="{'tab-check':tabIndex===3}" @click="setTab(3)">
  21. <view class="tab-content">
  22. <image v-if="tabIndex===3" class="tab-img" src="https://wealfavor-1257406827.cos.ap-beijing.myqcloud.com/new-xcx/tabBar/loan-select.png"></image>
  23. <image v-else class="tab-img" src="https://wealfavor-1257406827.cos.ap-beijing.myqcloud.com/new-xcx/tabBar/loan-default.png"></image>
  24. <view class="tab-text sys-size-24 text-color-dominant ">贷后</view>
  25. </view>
  26. </view>
  27. <view class="tab-item" :class="{'tab-check':tabIndex===4}" @click="setTab(3)">
  28. <view class="tab-content">
  29. <image v-if="tabIndex===4" class="tab-img" src="https://wealfavor-1257406827.cos.ap-beijing.myqcloud.com/new-xcx/tabBar/statistics-select.png"></image>
  30. <image v-else class="tab-img" src="https://wealfavor-1257406827.cos.ap-beijing.myqcloud.com/new-xcx/tabBar/statistics-default.png"></image>
  31. <view class="tab-text sys-size-24 text-color-dominant ">统计</view>
  32. </view>
  33. </view> -->
  34. </view>
  35. <view class="zw">
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. export default {
  41. name: 'en-tab',
  42. props: {
  43. 'tabIndex': {
  44. default: 0
  45. }
  46. },
  47. data() {
  48. return {
  49. tabList: [{
  50. name: '首页',
  51. path: '/pages/loan/loan',
  52. iconPath: 'loan-default',
  53. selectedIconPath: 'loan-select',
  54. },
  55. {
  56. name: '市场',
  57. path: '/pages/index/index',
  58. iconPath: 'home-default',
  59. selectedIconPath: 'home-select',
  60. },
  61. {
  62. name: '任务',
  63. path: '/pages/task/task',
  64. iconPath: 'task-default',
  65. selectedIconPath: 'task-select',
  66. },
  67. // {
  68. // name: '统计',
  69. // path: '/pages/statistics/statistics',
  70. // iconPath: 'statistics-default',
  71. // selectedIconPath: 'statistics-select',
  72. // },
  73. ]
  74. };
  75. },
  76. created() {
  77. this.getTabHeight()
  78. },
  79. methods: {
  80. setTab(path) {
  81. console.log(path)
  82. uni.switchTab({
  83. url: path
  84. })
  85. },
  86. getTabHeight() {
  87. const query = uni.createSelectorQuery().in(this);
  88. query.select('.tab_height').boundingClientRect(data => {
  89. if (data) {
  90. // data.height 就是元素的高度
  91. uni.setStorageSync('tab_height', data.height)
  92. }
  93. }).exec();
  94. }
  95. },
  96. }
  97. </script>
  98. <style lang="scss">
  99. .zw {
  100. height: 120rpx;
  101. }
  102. .tab-box {
  103. display: flex;
  104. justify-content: space-around;
  105. height: 120rpx;
  106. padding-bottom: 14rpx;
  107. position: fixed;
  108. bottom: 0;
  109. padding-bottom: env(safe-area-inset-bottom);
  110. width: 100%;
  111. .tab-item {
  112. // width: 50%;
  113. display: flex;
  114. justify-content: center;
  115. .tab-content {
  116. padding-top: 25rpx;
  117. width: 108rpx;
  118. height: 130rpx;
  119. box-sizing: border-box;
  120. border-radius: 0 0 100rpx 100rpx;
  121. text-align: center;
  122. .tab-img {
  123. width: 42rpx;
  124. height: 42rpx;
  125. }
  126. .tab-text {
  127. font-weight: 400;
  128. line-height: 34rpx;
  129. color: #333333;
  130. }
  131. }
  132. }
  133. .tab-check {
  134. .tab-content {
  135. background-color: rgba(15, 177, 128, 0.1);
  136. .tab-text {
  137. font-weight: 500;
  138. color: #0FB180;
  139. }
  140. }
  141. }
  142. }
  143. </style>