quanwei
2 days ago 04102f7237efefa744090ed7c25f7b5d0807b679
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<template>
  <!--
          作者:luoyiming
          时间:2019-10-24
          描述:后台系统头部
      -->
  <div class="common-header">
    <div class="breadcrumb">
      <div class="baseInfo-left-base">
        <span class="name">{{ menu_title }}</span>
      </div>
      <div class="header-navbar">
        <div class="header-navbar-icon">
          <span class="ml4 icon iconfont icon-geren9"></span>
          <span class="text ml4">{{ username }},欢迎您!</span>
        </div>
        <div class="header-navbar-icon" @click="login_out()">
          <span class="icon iconfont icon-tuichu"></span>
          <span class="text ml4">退出</span>
        </div>
      </div>
    </div>
  </div>
</template>
 
<script>
import UserApi from '@/api/user.js';
import bus from '@/utils/eventBus';
import { delCookie, getCookie } from '@/utils/base.js';
export default {
  data() {
    return {
      menu_title: '首页',
       username:''
    };
  },
  created() {
    bus.$on('MenuName', res => {
      this.menu_title = res;
    });
 
    /*获取登录用户名*/
    this.username= getCookie('userinfo');
    console.log(this.username);
  },
  methods: {
    /*退出登录*/
    login_out() {
      this.$confirm('此操作将退出登录, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          UserApi.loginOut(true)
            .then(data => {
              delCookie('isLogin');
              this.$router.push({
                path: '/Login'
              });
            })
            .catch(error => {});
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消退出'
          });
        });
    }
  }
};
</script>
<style lang="scss">
    .login-out .icon-tuichu {
      color: red;
    }
 
    .header-navbar-icon .icon-geren9 {
      font-size: 20px;
    }
</style>