x-navbottom.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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-shouye',
  33. title: '首页',
  34. }, {
  35. icon: 'icon-dingdan',
  36. title: '订单',
  37. },
  38. // {
  39. // icon: 'icon-a-xiaoxi',
  40. // title: '消息',
  41. // },
  42. {
  43. icon: 'icon-wode',
  44. title: '我的',
  45. }
  46. ],
  47. gasList: [{
  48. icon: 'icon-shouye',
  49. title: '首页',
  50. }, {
  51. icon: 'icon-wode',
  52. title: '我的',
  53. }],
  54. }
  55. },
  56. mounted() {
  57. var userInfo = this.$cache.getCache('userInfo')
  58. if (userInfo.provUser) {
  59. if (userInfo.provUser.isorders == 0 && userInfo.provUser.userType == 3) {
  60. this.dataList = this.list
  61. } else {
  62. this.dataList = this.gasList
  63. }
  64. } else {
  65. this.dataList = this.list
  66. }
  67. },
  68. methods: {
  69. gonavs(e, cindex) {
  70. this.$emit('botomchos', cindex)
  71. }
  72. }
  73. }
  74. </script>
  75. <style lang="scss">
  76. .navmainbox {
  77. position: fixed;
  78. bottom: 0;
  79. left: 0;
  80. z-index: 5;
  81. background-color: #ffffff;
  82. box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.1);
  83. width: 100%;
  84. height: 100rpx;
  85. padding-bottom: constant(safe-area-inset-bottom); //兼容 IOS<11.2
  86. padding-bottom: env(safe-area-inset-bottom); //兼容 IOS>11.2
  87. }
  88. .navigation {
  89. z-index: 2024;
  90. position: relative;
  91. display: flex;
  92. justify-content: center;
  93. align-items: center;
  94. height: 100rpx;
  95. padding-bottom: var(--window-bottom);
  96. }
  97. .navigation .navcont {
  98. position: relative;
  99. display: flex;
  100. flex-direction: column;
  101. align-items: center;
  102. flex: 1;
  103. }
  104. .navchosbox {
  105. color: #727289 !important;
  106. margin-top: 2rpx;
  107. font-size: 26rpx;
  108. }
  109. .activeName {
  110. color: #3E80FF !important;
  111. }
  112. .icon_image {
  113. font-size: 44rpx;
  114. }
  115. </style>