en-tab.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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. uni.switchTab({
  82. url: path
  83. })
  84. },
  85. getTabHeight() {
  86. const query = uni.createSelectorQuery().in(this);
  87. query.select('.tab_height').boundingClientRect(data => {
  88. if (data) {
  89. // data.height 就是元素的高度
  90. uni.setStorageSync('tab_height', data.height)
  91. }
  92. }).exec();
  93. }
  94. },
  95. }
  96. </script>
  97. <style lang="scss">
  98. .zw {
  99. height: 120rpx;
  100. }
  101. .tab-box {
  102. display: flex;
  103. justify-content: space-around;
  104. height: 120rpx;
  105. padding-bottom: 14rpx;
  106. position: fixed;
  107. bottom: 0;
  108. padding-bottom: env(safe-area-inset-bottom);
  109. width: 100%;
  110. .tab-item {
  111. // width: 50%;
  112. display: flex;
  113. justify-content: center;
  114. .tab-content {
  115. padding-top: 25rpx;
  116. width: 108rpx;
  117. height: 130rpx;
  118. box-sizing: border-box;
  119. border-radius: 0 0 100rpx 100rpx;
  120. text-align: center;
  121. .tab-img {
  122. width: 42rpx;
  123. height: 42rpx;
  124. }
  125. .tab-text {
  126. font-weight: 400;
  127. line-height: 34rpx;
  128. color: #333333;
  129. }
  130. }
  131. }
  132. .tab-check {
  133. .tab-content {
  134. background-color: rgba(15, 177, 128, 0.1);
  135. .tab-text {
  136. font-weight: 500;
  137. color: #0FB180;
  138. }
  139. }
  140. }
  141. }
  142. </style>