珠宝小程序前端代码
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

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