headContent.vue 3.5 KB

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