推拿小程序前端代码仓库
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.

124 lines
2.6 KiB

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