敢为人鲜小程序前端代码仓库
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.

127 lines
2.7 KiB

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