<template>
|
<div class="index_user">
|
<div class="pwd" @click="onPwd">
|
<i class="el-icon-edit-outline"></i>
|
修改密码
|
</div>
|
<div class="user">
|
<span class="avatar" @mouseleave="leave" @mouseenter="enter">
|
<img :src="user.logo || defaultImage" alt />
|
</span>
|
<b class="text_overflow" @mouseenter="enter" @mouseleave="leave">{{ user.name }}</b>
|
<transition name="fade">
|
<div class="child" v-if="flag" @mouseenter="enter" @mouseleave="leave">
|
<ul>
|
<li @click="onPwd">修改密码</li>
|
<li @click="exit">退出登录</li>
|
</ul>
|
</div>
|
</transition>
|
</div>
|
<div class="exit" @click="exit" title="退出">
|
<span class="el-icon-switch-button"></span>
|
<span class="el-icon-top up"></span>
|
</div>
|
</div>
|
</template>
|
|
<script>
|
import logo from "../../../static/image/user.jpg";
|
export default {
|
props: {
|
user: {
|
type: Object,
|
default: () => {
|
return {};
|
},
|
},
|
},
|
components: {},
|
data() {
|
return { flag: false, num: 0, timer: null, defaultImage: logo };
|
},
|
watch: {},
|
methods: {
|
exit() {
|
this.$js.model("", "是否退出登录", (res) => {
|
this.flag = false;
|
if (res) {
|
this.$api.clear();
|
this.$router.push(this.$nav.url("/login"));
|
}
|
});
|
},
|
onPwd() {
|
this.$router.push(this.$nav.url("/pwd"));
|
this.flag = false;
|
if (this.timer !== null) {
|
clearTimeout(this.timer);
|
this.timer = null;
|
}
|
},
|
enter() {
|
this.flag = true;
|
this.num = Date.now();
|
if (this.timer !== null) {
|
clearTimeout(this.timer);
|
this.timer = null;
|
}
|
},
|
leave() {
|
if (this.timer !== null) {
|
clearTimeout(this.timer);
|
this.timer = null;
|
}
|
this.timer = setTimeout(() => {
|
clearTimeout(this.timer);
|
this.flag = false;
|
this.num = 0;
|
this.timer = null;
|
}, 300);
|
},
|
},
|
mounted() { },
|
};
|
</script>
|
<style lang='less' scoped>
|
.index_user {
|
box-sizing: border-box;
|
padding: 14px 0;
|
display: flex;
|
position: relative;
|
.pwd {
|
width: 100px;
|
line-height: 36px;
|
font-size: 14px;
|
color: #999;
|
cursor: pointer;
|
transition: all 0.2s;
|
i {
|
font-size: 20px;
|
vertical-align: middle;
|
}
|
&:hover {
|
color: #333;
|
}
|
}
|
.user {
|
width: 150px;
|
display: flex;
|
position: relative;
|
margin-left: 10px;
|
}
|
.exit {
|
position: relative;
|
width: 36px;
|
height: 36px;
|
display: inline-block;
|
transform: rotate(90deg);
|
color: #666;
|
cursor: pointer;
|
span {
|
position: absolute;
|
left: 0;
|
top: 0;
|
font-size: 25px;
|
line-height: 36px;
|
width: 36px;
|
height: 36px;
|
text-align: center;
|
&.up {
|
transform: translateY(-8px) translateX(-1px);
|
}
|
}
|
}
|
.avatar {
|
width: 32px;
|
height: 32px;
|
border-radius: 50%;
|
overflow: hidden;
|
margin-right: 5px;
|
margin-top: 2px;
|
img {
|
display: block;
|
width: 100%;
|
height: 100%;
|
background-color: #eee;
|
}
|
}
|
b {
|
line-height: 36px;
|
font-size: 14px;
|
color: #666;
|
cursor: pointer;
|
max-width: 110px;
|
&:hover {
|
color: rgb(63, 168, 77);
|
text-decoration: underline;
|
}
|
}
|
.child {
|
background-color: #fff;
|
height: 100px;
|
width: 100px;
|
position: absolute;
|
z-index: 9999;
|
top: 50px;
|
left: 0;
|
right: 0;
|
margin: auto;
|
border-radius: 5px;
|
box-shadow: 0 0 8px #ccc;
|
overflow: hidden;
|
ul {
|
padding: 10px 0;
|
}
|
li {
|
height: 40px;
|
line-height: 40px;
|
padding: 0 8px;
|
font-size: 15px;
|
letter-spacing: 1px;
|
color: #666;
|
transition: all 0.3s;
|
text-align: center;
|
cursor: pointer;
|
&:hover {
|
color: #333;
|
background-color: #fafafa;
|
}
|
}
|
}
|
}
|
</style>
|