erp-tab-bar.vue 2.3 KB

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