Navbar.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. };
  37. },
  38. created() {
  39. setInterval(this.showTimes, 30000);
  40. },
  41. mounted() {},
  42. methods: {
  43. showTimes() {
  44. this.time = moment().format("YYYY-M-D dddd HH:mm:ss");
  45. },
  46. informs() {
  47. this.$router
  48. .replace({ name: "Inform" })
  49. .then((res) => {})
  50. .catch((err) => {
  51. console.log();
  52. });
  53. },
  54. outLogin() {
  55. this.$confirm("确认退出登录?")
  56. .then((_) => {
  57. this.$store.dispatch("user/logout").then(() => {
  58. this.$message({
  59. message: "退出成功",
  60. type: "success",
  61. });
  62. this.$router.replace({ path: "/login" });
  63. });
  64. })
  65. .catch((_) => {});
  66. },
  67. },
  68. };
  69. </script>
  70. <style lang="scss" scoped>
  71. .navbar {
  72. height: 96px;
  73. overflow: hidden;
  74. background: rgba(255, 255, 255, 1);
  75. display: flex;
  76. align-items: center;
  77. justify-content: space-between;
  78. .nav-title {
  79. display: inline-block;
  80. width: 324px;
  81. height: 53px;
  82. line-height: 53px;
  83. color: rgba(0, 0, 0, 1);
  84. font-size: 36px;
  85. font-weight: 500;
  86. margin-left: 22px;
  87. }
  88. .right {
  89. display: flex;
  90. align-items: center;
  91. .time {
  92. width: 241px;
  93. height: 27px;
  94. line-height: 27px;
  95. color: rgba(102, 102, 102, 1);
  96. font-size: 18px;
  97. font-weight: 400;
  98. margin-right: 35px;
  99. // float: right;
  100. }
  101. .photo {
  102. width: 53px;
  103. height: 53px;
  104. margin: 0 4px 0 38px;
  105. }
  106. .name {
  107. // width: 50px;
  108. height: 28px;
  109. color: rgba(51, 51, 51, 1);
  110. font-size: 14px;
  111. font-weight: 500;
  112. line-height: 28px;
  113. padding: 0 15px 0 5px;
  114. margin-right: 13px;
  115. border-right: 1px solid rgba(204, 204, 204, 1);
  116. }
  117. .out {
  118. display: flex;
  119. align-items: center;
  120. padding-right: 18px;
  121. cursor: pointer;
  122. .title {
  123. margin-left: 6px;
  124. font-size: 14px;
  125. }
  126. }
  127. }
  128. }
  129. </style>