Header.vue 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <div class="header">
  3. <div class="logo">商城后台管理系统</div>
  4. <div class="user-info">
  5. <el-dropdown trigger="click" @command="handleCommand">
  6. <span class="el-dropdown-link">
  7. {{username}}
  8. </span>
  9. <el-dropdown-menu slot="dropdown">
  10. <el-dropdown-item command="loginout">退出</el-dropdown-item>
  11. </el-dropdown-menu>
  12. </el-dropdown>
  13. </div>
  14. </div>
  15. </template>
  16. <script>
  17. export default {
  18. data() {
  19. return {
  20. username:'',
  21. icon:''
  22. }
  23. },
  24. methods:{
  25. getuser:function(){
  26. this.$http.getuser({}, this).then(res=>{
  27. if (res.code ===0 ){
  28. this.username = res.obj.name
  29. this.icon = res.obj.idcard
  30. }
  31. });
  32. },
  33. handleCommand(command) {
  34. if(command == 'loginout'){
  35. this.$http.loginout({}, this).then(res => {
  36. if (res.code === 0){
  37. window.location.href = res.obj
  38. }
  39. })
  40. }
  41. }
  42. },
  43. mounted: function(){
  44. this.getuser()
  45. }
  46. }
  47. </script>
  48. <style>
  49. .header {
  50. position: relative;
  51. box-sizing: border-box;
  52. width: 100%;
  53. height: 70px;
  54. font-size: 22px;
  55. line-height: 70px;
  56. color: #fff;
  57. }
  58. .header .logo {
  59. float: left;
  60. width: 250px;
  61. text-align: center;
  62. }
  63. .user-info {
  64. float: right;
  65. padding-right: 50px;
  66. font-size: 16px;
  67. color: #fff;
  68. }
  69. .user-info .el-dropdown-link {
  70. position: relative;
  71. display: inline-block;
  72. padding-left: 50px;
  73. color: #fff;
  74. cursor: pointer;
  75. vertical-align: middle;
  76. }
  77. .user-info .user-logo {
  78. position: absolute;
  79. left: 0;
  80. top: 15px;
  81. width: 40px;
  82. height: 40px;
  83. border-radius: 50%;
  84. }
  85. .el-dropdown-menu__item {
  86. text-align: center;
  87. }
  88. </style>