index.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <template>
  2. <view class="bottom_tabbar">
  3. <view v-for="(item, index) in list" :key="index" @click="changeTabbar(index)">
  4. <image :src="tabbarValue === index ? item.activeImg : item.inactiveImg"></image>
  5. <text :class="{ active: tabbarValue === index }">{{ item.text }}</text>
  6. </view>
  7. </view>
  8. </template>
  9. <script setup>
  10. import { ref, onMounted, watch } from 'vue';
  11. const props = defineProps({
  12. tabbarIndex: {
  13. type: Number,
  14. default: 0
  15. }
  16. });
  17. const tabbarValue = ref(0);
  18. const list = ref([
  19. {
  20. inactiveImg: 'https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/11/cecc3397-5844-4bce-8965-232ea046b67e.png',
  21. activeImg: 'https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/11/4e81c0b3-b6c4-4aa2-9ce5-ad6a2a256499.png',
  22. text: '首页',
  23. path: '/pages/home'
  24. },
  25. {
  26. inactiveImg: 'https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/11/57824411-6c16-4b39-a28f-0a640178416c.png',
  27. activeImg: 'https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/11/7d00fc58-b738-4ab5-bb4a-cd95a080ec2b.png',
  28. text: '公益',
  29. path: '/pages/nonprofit'
  30. },
  31. {
  32. inactiveImg: 'https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/11/44e4a6e4-1d85-4b32-bed8-db2129137dc5.png',
  33. activeImg: 'https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/11/56acd490-8ca6-4e30-8d1b-5ece55a3ad3c.png',
  34. text: '我的',
  35. path: '/pages/my'
  36. }
  37. ]);
  38. watch(() => props.tabbarIndex,(newVal) => {
  39. tabbarValue.value = newVal;
  40. });
  41. onMounted(() => {
  42. tabbarValue.value = props.tabbarIndex;
  43. });
  44. const changeTabbar = (e) => {
  45. tabbarValue.value = e;
  46. uni.reLaunch({
  47. url: list.value[e].path
  48. });
  49. };
  50. </script>
  51. <style scoped lang="scss">
  52. .bottom_tabbar {
  53. width: 100%;
  54. height: 164rpx;
  55. background: #ffffff;
  56. display: flex;
  57. position: fixed;
  58. left: 0;
  59. bottom: 0;
  60. z-index: 999;
  61. padding-top: 19rpx;
  62. box-sizing: border-box;
  63. box-shadow: 0rpx -2rpx 8rpx 0rpx rgba(0, 0, 0, 0.06);
  64. & > view {
  65. width: calc(100% / 2);
  66. height: 100%;
  67. display: flex;
  68. flex-direction: column;
  69. align-items: center;
  70. image {
  71. width: 48rpx;
  72. height: 48rpx;
  73. margin-bottom: 12rpx;
  74. }
  75. text {
  76. font-family: PingFangSC, PingFang SC;
  77. font-weight: 400;
  78. font-size: 24rpx;
  79. color: #B2B2B2;
  80. line-height: 30rpx;
  81. text-align: center;
  82. &.active {
  83. font-weight: bold;
  84. color: #151B29;
  85. }
  86. }
  87. }
  88. }
  89. </style>