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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<template>
<div class="top-bar">
<div class="top-bar-left">
<div class="logo" @click="$router.push('/index')"></div>
<span class="title f24">中国国家博物馆建党百年展点播院线服务平台</span>
</div>
<div class="top-bar-right">
<!-- <div class="avatar"></div> -->
<div class="user-name f16">Hello, {{ userName }}</div>
<div class="line"></div>
<div class="login-out" @click="logout()"></div>
</div>
</div>
</template>
<script>
import { loginOut } from "@/config/loginOut";
export default {
data() {
return {
userName: localStorage.getItem("user"),
};
},
mounted() {},
methods: {
logout() {
this.$confirm("确认退出吗?")
.then((_) => {
this.handleLogout();
})
.catch((_) => {});
},
handleLogout() {
let _this = this;
_this
.$https({
method: "get",
url: "logout",
authType: "back",
})
.then((res) => {
if (res.status == 200) {
let resData = res.data;
if (resData.resultCode == 200) {
_this.$message({
type: "success",
message: resData.message,
});
loginOut();
_this.$router.push("login");
} else {
_this.$message.error(res.data.message);
}
} else {
_this.$message.error(res.data.message);
}
})
.catch((err) => {
_this.$message.error(error.message);
});
},
},
};
</script>
<style lang="less" scoped>
.top-bar {
background-color: @party-red;
width: 100%;
height: 76px;
line-height: 76px;
padding: 0 30px;
overflow: hidden;
.top-bar-left {
float: left;
.logo {
width: 46px;
height: 36px;
display: inline-block;
vertical-align: middle;
background: url("~@/assets/login/logo.png") no-repeat center/100% 100%;
cursor: pointer;
}
.title {
color: @party-white;
vertical-align: middle;
padding-left: 16px;
}
}
.top-bar-right {
float: right;
> * {
display: inline-block;
vertical-align: middle;
}
.avatar {
width: 36px;
height: 36px;
border-radius: 50%;
background-color: pink;
}
.user-name {
font-size: 16px;
line-height: 16px;
color: @party-white;
}
.line {
width: 2px;
height: 18px;
background-color: @party-white;
margin: 0 15px;
}
.login-out {
width: 20px;
height: 20px;
background: url("~@/assets/login/logout.png") no-repeat center/100% 100%;
cursor: pointer;
}
}
}
</style>