NavBar.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <template>
  2. <!-- 头部信息的组件 -->
  3. <el-header class="el-header">
  4. <header class="page-home-header">
  5. <div class="page-home-left">
  6. <span class="name">欢迎你,&ensp;{{ nameLeft }}</span>
  7. <span>{{ week }}</span
  8. >&ensp;<span>{{ data_show }}</span>
  9. </div>
  10. <div class="page-home-right">
  11. <div class="head-portrait">
  12. <img src="../../../assets/OIP-C.jpg" alt="头像" />
  13. </div>
  14. <span class="admin">{{ nameRight }}</span>
  15. <span class="line"></span>
  16. <i class="el-icon-switch-button out" @click="output"></i>
  17. </div>
  18. </header>
  19. </el-header>
  20. </template>
  21. <script>
  22. export default {
  23. name: 'NavBar',
  24. data () {
  25. return {
  26. nameLeft: '管理员', // 左边名字
  27. nameRight: '管理员', // 右边名字
  28. // headPortrait:"../../assets/OIP-C.jpg",//用户图片
  29. week: '', // 左边周
  30. data_show: '' // 左边时间
  31. }
  32. },
  33. mounted () {
  34. this.getDataTime()
  35. },
  36. methods: {
  37. // 获取当前时间
  38. getDataTime () {
  39. const wk = new Date().getDay()
  40. const yy = new Date().getFullYear()
  41. const mm = new Date().getMonth() + 1
  42. const dd = new Date().getDate()
  43. const weeks = [
  44. '星期日',
  45. '星期一',
  46. '星期二',
  47. '星期三',
  48. '星期四',
  49. '星期五',
  50. '星期六'
  51. ]
  52. this.week = weeks[wk]
  53. this.data_show = yy + '年' + mm + '月' + dd + '日'
  54. },
  55. // 用户退出
  56. output () {
  57. this.$confirm('确定要退出系统吗?', '提示', {
  58. confirmButtonText: '确定',
  59. cancelButtonText: '取消',
  60. type: 'error'
  61. })
  62. .then(() => {
  63. // 点击确定的操作(调用接口)
  64. // this.jiashuzu.splice(index, 1);
  65. sessionStorage.removeItem('token')
  66. this.$axios('/api/user/logout/', 'GET').then((data) => {
  67. if (data) {
  68. this.$message({
  69. type: 'success',
  70. message: '已成功退出'
  71. })
  72. this.$router.go(0)
  73. window.sessionStorage.clear()
  74. } else {
  75. this.$message({
  76. type: 'error',
  77. message: '请稍后再试或者直接关闭浏览器'
  78. })
  79. }
  80. })
  81. })
  82. .catch(() => {
  83. // 点取消的提示
  84. this.$message({
  85. type: 'success',
  86. message: '已取消退出'
  87. })
  88. })
  89. }
  90. }
  91. }
  92. </script>
  93. <style scoped lang="less">
  94. .el-header {
  95. width: 100%;
  96. // border: 1px solid red;
  97. background-color: #040e1b;
  98. // color: #333;
  99. text-align: center;
  100. line-height: 60px;
  101. }
  102. .page-home-header {
  103. width: 100%;
  104. // min-width: 1400px;
  105. min-width: 1291px;
  106. height: 60px;
  107. box-sizing: border-box;
  108. display: flex;
  109. justify-content: space-between;
  110. align-items: center;
  111. // border-bottom: 1px solid #ecf0f8;
  112. font-size: 16px;
  113. font-family: Microsoft YaHei;
  114. font-weight: bold;
  115. color: #ffffff;
  116. background: #040e1b;
  117. // box-shadow: 0px 1px 50px 0px rgba(210, 214, 223, 0.7);
  118. .name {
  119. margin-right: 25px;
  120. }
  121. .admin {
  122. cursor: pointer;
  123. }
  124. .page-home-right {
  125. display: flex;
  126. // width: 149px;
  127. align-items: center;
  128. .head-portrait {
  129. width: 38px;
  130. height: 38px;
  131. box-sizing: border-box;
  132. img {
  133. width: 100%;
  134. height: 100%;
  135. object-fit: cover;
  136. border-radius: 50%;
  137. }
  138. }
  139. .admin {
  140. margin: 0 20px;
  141. }
  142. .line {
  143. width: 1px;
  144. height: 36px;
  145. background-color: #ccc;
  146. margin-right: 15px;
  147. }
  148. .out {
  149. width: 40px;
  150. height: 40px;
  151. font-size: 35px;
  152. text-align: center;
  153. line-height: 40px;
  154. cursor: pointer;
  155. }
  156. }
  157. }
  158. </style>