<template>
  <view class="">
    <view class="header" :style="style">
      <view class="flexbox"
        :style="[{'height': customBarH + 'px', 'padding-top': statusBarH + 'px','background':bgckgroundBox}]">
        <view @tap="goBack">
          <text  class="iconfont" v-if="leftShow">
            &#xe60e;

          </text>
        </view>
        <!-- <view v-if="false">

        </view> -->
        <view class="title-text" :style="[{'marginLeft':left +'px'}]">{{title}}</view>
        <view style="width: 36px;"></view>
      </view>
    </view>
    <view class="box-title">
      <view class="" :style="[{'height': customBarH + 'px', 'padding-top': statusBarH + 'px'}]">
      </view>
    </view>
  </view>


</template>

<script>
  export default {
    data() {
      return {
        statusBarH: 0,
        customBarH: 0,
        left: 35
      }
    },
    props: {
      title: {
        type: String,
        default: ''
      },
      leftShow: {
        type: Boolean,
        default: true
      },

      bgckgroundBox: {
        type: String,
        default: '#fff'
      },
      // titleColor: {
      //   type: String,
      //   default: '#fff'
      // },
      // bgColor: {
      //   type: String,
      //   default: '#707'
      // },
    },
    computed: {
      style() {
        let _style = `height: ${this.customBarH}px;`
        return _style
      }
    },
    watch: {
      leftShow(e) {
        if (e == true) {
          this.left = 0
        }
      }
    },
    methods: {
      goBack() {
        if(!this.leftShow){
          return ;
        }
        this.$emit('leftClick')
      }
    },
    created() {
      let self = this;
      uni.getSystemInfo({
        success: function(e) {
          self.statusBarH = e.statusBarHeight + 10
          let custom = wx.getMenuButtonBoundingClientRect()
          self.customBarH = custom.height
        }
      })
    }
  }
</script>

<style scoped lang="scss">
@import url("../../static/css/en-common.css") ;

  .header {
    width: 100vw;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 999999;
  }

  .box-title {
    width: 100vw;
  }

  .flexbox {
    display: flex;
    justify-content: space-between;
    padding: 0 20px;
    .iconfont{
      color: #fff;
    }
    .title-text {
      font-size: 36rpx;
      font-weight: 600;
    }

    .icon-left {
      width: 20px;
      height: 20px;
    }
  }
</style>
