<template>
  <el-container style="height: 100%">
    <el-header class="header" v-show="flag">
      <div v-if="userinfo.logo">
        <img
          :src="userinfo.logo"
          alt=""
          style="position: absolute; left: 20px; top: 20px; max-width: 136px"
        />
      </div>
      <!-- 用户 -->
      <div class="userinfo">
        <img :src="userphoto" class="userheadImg" alt="" />{{ username }}
      </div>
      <!-- 标题 -->
      <div class="sysName">
        <h2 v-if="userinfo.user_header">{{ userinfo.user_header }}</h2>
        <h2 v-else>可视农业应用系统 实时监测基地生产环境</h2>
        <p>
          The visual agricultural application system monitors the production
          environment of the base in real time
        </p>
      </div>
      <div class="site" v-if="userinfo.site">
        <i class="iconfont icon-jidi"></i>
        <span>{{ userinfo.site }}</span>
      </div>
      <span class="header_btn" @click="hCheckFun">[隐藏]</span>
    </el-header>
    <el-header class="header2" v-show="!flag">
      <h3 v-if="userinfo.user_header">{{ userinfo.user_header }}</h3>
      <h3 v-else>可视农业应用系统</h3>
      <div class="site" v-if="userinfo.site">
        <i class="iconfont icon-jidi"></i>
        <span>{{ userinfo.site }}</span>
      </div>
      <span class="header_btn" @click="hCheckFun">[展开]</span>
    </el-header>
    <el-container style="overflow: auto">
      <el-aside width="200px">
        <el-menu
          :default-active="$route.path"
          :collapse-transition="false"
          class="el-menu-vertical-demo"
          :router="isRouter"
          active-text-color="rgb(57, 249, 190)"
        >
          <el-menu-item index="/index/monitor1">
            <i :class="iconObj[20]"></i>
            <span slot="title">可视农业应用系统</span>
          </el-menu-item>
          <el-menu-item index="/index/list1">
            <i :class="iconObj[22]"></i>
            <span slot="title">设备列表</span>
          </el-menu-item>
          <el-menu-item index="/index/userManger1">
            <i :class="iconObj[23]"></i>
            <span slot="title">用户管理</span>
          </el-menu-item>
        </el-menu>
      </el-aside>
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>
<script>
export default {
  data() {
    return {
      isRouter: true,
      iconObj: {
        20: "iconfont icon-jiankong",
        22: "iconfont icon-shebei",
        23: "iconfont icon-xitong",
      },
      flag: true,
      active: 1,
      userinfo: {},
      username: "",
      userphoto: "",
    };
  },
  created: function () {
    this.getuserinfo();
  },
  computed: {},
  mounted() {},
  methods: {
    hCheckFun() {
      this.flag = !this.flag;
    },
    getuserinfo() {
      this.$axios({
        method: "post",
        url: "userinfo_",
      }).then((res) => {
        this.username = res.data.username;
        this.userphoto = res.data.userphoto;
        localStorage.setItem("username", res.data.username); // 0管理员  1用户
      });
      this.$axios({
        method: "get",
        url: "user_detail",
      }).then((res) => {
        this.userinfo = res.data;
        localStorage.setItem("have_type", this.userinfo.have_type); // 0管理员  1用户
        localStorage.setItem("staff", this.userinfo.staff); // 1是admin
      });
    },
  },
};
</script>

<style scoped lang="less">
.header {
  position: relative;
  width: 100%;
  height: 177px !important;
  border-bottom: 2px solid #272b3a;
  background: #272b3a no-repeat center / 100% 100%
    url(../assets/images/monitor/h_bg.jpg);
  .userinfo {
    color: #fff;
    position: absolute;
    top: 10px;
    right: 10px;
    .userheadImg {
      width: 35px;
      height: 35px;
      border-radius: 50%;
      vertical-align: middle;
      margin-right: 6px;
    }
  }
  .sysName {
    color: #fff;
    text-align: center;
    h2 {
      font-size: 20px;
    }
    p {
      font-size: 14px;
    }
    margin-top: 50px;
  }
  .logInfo {
    color: #fff;
    position: absolute;
    top: 10px;
    left: 20px;
    display: flex;
    flex-direction: row;
    align-items: center;
    img {
      width: auto;
      height: 40px;
    }
    h3 {
      margin: 0;
      margin-left: 20px;
    }
  }
}
.header2 {
  border-bottom: 2px solid #272b3a;
  position: relative;
  background-color: #323749;
  color: #fff;
}
.site {
  position: absolute;
  right: 90px;
  bottom: 10px;
  z-index: 888;
  font-size: 14px;
  color: #ffffff;
  span {
    color: #fff;
    letter-spacing: 1px;
    font-size: 13px;
  }
}
.header_btn {
  position: absolute;
  color: #727272;
  font-size: 14px;
  right: 20px;
  bottom: 10px;
  cursor: pointer;
}
.header_btn:hover {
  color: #fff;
}

.el-aside {
  background: #474e60;
  .el-menu {
    background: #232735;
    .el-menu-item {
      color: #909399;
    }
    .is-active {
      background-color: rgba(45, 111, 102, 0.4);
    }
    .el-menu-item:focus,
    .el-menu-item:hover {
      color: #39f9be;
      background-color: rgba(45, 111, 102, 0.4);
      i {
        color: #39f9be;
      }
    }
  }
}
.el-main {
  padding: 0;
  background-color: #f6f6f6;
}
</style>
