<template>
|
<router-link key="expand" class="user-link" to="/userInfo">
|
<img v-if="logo" :src="logo" class="avatar" alt="">
|
<div class="user-name">{{ name }}</div>
|
<el-divider direction="vertical" />
|
<div>
|
<div v-if="deptName" class="dept-name">{{ deptName }}</div>
|
<div v-if="titleName" class="title-name">{{ titleName }}</div>
|
</div>
|
</router-link>
|
</template>
|
|
<script>
|
import { getFtpUrl } from '@/utils/base'
|
import storage from 'store'
|
export default {
|
name: 'UserInfo',
|
data() {
|
return {
|
name: '欢迎您:admin',
|
deptName: storage.get('user').deptName || '',
|
logo: '',
|
titleName: storage.get('user').titleName || ''
|
}
|
},
|
created() {
|
this.name = this.$store.getters.name
|
if (this.$store.getters.info.headUrl) {
|
this.logo = this.getUrl(JSON.parse(this.$store.getters.info.headUrl)[0].path)
|
} else {
|
this.logo = 'https://tse1-mm.cn.bing.net/th/id/R-C.6e0766f48cac2b57efcfdf15bbb4124f?rik=XWu%2bR657LNpTRg&riu=http%3a%2f%2fwww.jcrb.com%2fxmtpd%2fmengman%2f201707%2fW020170712672258195967.jpg&ehk=FceMdlWHihzZotopRc8GtPnS6wuFZfWw%2bjA5BGB3qlA%3d&risl=&pid=ImgRaw&r=0'
|
}
|
},
|
methods: {
|
getUrl(path) {
|
if (path.substr(0, 7).toLowerCase() == 'http://' || path.substr(0, 8).toLowerCase() == 'https://') {
|
return path
|
} else {
|
return getFtpUrl() + path
|
}
|
}
|
}
|
}
|
</script>
|
|
<style scoped>
|
.user-link {
|
display: flex;
|
align-items: center;
|
height: 72px;
|
margin-right: 10px;
|
font-size: 0;
|
}
|
|
.avatar {
|
width: 45px;
|
height: 45px;
|
margin-right: 15px;
|
-webkit-border-radius: 50%;
|
-moz-border-radius: 50%;
|
border-radius: 50%;
|
}
|
|
.user-name {
|
color: #333;
|
font-weight: 600;
|
font-size: 18px;
|
font-family: Avenir, Helvetica Neue, Arial, Helvetica, sans-serif;
|
}
|
.dept-name{
|
font-size: 16px;
|
color: #333;
|
}
|
.title-name{
|
font-size: 16px;
|
color: #E04E5F;
|
}
|
</style>
|