<template>
  <div class="video-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="middle" v-if="showTab">
          <div class="item" :class="{active : videoActiveType == 'default'}" @click="toChooseCate('default')"><i class="iconfont icon-fontclass-qidong"></i> <span class="type-name">全部</span></div>
          <div class="item" :class="{active : videoActiveType == 'recommend'}" @click="toChooseCate('recommend')" v-if="videoBasicSet.is_show_recommend && videoBasicSet.is_show_recommend == 1"><i class="iconfont icon-fontclass-tuijian1"></i> <span class="type-name">推荐</span></div>
          <div class="item" :class="{active : videoActiveType == 'follow'}" @click="toChooseCate('follow')" v-if="videoBasicSet.is_show_own_follow && videoBasicSet.is_show_own_follow == 1"><i class="iconfont icon-fontclass-guanzhu1"></i> <span class="type-name">关注</span></div>
        </div>
        <div class="right">
          <el-button size="small" class="btn-login btn-default" v-if="showPublish" @click="getPermission"><i class="iconfont icon-life-game-plus"></i><span>发布</span>
          </el-button>
          <el-button size="small" plain class="btn-video" @click="toUrl('videoList')"><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: "VHeader",
    props: {
      showTab: {
        type: Boolean,
        default: false
      },
      showPublish: {
        type: Boolean,
        default: false
      }
    },
    data() {
      return {
      }
    },
    computed: {
      ...mapState(['basicSet', 'videoBasicSet', 'videoActiveType']),
    },
    mounted() {},
    methods: {
      getPermission() {
        this.fun.$get("plugin.video-share.frontend.permission.verify").then(res => {
          if (res.result == 1) {
            if (res.data.ret) {
              this.toUrl('releaseVideo')
            }else {
              this.$message.error(res.msg);
            }
          } else {
            this.$message.error(res.msg);
          }
        });
      },
      toUrl(url, params, query) {
        if (url == 'login') {
          sessionStorage.setItem("yz_redirect", document.location.href);
        }
        this.$router.push(this.fun.getUrl(url, params, query));
      },
      toChooseCate(code) {
        this.$store.commit('setVideoActiveType', code);
        this.$router.push(this.fun.getUrl("videoDetail", {}, { activeType: code}));
      },
    }
  };
</script>

<style lang="scss" rel="stylesheet/scss" scoped>
.video-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;
    }
  }
  .middle {
    display: flex;
    font-size: 16px;
    color: #333333;
    .item {
      margin: 0 15px;
      cursor: pointer;
    }
    .iconfont {
      font-size: 18px;
      color: #838382;
    }
    .active {
      color: #ec544a;
      .iconfont {
        color: #ec544a;
      }
    }
  }
  .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>
