<template>
  <div class="micro-header">
    <div class="fixed-box">
      <div class="header-content">
        <div class="left">
          <img class="logo" @click="toUrl('home')" v-if="basicSet.set" :src="basicSet.set.logo_src" alt="">
        </div>
        <div class="right">
          <el-button size="small" class="btn-login btn-default" v-if="showPublish" @click="toUrl('microRelease')"><i class="iconfont icon-life-game-plus"></i><span>发布</span>
          </el-button>
          <el-button size="small" plain class="btn-video" @click="toUrl('microHome-microIndex')"><span>微社区</span>
          </el-button>
          <el-button size="small" class="btn-login btn-default" v-if="!basicSet.is_login"
                     @click="toUrl('login',{select: '1'})"><span>登录</span>
          </el-button>
          <div class="member-box" v-if="basicSet.is_login">
            <img :src="basicSet.user_info ? basicSet.user_info.avatar : ''" alt="">
            <p>{{basicSet.user_info ? basicSet.user_info.nickname : ''}}</p>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  import {mapState} from 'vuex'
  export default {
    name: "MHeader",
    props: {
      showPublish: {
        type: Boolean,
        default: false
      }
    },
    data() {
      return {
      }
    },
    computed: {
      ...mapState(['basicSet', 'videoBasicSet',]),
    },
    mounted() {},
    methods: {
      toUrl(url, params, query) {
        if (url == 'login') {
          sessionStorage.setItem("yz_redirect", document.location.href);
        }
        this.$router.push(this.fun.getUrl(url, params, query));
      },
    }
  };
</script>

<style lang="scss" rel="stylesheet/scss" scoped>
  .micro-header {
    min-width: 1200px;
    height: 60px;
    padding: 4px;
    box-sizing: border-box;
  }
  .fixed-box {
    z-index: 999;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background-color: #ffffff;
  }
  .header-content {
    padding: 0 30px;
    height: 60px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    .left {
      display: flex;
      align-items: center;
      position: relative;
      .logo {
        cursor: pointer;
        width: 220px;
        height: 32px;
      }
    }
    .right {
      display: flex;
      align-items: center;
      .btn-default {
        border: none;
        color: #ffffff;
      }
      .iconfont {
        font-size: 12px;
      }
      .btn-login {
        background-color: #3a75f4;
      }
      .btn-video {
        margin-right: 20px;
        color: var(--color);
        border: 1px solid var(--color);
      }
    }
  }
  .member-box {
    display: flex;
    align-items: center;
    img {
      margin-right: 6px;
      width: 28px;
      height: 28px;
      border-radius: 50%;
    }
    p {
      font-weight: bold;
    }
  }
</style>
