headContent.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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. .status-bar{
  78. width: 100%;
  79. }
  80. .status-bar-fixed{
  81. position: fixed;
  82. top: 0;
  83. left: 0;
  84. z-index: $headFixedZIndex;
  85. }
  86. .head {
  87. width: 750rpx;
  88. .head-content {
  89. width: 100%;
  90. .content-box {
  91. width: 100%;
  92. padding: 0 $pages-padding;
  93. display: flex;
  94. justify-content: space-between;
  95. align-items: center;
  96. .left,
  97. .right {
  98. flex-shrink: 0;
  99. }
  100. .left,
  101. .right,
  102. .content {
  103. height: 100%;
  104. display: flex;
  105. align-items: center;
  106. }
  107. .content {
  108. flex: 1;
  109. justify-content: center;
  110. }
  111. ::v-deep .haed-title {
  112. font-size: 32rpx;
  113. font-family: PingFang SC, PingFang SC-Bold;
  114. font-weight: 700;
  115. text-align: center;
  116. color: #1a1a1a;
  117. letter-spacing: 0.72rpx;
  118. }
  119. ::v-deep .head-icon {
  120. width: 42rpx;
  121. height: 40rpx;
  122. image {
  123. width: 100%;
  124. height: 100%;
  125. }
  126. }
  127. .right {
  128. justify-content: flex-end;
  129. ::v-deep .head-icon+.head-icon {
  130. margin-left: 20rpx;
  131. }
  132. }
  133. }
  134. }
  135. .placeholder-view {
  136. width: 100%;
  137. }
  138. .content-fixed {
  139. position: fixed;
  140. left: 0;
  141. top: 0;
  142. z-index: $headFixedZIndex;
  143. }
  144. }
  145. </style>