<template>
  <div class="navbar">
    <hamburger
      id="hamburger-container"
      :is-active="sidebar.opened"
      class="hamburger-container"
      @toggleClick="toggleSideBar"
    />
    <div class="homeIcon" @click="goHome()">
      <img src="../../assets/images/home.png" />
      <span style="padding-left:10px;">首页</span>
    </div>


    <Navebarright></Navebarright>

  </div>
</template>

<script>
import { mapGetters } from "vuex"

import Hamburger from "@/components/Hamburger"
import Navebarright from "@/components/Navebarright"
import { getUser } from '@/utils/auth'

export default {
  components: {

    Hamburger,
    Navebarright
  },
  computed: {
    ...mapGetters(["sidebar", "avatar", "device"])
  },
  methods: {
    // 点击home图标时
    goHome() {
      let userInfo = JSON.parse(getUser())
      let homeType = userInfo.homeType
      if (homeType == 1) {
        this.$router.push({ path: "/dashboard" })  //分公司
      }else if (homeType == 2) {
        //库主任及以上领导首页
      } else if (homeType == 3) {
        this.$router.push({ path: "/home" })  //员工
      }
    },



    toggleSideBar() {
      this.$store.dispatch("app/toggleSideBar")
    }
  }
}
</script>

<style lang="scss" scoped>
.navbar {
  height: 50px;
  overflow: hidden;
  position: relative;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
  //homeIcon样式
  .homeIcon {
    float: left;
    height: 100%;
    line-height: 50px;
    margin-right: 10px;

    img {
      width: 25px;
      vertical-align: middle;
    }
  }

 


  .hamburger-container {
    line-height: 46px;
    height: 100%;
    float: left;
    cursor: pointer;
    transition: background 0.3s;
    -webkit-tap-highlight-color: transparent;

    &:hover {
      background: rgba(0, 0, 0, 0.025);
    }
  }

  .breadcrumb-container {
    float: left;
  }

  .errLog-container {
    display: inline-block;
    vertical-align: top;
  }

  .right-menu {
    float: right;
    height: 100%;
    line-height: 50px;

    &:focus {
      outline: none;
    }

    .right-menu-item {
      display: inline-block;
      padding: 0 8px;
      height: 100%;
      font-size: 18px;
      color: #5a5e66;
      vertical-align: text-bottom;

      &.hover-effect {
        cursor: pointer;
        transition: background 0.3s;

        &:hover {
          background: rgba(0, 0, 0, 0.025);
        }
      }
    }

    .avatar-container {
      margin-right: 30px;

      .avatar-wrapper {
        margin-top: 5px;
        position: relative;

        .user-avatar {
          cursor: pointer;
          width: 40px;
          height: 40px;
          border-radius: 10px;
        }

        .el-icon-caret-bottom {
          cursor: pointer;
          position: absolute;
          right: -20px;
          top: 25px;
          font-size: 12px;
        }
      }
    }
  }
}
</style>
