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

138 lines
3.0 KiB

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