index.vue 2.5 KB

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