鸿宇研学生前端代码
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.

120 lines
2.5 KiB

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