小说小程序前端代码仓库(小程序)
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.8 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
  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. @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. export default {
  20. name: "tabbar",
  21. props: ['select'],
  22. computed: {
  23. },
  24. data() {
  25. return {
  26. list: [{
  27. "selectedIconPath": "/static/image/tabbar/home-a.png",
  28. "iconPath": "/static/image/tabbar/home.png",
  29. "pagePath": "/pages/index/index",
  30. "title": "精品推荐",
  31. key: 'home',
  32. },
  33. {
  34. "selectedIconPath": "/static/image/tabbar/category-a.png",
  35. "iconPath": "/static/image/tabbar/category.png",
  36. "pagePath": "/pages/index/category",
  37. "title": "书城",
  38. key: 'category',
  39. },
  40. {
  41. "selectedIconPath": "/static/image/tabbar/bookshelf-a.png",
  42. "iconPath": "/static/image/tabbar/bookshelf.png",
  43. "pagePath": "/pages/index/bookshelf",
  44. "title": "书架",
  45. key: 'bookshelf',
  46. },
  47. {
  48. "selectedIconPath": "/static/image/tabbar/center-a.png",
  49. "iconPath": "/static/image/tabbar/center.png",
  50. "pagePath": "/pages/index/center",
  51. "title": "我的",
  52. key: 'center',
  53. },
  54. ]
  55. };
  56. },
  57. methods: {
  58. toPath(item, index) {
  59. if (item.key == this.select) {
  60. return
  61. }
  62. uni.reLaunch({
  63. url: item.pagePath
  64. })
  65. },
  66. }
  67. }
  68. </script>
  69. <style scoped lang="scss">
  70. .tabbar-box {
  71. height: 120rpx;
  72. padding-bottom: env(safe-area-inset-bottom);
  73. .tabbar {
  74. position: fixed;
  75. width: 750rpx;
  76. background-color: #fff;
  77. display: flex;
  78. justify-content: center;
  79. align-items: center;
  80. flex-direction: row;
  81. height: 120rpx;
  82. padding-bottom: env(safe-area-inset-bottom);
  83. z-index: 999999;
  84. bottom: 0;
  85. left: 0;
  86. color: #BCBCBC;
  87. border-top: 2rpx solid #BCBCBC;;
  88. .tabbar-item {
  89. flex: 1;
  90. display: flex;
  91. flex-direction: column;
  92. justify-content: center;
  93. align-items: center;
  94. .tabbar-icon {
  95. width: 54rpx;
  96. height: 54rpx;
  97. .tabbar-icon-image {
  98. width: 54rpx;
  99. height: 54rpx;
  100. }
  101. }
  102. .tabbar-title {
  103. overflow: hidden;
  104. white-space: nowrap;
  105. text-overflow: ellipsis;
  106. -o-text-overflow: ellipsis;
  107. font-size: 23rpx;
  108. line-height: 35rpx;
  109. }
  110. }
  111. .tabbar-active {
  112. color: $uni-color !important;
  113. .tabbar-icon {
  114. width: 94rpx;
  115. height: 94rpx;
  116. margin-top: -40rpx;
  117. .tabbar-icon-image {
  118. width: 94rpx;
  119. height: 94rpx;
  120. }
  121. }
  122. }
  123. }
  124. }
  125. </style>