<template>
  <div class="avue-logo">
    <transition-group name="fade">
      <template v-if="!keyCollapse">
        <span
          key="2"
          @click="goIndex"
          style="margin-left: 15px;margin-right: 5px;width: 40px;float: left"
        >
          <img
            src="/images/logo.png"
            style="width: 40px;height: 40px;line-height: 100px;margin-top: 10px;border-radius:20px;"
            alt=""
          />
        </span>
        <span
          key="1"
          class="avue-logo_title"
          @click="goIndex"
          style="line-height: 30px;"
          >{{ website.title }}<br />{{ roleName }}
        </span>
      </template>
    </transition-group>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
export default {
  name: "Logo",
  data() {
    return {
      roleName: ""
    };
  },
  computed: {
    ...mapGetters(["website", "keyCollapse", "userInfo"])
  },
  created() {
    this.bulidTitle();
  },
  methods: {
    goIndex: function() {
      window.location.href = "/";
    },
    bulidTitle() {
      let userInfo = this.userInfo;
      let role = userInfo.roles;
      console.log("role", role);
      if (role.includes(2)) {
        this.roleName = "平台端";
      }

      if (role.includes(3)) {
        this.roleName = "人用疫苗事业部";
      }

      if (role.includes(4)) {
        this.roleName = "学术推广服务端";
      }

      if (role.includes(9)) {
        this.roleName = "CRO推广服务端";
      }
      if (role.includes(37)) {
        this.roleName = "服务平台端";
      }
    }
  }
};
</script>

<style lang="scss">
.fade-leave-active {
  transition: opacity 0.2s;
}
.fade-enter-active {
  transition: opacity 2.5s;
}
.fade-enter,
.fade-leave-to {
  opacity: 0;
}
.avue-logo {
  position: fixed;
  top: 0;
  left: 0;
  width: 240px;
  height: 64px;
  line-height: 64px;
  background-color: #20222a;
  font-size: 20px;
  overflow: hidden;
  box-sizing: border-box;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.15);
  color: rgba(255, 255, 255, 0.8);
  z-index: 1024;
  &_title {
    display: block;
    text-align: center;
    font-weight: 300;
    font-size: 16px;
  }
  &_subtitle {
    display: block;
    text-align: center;
    font-size: 18px;
    font-weight: bold;
    color: #fff;
  }
}
</style>
