cu-tabbar.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <template>
  2. <view class="content">
  3. <!-- isIphoneX判断是否为刘海屏在main.js里,好像uniapp有一个css变量获取刘海屏的安全区域 -->
  4. <view class="tabBar" :style="{height:isIphoneX?'140rpx':'98rpx'}">
  5. <view class="tabBar_list" :style="{paddingBottom:isIphoneX?'40rpx':''}">
  6. <view @tap="cut_index('/seller/pages/home/home')" class="tabBar_item">
  7. <image v-if="show_index == 0" src="../static/icon-home-active@3x.png"></image>
  8. <image v-else src="../static/icon-home@3x.png"></image>
  9. <view :class="{'tabBar_name':true,'nav_active':show_index == 0}">首页</view>
  10. </view>
  11. <view @tap="cut_index('/seller/pages/category/category')" class="tabBar_item">
  12. <image v-if="show_index == 1" src="../static/icon-sort-active@3x.png"></image>
  13. <image v-else src="../static/icon-sort@3x.png"></image>
  14. <view :class="{'tabBar_name':true,'nav_active':show_index == 1}">分类</view>
  15. </view>
  16. <view @tap="cut_index('/seller/pages/user/user')" class="tabBar_item">
  17. <image v-if="show_index == 2" src="../static/icon-user-active@3x.png"></image>
  18. <image v-else src="../static/icon-user@3x.png"></image>
  19. <view :class="{'tabBar_name':true,'nav_active':show_index == 2}">我的</view>
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. export default {
  27. props:{
  28. activeIndex:{
  29. type:Number
  30. }
  31. },
  32. data() {
  33. return {
  34. show_index:0,//控制显示那个组件
  35. isIphoneX:this.$store.state.isIphoneX
  36. }
  37. },
  38. created() {
  39. this.show_index = this.activeIndex
  40. },
  41. methods: {
  42. // 切换组件
  43. cut_index(url){
  44. this.$api.navigateTo(url)
  45. }
  46. }
  47. }
  48. </script>
  49. <style lang="scss">
  50. .tabBar{
  51. width:100%;
  52. height: 98rpx;
  53. background: #fff;
  54. border-top:1px solid #E5E5E5;
  55. position: fixed;
  56. bottom:0px;
  57. left:0px;
  58. right:0px;
  59. display: flex;
  60. align-items: center;
  61. justify-content: center;
  62. .tabBar_list{
  63. width:86%;
  64. display: flex;
  65. justify-content: space-between;
  66. image{
  67. width:48rpx;
  68. height: 48rpx;
  69. margin-bottom:2rpx
  70. }
  71. .tabBar_item{
  72. width:68rpx;
  73. display: flex;
  74. justify-content: center;
  75. align-items: center;
  76. flex-direction: column;
  77. font-size: 20rpx;
  78. color: #999999;
  79. }
  80. }
  81. }
  82. .nav_active{
  83. color: $color-system;
  84. }
  85. </style>