<template>
  <div class="navbar">
    <div class="nav-title">智慧校园公寓管理端</div>
    <div class="right">
      <p class="time">{{ time }}</p>
      <el-badge :value="$store.state.inform.readFlag" class="item">
        <!-- <svg-icon icon-class="xiaoxizhongxin" /> -->
        <div @click="informs">
          <IconSvg :W="28" :H="31" name="xiaoxizhongxin" />
        </div>
      </el-badge>
      <div class="photo">
        <el-avatar
          icon="el-icon-user-solid"
          style="width: 53px; height: 53px; margin: 0; line-height: 53px"
        >
        </el-avatar>
      </div>
      <div class="name">名字</div>
      <div class="out" @click="outLogin">
        <IconSvg :W="16" :H="16" name="quit" />
        <div class="title">退出</div>
      </div>
    </div>
  </div>
</template>

<script>
import { removeToken } from "@/utils/auth";
import moment from "moment";
import "moment/locale/zh-cn";
export default {
  name: "Navbar",
  data() {
    return {
      time: moment().format("YYYY-M-D dddd HH:mm:ss"),
    };
  },
  mounted() {},
  methods: {
    informs() {
      this.$router
        .replace({ name: "Inform" })
        .then((res) => {})
        .catch((err) => {
          console.log();
        });
    },
    outLogin() {
      this.$confirm("确认退出登录？")
        .then((_) => {
          this.$store.dispatch("user/logout").then(() => {
            this.$message({
              message: "退出成功",
              type: "success",
            });
            this.$router.replace({ path: "/login" });
          });
        })
        .catch((_) => {});
    },
  },
};
</script>

<style lang="scss" scoped>
.navbar {
  height: 96px;
  overflow: hidden;
  background: rgba(255, 255, 255, 1);
  display: flex;
  align-items: center;
  justify-content: space-between;

  .nav-title {
    display: inline-block;
    width: 324px;
    height: 53px;
    line-height: 53px;
    color: rgba(0, 0, 0, 1);
    font-size: 36px;
    font-weight: 500;
    margin-left: 22px;
  }

  .right {
    display: flex;
    align-items: center;

    .time {
      width: 241px;
      height: 27px;
      line-height: 27px;
      color: rgba(102, 102, 102, 1);
      font-size: 18px;
      font-weight: 400;
      margin-right: 35px;
      // float: right;
    }

    .photo {
      width: 53px;
      height: 53px;
      margin: 0 4px 0 38px;
    }

    .name {
      // width: 50px;
      height: 28px;
      color: rgba(51, 51, 51, 1);
      font-size: 14px;
      font-weight: 500;
      line-height: 28px;
      padding: 0 15px 0 5px;
      margin-right: 13px;
      border-right: 1px solid rgba(204, 204, 204, 1);
    }

    .out {
      display: flex;
      align-items: center;
      padding-right: 18px;
      cursor: pointer;

      .title {
        margin-left: 6px;
        font-size: 14px;
      }
    }
  }
}
</style>