8d73e917
陈威
初始化提交
|
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
|
<template>
<div :class="{'avatar-wrap':isShowTriangle}">
<el-avatar :src="userPhoto">
<img :src="userPhoto" />
</el-avatar>
<i v-if="isShowTriangle" class="icon-nav-user-unfold triangle-icon"></i>
</div>
</template>
<script>
export default {
props: {
user:{
type:Object,
default:()=>{}
},
isShowTriangle:{
type:Boolean,
default:false
}
},
data() {
return {
userPhoto: null,
userPhotoUrl: null,
defaultUserPhoto: window.context.manage + "/img/defaultPhoto.jpg"
};
},
watch: {
user: {
handler: function(val, oldVal) {
if (val && val.user && val.user.photo && val !== oldVal && val.user.photo != '/img/defaultPhoto.jpg' ) {
this.$store.dispatch("menu/downloadImg",val.user.photo).then(res => {
if (res != "") {
this.userPhoto = res;
}else{
this.userPhoto = this.defaultUserPhoto;
}
});
} else {
this.userPhoto = this.defaultUserPhoto;
}
},
deep: true
}
}
};
</script>
<style lang="scss" scoped>
.avatar-wrap{
display: flex;
align-items: center;
.triangle-icon{
margin-left: 12px;
}
&:hover{
.triangle-icon{
transform: rotateZ(180deg);
margin-left: 0;
margin-right: 12px;
}
}
}
::v-deep.el-avatar {
display: flex;
align-items: center;
justify-content: center;
img {
height: 100%;
width: 100%;
}
}
</style>
|