headContent.vue 3.5 KB

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