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

126 lines
2.7 KiB

6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
5 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 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="widthFix"></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. },
  30. data() {
  31. return {
  32. list : []
  33. };
  34. },
  35. mounted() {
  36. // 初始化国际化的 tabbar 数据
  37. this.list = [
  38. {
  39. "selectedIconPath": "/static/image/tabbar/home-a.png",
  40. "iconPath": "/static/image/tabbar/home.png",
  41. "pagePath": "/pages/index/index",
  42. "title": this.$t('components.base.tabbar.home'), // 首页
  43. key : 'home',
  44. },
  45. {
  46. "selectedIconPath": "/static/image/tabbar/zhaomu-a.png",
  47. "iconPath": "/static/image/tabbar/zhaomu.png",
  48. "pagePath": "/pages/index/member",
  49. "title": this.$t('components.base.tabbar.member'), // 招募
  50. key : 'member',
  51. },
  52. {
  53. "selectedIconPath": "/static/image/tabbar/order-a.png",
  54. "iconPath": "/static/image/tabbar/order.png",
  55. "pagePath": "/pages/index/cart",
  56. "title": this.$t('components.base.tabbar.cart'), // 订单
  57. key : 'cart',
  58. },
  59. {
  60. "selectedIconPath": "/static/image/tabbar/center-a.png",
  61. "iconPath": "/static/image/tabbar/center.png",
  62. "pagePath": "/pages/index/center",
  63. "title": this.$t('components.base.tabbar.center'), // 我的
  64. key : 'center',
  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. }
  85. .tabbar{
  86. position: fixed;
  87. width: 750rpx;
  88. background-color: $uni-color-card-background;
  89. display: flex;
  90. justify-content: center;
  91. align-items: center;
  92. flex-direction: row;
  93. height: 120rpx;
  94. padding-bottom: env(safe-area-inset-bottom);
  95. z-index: 9999;
  96. bottom: 0;
  97. left: 0;
  98. color: #4C4C4C;
  99. border-radius: 67rpx 67rpx 0rpx 0rpx;
  100. .item{
  101. flex: 1;
  102. display: flex;
  103. flex-direction: column;
  104. justify-content: center;
  105. align-items: center;
  106. .icon{
  107. width: 49rpx;
  108. .icon-image{
  109. width: 49rpx;
  110. }
  111. }
  112. .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. }
  122. .active{
  123. color: #F85152 !important;
  124. }
  125. </style>