shikeying
2023-04-07 c192f834c4e092bc7c0f2722c343c25c1be619ab
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
<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>