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

5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
3 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 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. .tabbar {
  79. position: fixed;
  80. width: 750rpx;
  81. background-color: #fff;
  82. display: flex;
  83. justify-content: center;
  84. align-items: center;
  85. flex-direction: row;
  86. height: 120rpx;
  87. padding-bottom: env(safe-area-inset-bottom);
  88. z-index: 999999;
  89. bottom: 0;
  90. left: 0;
  91. color: #000;
  92. .tabbar-item {
  93. flex: 1;
  94. display: flex;
  95. flex-direction: column;
  96. justify-content: center;
  97. align-items: center;
  98. .tabbar-icon {
  99. width: 54rpx;
  100. height: 54rpx;
  101. .tabbar-icon-image {
  102. width: 54rpx;
  103. height: 54rpx;
  104. }
  105. }
  106. .tabbar-title {
  107. overflow: hidden;
  108. white-space: nowrap;
  109. text-overflow: ellipsis;
  110. -o-text-overflow: ellipsis;
  111. font-size: 23rpx;
  112. line-height: 35rpx;
  113. }
  114. }
  115. .tabbar-active {
  116. color: $uni-color !important;
  117. }
  118. }
  119. }
  120. </style>