普兆健康管家前端代码仓库
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.

125 lines
2.6 KiB

2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months 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/user-center-active.png",
  51. "iconPath": "/static/image/tabbar/user-center.png",
  52. "pagePath": "/pages/index/center",
  53. "title": "我的",
  54. key: 'center',
  55. },
  56. ]
  57. };
  58. },
  59. methods: {
  60. toPath(item, index) {
  61. if (item.key == this.select) {
  62. return
  63. }
  64. uni.reLaunch({
  65. url: item.pagePath
  66. })
  67. },
  68. }
  69. }
  70. </script>
  71. <style scoped lang="scss">
  72. .tabbar-box {
  73. height: $tabbar-height;
  74. padding-bottom: env(safe-area-inset-bottom);
  75. .tabbar {
  76. position: fixed;
  77. width: 750rpx;
  78. background-color: #fff;
  79. display: flex;
  80. justify-content: center;
  81. align-items: center;
  82. flex-direction: row;
  83. height: $tabbar-height;
  84. padding-bottom: env(safe-area-inset-bottom);
  85. z-index: 999999;
  86. bottom: 0;
  87. left: 0;
  88. color: #BCBCBC;
  89. .tabbar-item {
  90. flex: 1;
  91. display: flex;
  92. flex-direction: column;
  93. justify-content: center;
  94. align-items: center;
  95. .tabbar-icon {
  96. width: 54rpx;
  97. height: 54rpx;
  98. .tabbar-icon-image {
  99. width: 54rpx;
  100. height: 54rpx;
  101. }
  102. }
  103. .tabbar-title {
  104. overflow: hidden;
  105. white-space: nowrap;
  106. text-overflow: ellipsis;
  107. -o-text-overflow: ellipsis;
  108. font-size: 23rpx;
  109. line-height: 35rpx;
  110. }
  111. }
  112. .tabbar-active {
  113. color: $uni-color !important;
  114. }
  115. }
  116. }
  117. </style>