navbar.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <template>
  2. <view>
  3. <view class="wx-head-mod" :style="{height:navHeight+'rpx',background:navBackground}">
  4. <view class="wx-head-mod-nav" :style="{height:navigationBarHeight+'rpx',top:statusBarHeight+'rpx'}">
  5. <view class="wx-head-mod-nav-content"
  6. :style="{height:customHeight+'rpx',justifyContent:'left'}">
  7. <!-- 文本区 -->
  8. <view class="wx-head-mod-nav-content-mian"
  9. :style="{lineHeight:customHeight + 'rpx'}">
  10. {{title}}
  11. </view>
  12. </view>
  13. </view>
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. import { systemInfo } from '@/component/system-info'
  19. export default {
  20. name: "HeadView",
  21. props: {
  22. // 文本区内容
  23. title:'',
  24. background:'',
  25. },
  26. data() {
  27. return {
  28. statusBarHeight: 0, //状态栏高度
  29. navHeight: 0, //头部导航栏总体高度
  30. navigationBarHeight:0, //导航栏高度
  31. customHeight: 0, //胶囊高度
  32. scaleFactor: 0, //比例系数
  33. menubarLeft:0, //胶囊定位的左边left
  34. windowWidth: 0,
  35. navBackground:null
  36. };
  37. },
  38. methods: {
  39. },
  40. created() {
  41. /* 获取设备信息 */
  42. const SystemInfomations = systemInfo()
  43. /* 通用平台 */
  44. this.statusBarHeight = SystemInfomations.statusBarHeight //状态栏高度
  45. this.scaleFactor = SystemInfomations.scaleFactor //比例系数
  46. this.windowWidth = SystemInfomations.windowWidth //当前设备的屏幕宽度
  47. /* H5 */
  48. // #ifdef WEB
  49. this.navHeight = 100 //头部导航栏总高度
  50. this.navigationBarHeight = 100 //头部导航栏高度
  51. this.customHeight = 100 //胶囊高度
  52. this.menubarLeft = 0 //胶囊左边界距离左上角的距离
  53. // #endif
  54. /* 微信小程序平台 */
  55. // #ifdef MP-WEIXIN
  56. this.navHeight = SystemInfomations.navHeight + SystemInfomations.statusBarHeight //头部导航栏总高度
  57. this.navigationBarHeight = SystemInfomations.navHeight //头部导航栏高度
  58. this.customHeight = SystemInfomations.menuButtonHeight //胶囊高度
  59. this.menubarLeft = SystemInfomations.menuButtonLeft //胶囊左边界距离左上角的距离
  60. // #endif
  61. this.navBackground = this.background?this.background:'rgba(255,255,255,0)'
  62. }
  63. }
  64. </script>
  65. <style>
  66. .wx-head-mod {
  67. z-index:100;
  68. box-sizing: border-box;
  69. width: 100%;
  70. position: fixed;
  71. top: 0;
  72. left: 0;
  73. //background: #0183FA;
  74. /* background: linear-gradient(-35deg, #613A19 0%, #6F4E2B 100%); */
  75. }
  76. .wx-head-mod-nav {
  77. box-sizing: border-box;
  78. width: 100%;
  79. position: absolute;
  80. left: 0;
  81. display: flex;
  82. justify-content: center;
  83. align-items: center;
  84. }
  85. .wx-head-mod-nav-content {
  86. box-sizing: border-box;
  87. width: 100%;
  88. display: flex;
  89. justify-content: left;
  90. align-items: center;
  91. position: relative;
  92. padding-left: 30rpx;
  93. box-sizing: border-box;
  94. }
  95. /* 文本区 */
  96. .wx-head-mod-nav-content-mian {
  97. box-sizing: border-box;
  98. height: 100%;
  99. text-align: center;
  100. white-space: nowrap;
  101. text-overflow: ellipsis;
  102. overflow: hidden;
  103. color:#fff;
  104. font-size:36rpx;
  105. }
  106. /* 返回按钮 */
  107. .wx-head-mod-nav-content-back {
  108. box-sizing: border-box;
  109. width: 60rpx;
  110. height: 100%;
  111. /* background-color: aqua; */
  112. position: absolute;
  113. top: 0;
  114. left: 32rpx;
  115. display: flex;
  116. align-items: center;
  117. justify-content: left;
  118. }
  119. .wx-head-mod-nav-content-back-img {
  120. box-sizing: border-box;
  121. }
  122. </style>