headContent.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <template>
  2. <view class="head" >
  3. <!-- 状态栏 -->
  4. <view class="status-bar status-bar-fixed" :style="{'height':`${statusBarHeight}px` , 'background-color': statusBarBg}"></view>
  5. <view class="status-bar" :style="{'height':`${statusBarHeight}px`}"></view>
  6. <template v-if="showHead">
  7. <view :class="['head-content' , fixed ? 'content-fixed' : '']" :style="{'background-color': bgColor}">
  8. <view class="status-bar" v-if="fixed" :style="{'height':`${statusBarHeight}px` , 'background-color': statusBarBg}"></view>
  9. <view class="content-box" :style="{'height':headHeight}">
  10. <view class="left" v-if="showleftRight" :style="{'width': leftRightWidth}">
  11. <slot name="left"></slot>
  12. </view>
  13. <view class="content">
  14. <slot name="content"></slot>
  15. </view>
  16. <view class="right" v-if="showleftRight" :style="{'width': leftRightWidth}">
  17. <slot name="right"></slot>
  18. </view>
  19. </view>
  20. </view>
  21. <!-- 当标题烂定位时,占位 -->
  22. <view v-if="fixed" class="placeholder-view" :style="{'height':headHeight}"></view>
  23. </template>
  24. </view>
  25. </template>
  26. <script>
  27. import {
  28. mapGetters
  29. } from 'vuex'
  30. export default {
  31. name: "headContent",
  32. props: {
  33. // 是否线上状态栏
  34. showStatusBar: {
  35. type: Boolean,
  36. default: true
  37. },
  38. // 状态栏背景色
  39. statusBarBg: {
  40. type: String,
  41. default: '#fff'
  42. },
  43. bgColor: {
  44. type: String,
  45. default: '#fff'
  46. },
  47. fixed: {
  48. type: Boolean,
  49. default: true
  50. },
  51. showleftRight: {
  52. type: Boolean,
  53. default: true
  54. },
  55. showHead: {
  56. type: Boolean,
  57. default: true
  58. },
  59. leftRightWidth: {
  60. type: String,
  61. default: "30%"
  62. },
  63. },
  64. data() {
  65. return {
  66. };
  67. },
  68. computed: {
  69. ...mapGetters([
  70. 'statusBarHeight',
  71. 'headHeight'
  72. ]),
  73. }
  74. }
  75. </script>
  76. <style scoped lang="scss">
  77. $zIndex:50;
  78. .status-bar{
  79. width: 100%;
  80. }
  81. .status-bar-fixed{
  82. position: fixed;
  83. top: 0;
  84. left: 0;
  85. z-index: $zIndex;
  86. }
  87. .head {
  88. width: 750rpx;
  89. .head-content {
  90. width: 100%;
  91. .content-box {
  92. width: 100%;
  93. padding: 0 $pages-padding;
  94. display: flex;
  95. justify-content: space-between;
  96. align-items: center;
  97. .left,
  98. .right {
  99. flex-shrink: 0;
  100. }
  101. .left,
  102. .right,
  103. .content {
  104. height: 100%;
  105. display: flex;
  106. align-items: center;
  107. }
  108. .content {
  109. flex: 1;
  110. justify-content: center;
  111. }
  112. ::v-deep .haed-title {
  113. font-size: 32rpx;
  114. font-family: PingFang SC, PingFang SC-Bold;
  115. font-weight: 700;
  116. text-align: center;
  117. color: #1a1a1a;
  118. letter-spacing: 0.72rpx;
  119. }
  120. ::v-deep .head-icon {
  121. width: 42rpx;
  122. height: 40rpx;
  123. image {
  124. width: 100%;
  125. height: 100%;
  126. }
  127. }
  128. .right {
  129. justify-content: flex-end;
  130. ::v-deep .head-icon+.head-icon {
  131. margin-left: 20rpx;
  132. }
  133. }
  134. }
  135. }
  136. .placeholder-view {
  137. width: 100%;
  138. }
  139. .content-fixed {
  140. position: fixed;
  141. left: 0;
  142. top: 0;
  143. z-index: $zIndex;
  144. }
  145. }
  146. </style>