hader.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <template>
  2. <div>
  3. <div class="header row allAlignment">
  4. <div class="row item-center box_div" style="color:#666;font-size:14px;font-weight:bold;">
  5. <img style="width:38px;height:38px;margin: 0 10px;" src="@/assets/img/headerPortrait.png">
  6. 你好,<span>{{user_info.user_name}}--{{user_info.group}}</span>
  7. </div>
  8. <div class="row item-center rightAlignment msg box_div" style="padding: 0 30px;font-size:12px;color:#999">
  9. <div>
  10. <el-dropdown @command="handleCommand">
  11. <span class="el-span-1">
  12. <i style="font-size:14px;color:#5399F5;" class="el-icon-user"></i>
  13. {{value}}
  14. </span>
  15. <el-dropdown-menu slot="dropdown">
  16. <el-dropdown-item command='0'>在线</el-dropdown-item>
  17. <el-dropdown-item command=1>隐身</el-dropdown-item>
  18. <el-dropdown-item command=2>休息</el-dropdown-item>
  19. </el-dropdown-menu>
  20. </el-dropdown>
  21. </div>
  22. <el-badge :value="12" class="item">
  23. <el-button @click="openDrawer" style="margin:0 15px"><i style="font-size:14px; color:#5399F5;"
  24. class="el-icon-chat-dot-square"> </i>消息中心
  25. </el-button>
  26. </el-badge>
  27. <span @click="isExit()" class="el-span-1"><i style="font-size:13px; margin-right: 3px; color:#5399F5;"
  28. class="el-icon-switch-button"></i>退出</span>
  29. </div>
  30. </div>
  31. </div>
  32. </template>
  33. <script>
  34. import Vue from 'vue';
  35. import '@/css/index.css'
  36. export default {
  37. name: 'hader',
  38. data() {
  39. return {
  40. state: true,//在线状态
  41. announcement: true,//公告
  42. network: true,
  43. HeadPortrait: '',
  44. loginTo: false,//登录状态
  45. options: ['在线', '隐身', '休息'],
  46. value: '隐身',
  47. user_info: '',//
  48. }
  49. },
  50. methods: {
  51. openDrawer() {
  52. this.$store.dispatch("SET_DRAWER", true);
  53. },
  54. /**********************************************/
  55. //切换用户状态
  56. handleCommand(e) {
  57. //console.log(e)
  58. this.websocketsend(JSON.stringify({
  59. type: 'kfOnline',
  60. data: {
  61. uid: 'KF' + this.user_info.id,
  62. status: e * 1 + 1,
  63. }
  64. }));
  65. //Vue.prototype.$stateValue = this.options[e];
  66. this.$store.dispatch("SET_STATEVALUE", this.options[e]);
  67. this.value = this.options[e];
  68. },
  69. /************************************************/
  70. //退出系统
  71. isExit() {
  72. this.$store.dispatch("SET_STATEVALUE", '隐身');
  73. this.$store.dispatch("SET_SESSION", []);
  74. this.$store.dispatch("SET_OFFLINE", []);
  75. this.$websocket.close();
  76. this.$token = '';
  77. this.$router.push('/login')
  78. },
  79. /**************************************/
  80. //数据发送
  81. websocketsend(Data) {
  82. this.$websocket.send(Data);
  83. },
  84. },
  85. mounted() {
  86. if (this.$store.getters.get_stateValue) {
  87. this.value = this.$store.getters.get_stateValue;
  88. }
  89. this.user_info = this.$store.getters.get_user_info;
  90. }
  91. }
  92. </script>
  93. <style scoped>
  94. .header {
  95. width: 90vw;
  96. height: 7vh;
  97. border-bottom: 1px solid #D5E5FF;
  98. }
  99. .box_div {
  100. width: 50%;
  101. height: 100%;
  102. background: #ECF4FF;
  103. }
  104. .msg p {
  105. margin-left: 30px;
  106. display: flex;
  107. align-items: center;
  108. }
  109. .msg p img {
  110. margin-right: 6px;
  111. }
  112. .el-span-1 {
  113. margin-left: 6px;
  114. font-size: 14px;
  115. color: #666;
  116. }
  117. .el-span-1:hover {
  118. color: #5399f5;
  119. cursor: pointer;
  120. font-weight: 400;
  121. }
  122. button {
  123. outline: none;
  124. /* border: 1px solid #ECF4FF; */
  125. }
  126. .el-button {
  127. background: #ECF4FF;
  128. font-size: 14px;
  129. color: #666;
  130. }
  131. .el-button:hover {
  132. color: #5399f5;
  133. }
  134. .msg_left {
  135. width: 360px;
  136. height: 400px !important
  137. }
  138. .msg_right {
  139. width: 440px;
  140. }
  141. .el-popover {
  142. height: 700px !important;
  143. }
  144. /* .el-dropdown{
  145. border: 1px solid #ECF4FF;
  146. } */
  147. </style>
  148. <style>
  149. .el-badge__content.is-fixed {
  150. position: absolute;
  151. top: -2px !important;
  152. right: 18px !important;
  153. }
  154. </style>