en-tab.vue 3.5 KB

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