123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- <template>
- <view class="head" :style="{'padding-top': `${statusBarHeight}px` , 'background-color': bgColor}">
- <template v-if="showHead">
- <view :class="['head-content' , fixed ? 'content-fixed' : '']" :style="{'background-color': bgColor}">
- <view v-if="fixed" :style="{'padding-top': `${statusBarHeight}px`}"></view>
- <view class="content-box" :style="{'height':headHeight}">
- <view class="left" v-if="showleftRight" :style="{'width': leftRightWidth}">
- <slot name="left"></slot>
- </view>
- <view class="content">
- <slot name="content"></slot>
- </view>
- <view class="right" v-if="showleftRight" :style="{'width': leftRightWidth}">
- <slot name="right"></slot>
- </view>
- </view>
- </view>
- <!-- 当标题烂定位时,占位 -->
- <view v-if="fixed" class="placeholder-view" :style="{'height':headHeight}"></view>
- </template>
- </view>
- </template>
- <script>
- import {
- mapGetters
- } from 'vuex'
- export default {
- name: "headContent",
- props: {
- bgColor: {
- type: String,
- default: '#fff'
- },
- fixed: {
- type: Boolean,
- default: true
- },
- showleftRight: {
- type: Boolean,
- default: true
- },
- showHead: {
- type: Boolean,
- default: true
- },
- leftRightWidth: {
- type: String,
- default: "30%"
- },
- },
- data() {
- return {
- };
- },
- computed: {
- ...mapGetters([
- 'statusBarHeight',
- 'headHeight'
- ]),
- }
- }
- </script>
- <style scoped lang="scss">
- .head {
- width: 750rpx;
- .head-content {
- width: 100%;
- .content-box {
- width: 100%;
- padding: 0 $pages-padding;
- display: flex;
- justify-content: space-between;
- align-items: center;
- .left,
- .right {
- flex-shrink: 0;
- }
- .left,
- .right,
- .content {
- height: 100%;
- display: flex;
- align-items: center;
- }
- .content {
- flex: 1;
- justify-content: center;
- }
- ::v-deep .haed-title {
- font-size: 36rpx;
- font-family: PingFang SC, PingFang SC-Bold;
- font-weight: 700;
- text-align: center;
- color: #1a1a1a;
- letter-spacing: -0.72rpx;
- }
- ::v-deep .head-icon {
- width: 42rpx;
- height: 40rpx;
- image {
- width: 100%;
- height: 100%;
- }
- }
- .right {
- justify-content: flex-end;
- ::v-deep .head-icon+.head-icon {
- margin-left: 20rpx;
- }
- }
- }
- }
- .placeholder-view {
- width: 100%;
- }
- .content-fixed {
- position: fixed;
- left: 0;
- top: 0;
- z-index: 1;
- }
- }
- </style>
|