<template>
  <div class="home-container">

    <!-- 左侧菜单 -->
    <div class="side-bar">
      <side-bar></side-bar>
    </div>

    <!-- 主体 -->
    <div class="main-container">

      <div class="nav-bar">
        <el-dropdown class="user-menu">
          <span class="user-menu-link">
            <span>{{$store.state.user.userInfo.user.phone}}</span><i class="el-icon-caret-bottom el-icon--right"></i>
          </span>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item @click.native="updatePass">修改密码</el-dropdown-item>
            <el-dropdown-item @click.native="loginOut">退出登录</el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
      </div>

      <div class="content-container">
        <router-view></router-view>
      </div>

    </div>

    <update-pass v-model="updatePassDialogStatus" @dialog-close="dialogClose"></update-pass>

  </div>
</template>
<script>
import SideBar from "@/components/SideBar";
import UpdatePass from "@/components/UpdatePass";
export default {
  name: "Home",
  components: {
    SideBar,
    UpdatePass
  },
  data() {
    return {
      updatePassDialogStatus: false
    };
  },
  //可访问data属性
  created() {

  },
  //计算集
  computed: {

  },
  //方法集
  methods: {
    updatePass() {
      this.updatePassDialogStatus = true;
    },
    loginOut() {
      this.$confirm('是否确定退出登录?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$store.dispatch("user/loginOut").catch(err => console.log(err)).finally(() => location.href = "/login");
      }).catch(err => console.log(err));
    },
    dialogClose(v) {
      this.updatePassDialogStatus = v;
    }
  },
}
</script>
<style lang="scss" scoped>
.home-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  overflow: hidden;

  .side-bar {
    width: 260px;
    height: 100%;
  }

  .main-container {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;

    .nav-bar {
      width: 100%;
      height: 70px;
      border-bottom: 1px solid #eeeeee;
      box-sizing: border-box;
      display: flex;
      justify-content: flex-end;
      align-items: center;
      padding: 16px;
      box-sizing: border-box;

      .user-menu {
        .user-menu-link {
          display: flex;
          align-items: center;
          cursor: pointer;

          & > span {
            margin-top: 2px;
          }

          & > i {
            font-size: 24px;
          }
        }
      }
    }

    .content-container {
      width: 100%;
      height: calc(100% - 70px);
      padding: 16px;
      box-sizing: border-box;
      overflow-y: auto;
      overflow-x: hidden;
    }
  }
}
</style>
