x-navbottom.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <template>
  2. <!-- 底部tabbar -->
  3. <view class="navmainbox">
  4. <view class="navigation">
  5. <view class="navcont" v-for="(item,index) in dataList" :key="index" @click="gonavs(item,index)">
  6. <span class="iconfont icon_image" :class="[item.icon,nowchos == index ? 'activeName' :'']"></span>
  7. <view class="navchosbox" :class="nowchos == index ? 'activeName' :''">
  8. {{item.title}}
  9. </view>
  10. </view>
  11. </view>
  12. <!-- //防止 固定的底部菜单遮挡页面上的内容 -->
  13. <view class="navmainbox" style="position: relative;opacity: 0;z-index: 0;">
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. export default {
  19. name: 'x-navbottom',
  20. props: {
  21. nowchos: {
  22. type: Number,
  23. default () {
  24. return 0
  25. }
  26. },
  27. },
  28. data() {
  29. return {
  30. dataList: [],
  31. list: [{
  32. icon: 'icon-shouye1',
  33. title: '首页',
  34. }, {
  35. icon: 'icon-dingdan2',
  36. title: '订单',
  37. },
  38. {
  39. icon: 'icon-yehuaqiping',
  40. title: '我的钢瓶',
  41. },
  42. {
  43. icon: 'icon-icon-test',
  44. title: '我的',
  45. }
  46. ],
  47. gasList: [{
  48. icon: 'icon-shouye1',
  49. title: '首页',
  50. }, {
  51. icon: 'icon-yehuaqiping',
  52. title: '我的钢瓶',
  53. }, {
  54. icon: 'icon-icon-test',
  55. title: '我的',
  56. }],
  57. }
  58. },
  59. mounted() {
  60. var userInfo = this.$cache.getCache('userInfo')
  61. if (userInfo.provUser) {
  62. if (userInfo.provUser.isorders == 0 && userInfo.provUser.userType == 3) {
  63. this.dataList = this.list
  64. } else {
  65. this.dataList = this.gasList
  66. }
  67. } else {
  68. this.dataList = this.list
  69. }
  70. },
  71. methods: {
  72. gonavs(e, cindex) {
  73. this.$emit('botomchos', cindex)
  74. }
  75. }
  76. }
  77. </script>
  78. <style lang="scss">
  79. .navmainbox {
  80. position: fixed;
  81. bottom: 0;
  82. left: 0;
  83. z-index: 5;
  84. background-color: #ffffff;
  85. box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.1);
  86. width: 100%;
  87. height: 100rpx;
  88. padding-bottom: constant(safe-area-inset-bottom); //兼容 IOS<11.2
  89. padding-bottom: env(safe-area-inset-bottom); //兼容 IOS>11.2
  90. }
  91. .navigation {
  92. z-index: 2024;
  93. position: relative;
  94. display: flex;
  95. justify-content: center;
  96. align-items: center;
  97. height: 100rpx;
  98. padding-bottom: var(--window-bottom);
  99. }
  100. .navigation .navcont {
  101. position: relative;
  102. display: flex;
  103. flex-direction: column;
  104. align-items: center;
  105. flex: 1;
  106. }
  107. .navchosbox {
  108. color: #727289 !important;
  109. margin-top: 2rpx;
  110. font-size: 26rpx;
  111. }
  112. .activeName {
  113. color: #3C9CFE !important;
  114. }
  115. .icon_image {
  116. color: #606266;
  117. font-size: 44rpx;
  118. }
  119. </style>