普兆健康管家前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

133 lines
2.9 KiB

1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
  1. <template>
  2. <view class="tabbar-box">
  3. <view class="tabbar">
  4. <view
  5. :class="{ 'tabbar-active' : select == item.key}"
  6. v-for="(item, index) in list" :key="index"
  7. @click="toPath(item, index)" class="tabbar-item"
  8. >
  9. <view class="tabbar-icon">
  10. <image :src="select == item.key ?
  11. item.selectedIconPath :
  12. item.iconPath" class="tabbar-icon-image" mode="aspectFill"></image>
  13. </view>
  14. <view class="tabbar-title">
  15. {{ item.title }}
  16. </view>
  17. </view>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. export default {
  23. name: "tabbar",
  24. props: ['select'],
  25. data() {
  26. return {
  27. list: [
  28. {
  29. "selectedIconPath": "/static/image/tabbar/home-active.png",
  30. "iconPath": "/static/image/tabbar/home.png",
  31. "pagePath": "/pages/index/index",
  32. "title": "首页",
  33. key: 'home',
  34. },
  35. {
  36. "selectedIconPath": "/static/image/tabbar/report-active.png",
  37. "iconPath": "/static/image/tabbar/report.png",
  38. "pagePath": "/pages/index/report",
  39. "title": "报告",
  40. key: 'report',
  41. },
  42. {
  43. "selectedIconPath": "/static/image/tabbar/product-active.png",
  44. "iconPath": "/static/image/tabbar/product.png",
  45. "pagePath": "/pages/index/product",
  46. "title": "产品",
  47. key: 'product',
  48. },
  49. {
  50. "selectedIconPath": "/static/image/tabbar/cart-active.png",
  51. "iconPath": "/static/image/tabbar/cart.png",
  52. "pagePath": "/pages/index/cart",
  53. "title": "购物车",
  54. key: 'cart',
  55. },
  56. {
  57. "selectedIconPath": "/static/image/tabbar/user-center-active.png",
  58. "iconPath": "/static/image/tabbar/user-center.png",
  59. "pagePath": "/pages/index/center",
  60. "title": "我的",
  61. key: 'center',
  62. },
  63. ]
  64. };
  65. },
  66. methods: {
  67. toPath(item, index) {
  68. if (item.key == this.select) {
  69. return
  70. }
  71. uni.reLaunch({
  72. url: item.pagePath
  73. })
  74. },
  75. }
  76. }
  77. </script>
  78. <style scoped lang="scss">
  79. .tabbar-box {
  80. height: $tabbar-height;
  81. padding-bottom: env(safe-area-inset-bottom);
  82. .tabbar {
  83. position: fixed;
  84. width: 750rpx;
  85. background-color: #fff;
  86. display: flex;
  87. justify-content: center;
  88. align-items: center;
  89. flex-direction: row;
  90. height: $tabbar-height;
  91. padding-bottom: env(safe-area-inset-bottom);
  92. z-index: 999999;
  93. bottom: 0;
  94. left: 0;
  95. color: #BCBCBC;
  96. border-top: 2rpx solid #F1F1F1;
  97. .tabbar-item {
  98. flex: 1;
  99. display: flex;
  100. flex-direction: column;
  101. justify-content: center;
  102. align-items: center;
  103. .tabbar-icon {
  104. width: 54rpx;
  105. height: 54rpx;
  106. .tabbar-icon-image {
  107. width: 54rpx;
  108. height: 54rpx;
  109. }
  110. }
  111. .tabbar-title {
  112. overflow: hidden;
  113. white-space: nowrap;
  114. text-overflow: ellipsis;
  115. -o-text-overflow: ellipsis;
  116. font-size: 23rpx;
  117. line-height: 35rpx;
  118. }
  119. }
  120. .tabbar-active {
  121. color: $uni-color !important;
  122. }
  123. }
  124. }
  125. </style>