Navbar.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <template>
  2. <div class="navbar">
  3. <div class="nav-title">智慧校园公寓管理端</div>
  4. <div class="right">
  5. <p class="time">{{ time }}</p>
  6. <el-badge :value="$store.state.inform.readFlag" class="item">
  7. <!-- <svg-icon icon-class="xiaoxizhongxin" /> -->
  8. <div @click="informs">
  9. <IconSvg :W="28" :H="31" name="xiaoxizhongxin" />
  10. </div>
  11. </el-badge>
  12. <div class="photo">
  13. <el-avatar
  14. icon="el-icon-user-solid"
  15. style="width: 53px; height: 53px; margin: 0; line-height: 53px"
  16. >
  17. </el-avatar>
  18. </div>
  19. <div class="name">{{ $store.state.user.userName }}</div>
  20. <div class="out" @click="outLogin">
  21. <IconSvg :W="16" :H="16" name="quit" />
  22. <div class="title">退出</div>
  23. </div>
  24. </div>
  25. </div>
  26. </template>
  27. <script>
  28. import { removeToken } from "@/utils/auth";
  29. import moment from "moment";
  30. import "moment/locale/zh-cn";
  31. export default {
  32. name: "Navbar",
  33. data() {
  34. return {
  35. time: moment().format("YYYY-M-D dddd HH:mm:ss"),
  36. timer: null,
  37. };
  38. },
  39. mounted() {
  40. this.time = moment().format("YYYY-M-D dddd HH:mm:ss");
  41. this.timer = setInterval(() => {
  42. this.time = moment().format("YYYY-M-D dddd HH:mm:ss");
  43. }, 1000);
  44. },
  45. beforeDestroy() {
  46. if (this.timer) {
  47. clearInterval(this.timer);
  48. this.timer = null;
  49. }
  50. },
  51. methods: {
  52. informs() {
  53. this.$router
  54. .replace({ name: "Inform" })
  55. .then((res) => {})
  56. .catch((err) => {
  57. console.log();
  58. });
  59. },
  60. outLogin() {
  61. this.$confirm("确认退出登录?")
  62. .then((_) => {
  63. this.$store.dispatch("user/logout").then(() => {
  64. this.$message({
  65. message: "退出成功",
  66. type: "success",
  67. });
  68. this.$router.replace({ path: "/login" });
  69. });
  70. })
  71. .catch((_) => {});
  72. },
  73. },
  74. };
  75. </script>
  76. <style lang="scss" scoped>
  77. .navbar {
  78. height: 96px;
  79. overflow: hidden;
  80. background: rgba(255, 255, 255, 1);
  81. display: flex;
  82. align-items: center;
  83. justify-content: space-between;
  84. .nav-title {
  85. display: inline-block;
  86. width: 324px;
  87. height: 53px;
  88. line-height: 53px;
  89. color: rgba(0, 0, 0, 1);
  90. font-size: 36px;
  91. font-weight: 500;
  92. margin-left: 22px;
  93. }
  94. .right {
  95. display: flex;
  96. align-items: center;
  97. .time {
  98. width: 241px;
  99. height: 27px;
  100. line-height: 27px;
  101. color: rgba(102, 102, 102, 1);
  102. font-size: 18px;
  103. font-weight: 400;
  104. margin-right: 35px;
  105. // float: right;
  106. }
  107. .photo {
  108. width: 53px;
  109. height: 53px;
  110. margin: 0 4px 0 38px;
  111. }
  112. .name {
  113. // width: 50px;
  114. height: 28px;
  115. color: rgba(51, 51, 51, 1);
  116. font-size: 14px;
  117. font-weight: 500;
  118. line-height: 28px;
  119. padding: 0 15px 0 5px;
  120. margin-right: 13px;
  121. border-right: 1px solid rgba(204, 204, 204, 1);
  122. }
  123. .out {
  124. display: flex;
  125. align-items: center;
  126. padding-right: 18px;
  127. cursor: pointer;
  128. .title {
  129. margin-left: 6px;
  130. font-size: 14px;
  131. }
  132. }
  133. }
  134. }
  135. </style>