<template>
  <div class="app-headBox">
    <span class="head-inner">
      <div class="head-name"> <span>{{headTitle}}</span><div class="head-name-bg"></div></div>
      <div class="header-fullscreen" @click="handleFullScreen"></div>
      <div class="head-time">{{ headTime }}</div>
    </span>
  </div>
</template>

<script>
  import common from '../../api/common';
  export default {
    name: "appHeader",
    data() {
      return {
        headTitle:"",//城市智慧停车大数据中心
        headTime:'',//当前时间
        fullscreen: false
      }
    },
    mounted() {
      this.headTitle=appConfig.appTitle;
      this.getCurTime()
    },
    methods: {
      getCurTime(){
        let _self=this;
        _self.headTime=common.getNowFormatDate();

        setInterval(function(){
          _self.headTime=common.getNowFormatDate();
        },1000);//1分钟更新一次
      },
      handleFullScreen(){
            let element = document.documentElement;
            if (this.fullscreen) {
                if (document.exitFullscreen) {
                    document.exitFullscreen();
                } else if (document.webkitCancelFullScreen) {
                    document.webkitCancelFullScreen();
                } else if (document.mozCancelFullScreen) {
                    document.mozCancelFullScreen();
                } else if (document.msExitFullscreen) {
                    document.msExitFullscreen();
                }
            } else {
                if (element.requestFullscreen) {
                    element.requestFullscreen();
                } else if (element.webkitRequestFullScreen) {
                    element.webkitRequestFullScreen();
                } else if (element.mozRequestFullScreen) {
                    element.mozRequestFullScreen();
                } else if (element.msRequestFullscreen) {
                    // IE11
                    element.msRequestFullscreen();
                }
            }
            this.fullscreen = !this.fullscreen;
       },

    }
  }
</script>

<style lang="scss" scoped>
  .app-headBox {
    /*display: flex;*/
    /*justify-content: center;*/
    /*align-items: center;*/
    display: table;
    border: 0px solid red;
    font-size:18px;
    position:relative;
  .head-inner{
    display: table-cell;    /* 让子元素以表格的单元格形式渲染 */
    text-align: center;
    vertical-align: middle;
  }
  .head-name >span:first-child{
    position: relative;
    z-index: 666;
  }
  .head-name,.head-time{
    display: inline-block;
  }
  .head-name{
    font-size:23px;
    /*font-weight:bold;*/
    width: 884px;
    height: 60px;
    line-height: 60px;
    background: url(../../images/head/bg.svg) no-repeat;
    background-size: 100% 100%;
    position:relative;

  }
  .head-name-bg{
    background: url(../../images/head/headNameBg.png) no-repeat;
    background-size: 100% 100%;
    height: 60px;
    width:320px;
    position: absolute;
    top:-4px;
    left:280px;
    z-index: 10;
  }
    .header-fullscreen{
      width: 18px;
      height: 18px;
      line-height: 18px;
      position: absolute;
      right: 158px;
      top:25px;
      cursor:pointer;
      background: url('../../images/head/righttopbarico_Bg.png');
    }
  .head-time{
    font-size:14px;
    color:#b2c2cf;
    width: 101px;
    float:right;;
    right: 0px;
    top:0;
    bottom:0;
    text-align: left;
    position:absolute;

    display: flex;
    justify-content: center;
    align-items: center;
  }
  .head-time::before{
    content: " ";width: 35px; height: 35px;
    background: url("../../images/head/time.png") no-repeat center; background-size: 100%;
    position: absolute;
    left:0;
    margin-left:-45px;
  }
  }

</style>
