当前位置:   article > 正文

uni-app 自定义底部凸起导航栏_uniapp底部导航突出显示

uniapp底部导航突出显示

先上图

tabBar支持图片、iconfont图标展示

权限判断展示

  1. <template>
  2. <view>
  3. <view class="footer_box" :class="{ footer_bg: bg }">
  4. <view v-for="(item, index) of navigationList" :key="index" class="footer_item" v-if="item.isShow">
  5. <view v-if="item.raised" class="footer_raised_item" @click="onRaised">
  6. <text class="iconfont icon-saoma" style="font-size: 90rpx;color: #999999;"></text>
  7. </view>
  8. <view v-else class="footer_nav_item" @click="onPageJump(item.pagePath)">
  9. <block v-if="item.isShow && item.selectedIconPath">
  10. <image v-if="item.pagePath == path" class="footer_nav_item_image" :src="item.selectedIconPath" mode="aspectFit"></image>
  11. <image v-else class="footer_nav_item_image" :src="item.iconPath" mode="aspectFit"></image>
  12. <text class="footer_nav_item_text" :class="[item.pagePath == path ? 'footer_item_text_active' : '']">{{ item.text }}</text>
  13. </block>
  14. <block v-else-if="item.isShow">
  15. <text class="iconfont" :class="item.iconPath" :style="{'font-size': '45rpx','color': item.pagePath == path ? '#69C910':'#999999'}"></text>
  16. <text class="footer_nav_item_text" :class="[item.pagePath == path ? 'footer_item_text_active' : '']">{{ item.text }}</text>
  17. </block>
  18. </view>
  19. </view>
  20. </view>
  21. <view v-if="place" class="footer_station"></view>
  22. <view class="lan-mask" v-if="popupShow" :style="'height: '+(phoneHeight - 100)+'rpx;'">
  23. <view class="m-middle">
  24. <view class="m-middle-btn">扫描二维码</view>
  25. <view class="m-middle-btn">输入车编号</view>
  26. </view>
  27. </view>
  28. </view>
  29. </template>
  1. <script>
  2. export default {
  3. props: {
  4. bg: {
  5. type: Boolean,
  6. default: true
  7. },
  8. place: {
  9. type: Boolean,
  10. default: true
  11. }
  12. },
  13. data() {
  14. return {
  15. path: '',
  16. phoneHeight: 0,
  17. navigationList: [
  18. {
  19. pagePath: '/pages/equipment/manage/lanixong/visualization',
  20. iconPath: 'icon-ditu',
  21. isShow: true,
  22. text: '可视化'
  23. },
  24. {
  25. pagePath: '/pages/equipment/equipment',
  26. iconPath: '/static/icon/8d673f684b61101e7bb7342e3714078.png',
  27. selectedIconPath: '/static/icon/7314de4958d492a476b05fa0b2cb6b0.png',
  28. isShow: true,
  29. text: '设备'
  30. },
  31. {
  32. iconPath: 'icon-saoma',
  33. text: '扫一扫',
  34. isShow: true,
  35. raised: true
  36. },
  37. {
  38. pagePath: '/pages/equipment/manage/lanixong/manage',
  39. iconPath: 'icon-weixiu',
  40. isShow: true,
  41. text: '运维'
  42. },
  43. {
  44. pagePath: '/pages/user/user',
  45. iconPath: '/static/icon/d57d3d716d393498c227ff1d2f00abc.png',
  46. selectedIconPath: '/static/icon/ebfc732cdcdc515f2f26d44f263318c.png',
  47. isShow: true,
  48. text: '我的'
  49. }
  50. ],
  51. popupShow: false,
  52. lookEquipment: false
  53. };
  54. },
  55. //第一次加载
  56. created() {
  57. //查询权限
  58. this.lookEquipment = uni.getStorageSync('lookEquipment')
  59. //如果没有设备权限,那么可视化、运维不显示
  60. if(!this.lookEquipment) {
  61. this.navigationList.forEach((v) => {
  62. if(v.text == '可视化' || v.text == '运维') {
  63. v.isShow = false
  64. }
  65. })
  66. }
  67. // 获取页面指针数组
  68. let currentPages = getCurrentPages();
  69. // 获取当前页
  70. let page = currentPages[currentPages.length - 1];
  71. // 当前页的路径
  72. this.path = '/' + page.route;
  73. uni.getSystemInfo({
  74. success:(res)=> {
  75. this.phoneHeight = (res.screenHeight * (750 / res.windowWidth)) //窗口高度,将px 转换rpx
  76. }
  77. })
  78. },
  79. //方法
  80. methods: {
  81. onPageJump(url) {
  82. if (this.path !== url) {
  83. uni.reLaunch({
  84. url
  85. });
  86. }
  87. },
  88. onRaised(){
  89. this.popupShow = !this.popupShow;
  90. }
  91. }
  92. };
  93. </script>
  1. <style lang="scss" scoped>
  2. @import '@/style/mixin.scss';
  3. @keyframes fade-in {
  4. 0% {
  5. transform: scale(0);
  6. }
  7. 50% {
  8. transform: scale(1.3);
  9. }
  10. 100% {
  11. transform: scale(1);
  12. }
  13. }
  14. .lan-mask {
  15. position: fixed;
  16. z-index: 99999;
  17. top: 0;
  18. left: 0;
  19. right: 0;
  20. bottom: 0;
  21. width: 100vw;
  22. display: flex;
  23. flex-direction: column;
  24. justify-content: center;
  25. align-items: center;
  26. background: rgba(255,255,255, 0.7);
  27. .m-middle {
  28. border: 1px solid #999;
  29. background: rgba(245,247,250, 0.9);
  30. animation: fade-in 0.3s;
  31. z-index: 10001111;
  32. border-radius: 27upx;
  33. padding: 35upx;
  34. .m-middle-btn {
  35. width: 400upx;
  36. height: 86upx;
  37. background: #68C90F;
  38. border-radius: 18upx;
  39. font-size: 32upx;
  40. font-weight: 600;
  41. color: #FFFFFF;
  42. line-height: 86upx;
  43. text-align: center;
  44. margin: 0 auto;
  45. }
  46. .m-middle-btn:last-child {
  47. margin-top: 35upx;
  48. }
  49. }
  50. }
  51. .footer_station {
  52. height: 100rpx;
  53. box-sizing: content-box;
  54. // box-sizing: border-box;
  55. padding-bottom: constant(safe-area-inset-bottom);
  56. padding-bottom: env(safe-area-inset-bottom);
  57. }
  58. .footer_box {
  59. height: 100rpx;
  60. position: fixed;
  61. bottom: 0;
  62. left: 0;
  63. width: 100%;
  64. /* #ifndef APP-NVUE */
  65. display: flex;
  66. /* #endif */
  67. flex-direction: row;
  68. z-index: 502;
  69. box-sizing: content-box;
  70. // box-sizing: border-box;
  71. padding-bottom: constant(safe-area-inset-bottom);
  72. padding-bottom: env(safe-area-inset-bottom);
  73. }
  74. .footer_bg {
  75. background-color: #FFF;
  76. }
  77. .footer_item {
  78. position: relative;
  79. flex: 1;
  80. }
  81. .footer_nav_item {
  82. /* #ifndef APP-NVUE */
  83. display: flex;
  84. /* #endif */
  85. flex-direction: column;
  86. align-items: center;
  87. justify-content: center;
  88. height: 100%;
  89. }
  90. .footer_nav_item:active {
  91. background-color: rgba($color: #fff, $alpha: 0.1);
  92. }
  93. .footer_nav_item_text {
  94. font-size: 24rpx;
  95. color: #999999;
  96. margin-top: 6rpx;
  97. }
  98. .footer_nav_item_text_active {
  99. color: #f9a633;
  100. }
  101. .footer_item_text_active {
  102. color: #69C910;
  103. }
  104. .footer_nav_item_image {
  105. width: 50rpx;
  106. height: 50rpx;
  107. }
  108. .footer_raised_item {
  109. position: absolute;
  110. top: -40rpx;
  111. left: 50%;
  112. transform: translateX(-50%);
  113. width: 120rpx;
  114. height: 120rpx;
  115. background-color: #FFF;
  116. border-radius: 50%;
  117. /* #ifndef APP-NVUE */
  118. display: flex;
  119. /* #endif */
  120. align-items: center;
  121. justify-content: center;
  122. }
  123. .footer_raised_item_image {
  124. width: 70rpx;
  125. height: 70rpx;
  126. }
  127. .popup_content {
  128. background-color: #FFF;
  129. padding: 30rpx;
  130. }
  131. </style>
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小蓝xlanll/article/detail/113157?site
推荐阅读
相关标签
  

闽ICP备14008679号