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

105 lines
2.0 KiB

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. "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. };
  39. },
  40. methods: {
  41. toPath(item, index) {
  42. if (item.key == this.select) {
  43. return
  44. }
  45. uni.reLaunch({
  46. url: item.pagePath
  47. })
  48. },
  49. }
  50. }
  51. </script>
  52. <style scoped lang="scss">
  53. .tabbar-box {
  54. height: 120rpx;
  55. padding-bottom: env(safe-area-inset-bottom);
  56. .tabbar {
  57. position: fixed;
  58. width: 750rpx;
  59. background-color: #fff;
  60. display: flex;
  61. justify-content: center;
  62. align-items: center;
  63. flex-direction: row;
  64. height: 120rpx;
  65. padding-bottom: env(safe-area-inset-bottom);
  66. z-index: 999999;
  67. bottom: 0;
  68. left: 0;
  69. color: #BCBCBC;
  70. .tabbar-item {
  71. flex: 1;
  72. display: flex;
  73. flex-direction: column;
  74. justify-content: center;
  75. align-items: center;
  76. .tabbar-icon {
  77. width: 54rpx;
  78. height: 54rpx;
  79. .tabbar-icon-image {
  80. width: 54rpx;
  81. height: 54rpx;
  82. }
  83. }
  84. .tabbar-title {
  85. overflow: hidden;
  86. white-space: nowrap;
  87. text-overflow: ellipsis;
  88. -o-text-overflow: ellipsis;
  89. font-size: 23rpx;
  90. line-height: 35rpx;
  91. }
  92. }
  93. .tabbar-active {
  94. color: $uni-color !important;
  95. }
  96. }
  97. }
  98. </style>