erp-tab-bar.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <template>
  2. <view class="tab-bar-container">
  3. <view class="tab-bar-content">
  4. <view class="tab-item" @click="switchTab('home')" :class="{ active: active === 'home' }">
  5. <image class="tab-icon"
  6. :src="active === 'home' ? '/static/tabs/home_active.png' : '/static/tabs/home.png'"
  7. mode="aspectFit"></image>
  8. <text class="tab-text">首页</text>
  9. </view>
  10. <view class="tab-item" @click="switchTab('client')" :class="{ active: active === 'client' }">
  11. <image class="tab-icon"
  12. :src="active === 'client' ? '/static/tabs/client_active.png' : '/static/tabs/client.png'"
  13. mode="aspectFit"></image>
  14. <text class="tab-text">客户</text>
  15. </view>
  16. <view class="tab-item" @click="switchTab('mine')" :class="{ active: active === 'mine' }">
  17. <image class="tab-icon"
  18. :src="active === 'mine' ? '/static/tabs/mine_active.png' : '/static/tabs/mine.png'"
  19. mode="aspectFit"></image>
  20. <text class="tab-text">我的</text>
  21. </view>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. export default {
  27. props: {
  28. active: { type: String, default: 'client' }
  29. },
  30. methods: {
  31. switchTab(code) {
  32. let url = '';
  33. switch (code) {
  34. case 'home': url = '/pages/index/index'; break;
  35. case 'client': url = '/pages/client/index'; break;
  36. case 'mine': url = '/pages/mine/index'; break;
  37. }
  38. if (url) uni.reLaunch({ url });
  39. }
  40. }
  41. }
  42. </script>
  43. <style scoped>
  44. .tab-bar-container {
  45. position: fixed;
  46. bottom: 0;
  47. left: 0;
  48. right: 0;
  49. z-index: 999;
  50. display: flex;
  51. flex-direction: column;
  52. background: rgba(255, 255, 255, 0.98);
  53. backdrop-filter: blur(10px);
  54. box-shadow: 0 -4rpx 30rpx rgba(0, 0, 0, 0.06);
  55. padding-bottom: env(safe-area-inset-bottom);
  56. }
  57. .tab-bar-content {
  58. position: relative;
  59. z-index: 2;
  60. height: 100rpx;
  61. display: flex;
  62. align-items: center;
  63. justify-content: space-around;
  64. }
  65. .tab-item {
  66. flex: 1;
  67. display: flex;
  68. flex-direction: column;
  69. align-items: center;
  70. justify-content: center;
  71. height: 100%;
  72. }
  73. .tab-icon {
  74. width: 52rpx;
  75. height: 52rpx;
  76. margin-bottom: 4rpx;
  77. display: block;
  78. }
  79. .tab-text {
  80. font-size: 22rpx;
  81. color: #999;
  82. line-height: 1;
  83. }
  84. .tab-item.active .tab-text {
  85. color: #C1001C;
  86. font-weight: 600;
  87. }
  88. .tab-item.active .tab-icon {
  89. transform: none;
  90. }
  91. </style>