navbar.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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.js'
  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. /* 微信小程序平台 */
  48. // #ifdef MP-WEIXIN
  49. this.navHeight = SystemInfomations.navHeight + SystemInfomations.statusBarHeight //头部导航栏总高度
  50. this.navigationBarHeight = SystemInfomations.navHeight //头部导航栏高度
  51. this.customHeight = SystemInfomations.menuButtonHeight //胶囊高度
  52. this.menubarLeft = SystemInfomations.menuButtonLeft //胶囊左边界距离左上角的距离
  53. // #endif
  54. this.navBackground = this.background?this.background:'rgba(255,255,255,0)'
  55. }
  56. }
  57. </script>
  58. <style>
  59. .wx-head-mod {
  60. z-index:100;
  61. box-sizing: border-box;
  62. width: 100%;
  63. position: fixed;
  64. top: 0;
  65. left: 0;
  66. //background: #0183FA;
  67. /* background: linear-gradient(-35deg, #613A19 0%, #6F4E2B 100%); */
  68. }
  69. .wx-head-mod-nav {
  70. box-sizing: border-box;
  71. width: 100%;
  72. position: absolute;
  73. left: 0;
  74. display: flex;
  75. justify-content: center;
  76. align-items: center;
  77. }
  78. .wx-head-mod-nav-content {
  79. box-sizing: border-box;
  80. width: 100%;
  81. display: flex;
  82. justify-content: left;
  83. align-items: center;
  84. position: relative;
  85. padding-left: 30rpx;
  86. box-sizing: border-box;
  87. }
  88. /* 文本区 */
  89. .wx-head-mod-nav-content-mian {
  90. box-sizing: border-box;
  91. height: 100%;
  92. text-align: center;
  93. white-space: nowrap;
  94. text-overflow: ellipsis;
  95. overflow: hidden;
  96. color:#fff;
  97. font-size:36rpx;
  98. }
  99. /* 返回按钮 */
  100. .wx-head-mod-nav-content-back {
  101. box-sizing: border-box;
  102. width: 60rpx;
  103. height: 100%;
  104. /* background-color: aqua; */
  105. position: absolute;
  106. top: 0;
  107. left: 32rpx;
  108. display: flex;
  109. align-items: center;
  110. justify-content: left;
  111. }
  112. .wx-head-mod-nav-content-back-img {
  113. box-sizing: border-box;
  114. }
  115. </style>