NavInfoCard.vue
5.39 KB
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<template>
<div>
<div class="info-card" :class="{ infoActive: !isNavFilterActive }">
<!-- <DownOutlined class="arrow-icon" @click="downClicked" /> -->
<div class="info-card-content" :style="{width: collapsed? '80px' : '100%'}">
<!-- 用户卡片头像:缩小时点击会出现用户信息 v-if="collapsed" -->
<!-- <a-popover placement="right" v-if="collapsed">
<template v-slot:content>
<p>{{ username }}</p>
<p>{{ professionalTitle }}</p>
</template>
<a-avatar class="info-card-avatar" size="large" :style="{marginRight: collapsed? '0' : '15px'}">
<template v-slot:icon>
<UserOutlined />
</template>
</a-avatar>
</a-popover> -->
<!-- 未缩小无点击效果处理 v-if="!collapsed"-->
<a-avatar class="info-card-avatar" size="large" :style="{marginRight: '15px'}">
<template v-slot:icon>
<UserOutlined />
</template>
</a-avatar>
<div class="flex-column info-card-user" :style="{display: 'block'}">
<span class="two-line-ellipsis">{{username || '用户名啦啦啦'}}</span>
<span class="two-line-ellipsis">{{professionalTitle || '管理员'}}</span>
</div>
</div>
</div>
<!-- 菜单搜索 -->
<div class="search-menu" :class="{ navActive: isNavFilterActive }">
<a-input class="search-menu-input"
v-model:value="value" placeholder="菜单搜索" />
<UpCircleOutlined class="icon-arrow" @click="upClicked" />
</div>
</div>
</template>
<script>
import {
UpCircleOutlined,
DownOutlined,
UserOutlined
} from '@ant-design/icons-vue';
import { reactive, toRefs, computed, onMounted } from 'vue';
import { useStore } from 'vuex';
export default {
name: 'NavFilter',
components: {
UpCircleOutlined,
DownOutlined,
UserOutlined
},
// props: {
// collapsed: Boolean
// },
setup (props, context) {
const store = useStore();
const state = reactive({
isNavFilterActive: false,
value: '',
username: '用户名啦啦啦',
professionalTitle: '广联赛讯管理员'
});
const upClicked = () => {
// 点击菜单搜索按钮
state.isNavFilterActive = false;
};
const downClicked = () => {
// 点击用户卡片按钮
state.isNavFilterActive = true;
};
onMounted(() => {
const userInfo = store.getters.userInfo;
state.username = userInfo.username;
state.professionalTitle = userInfo.roleName;
})
return {
...toRefs(state),
upClicked,
downClicked
}
}
}
</script>
<style lang="less" scoped>
@import 'styles/variables.less';
@import 'styles/mixins.less';
.search-menu {
display: flex;
align-items: center;
opacity: 0;
visibility: hidden;
height: 0;
-webkit-transition: all 400ms cubic-bezier(0.34, 1.25, 0.3, 1);
transition: all 400ms cubic-bezier(0.34, 1.25, 0.3, 1);
-webkit-transform: scale(0.3);
transform: scale(0.3);
&-input {
border: 1px solid #E5E5E5;
border-radius: 4px;
border-color: rgba(0, 0, 0, 0.1);
background-color:#1a3051;
}
.icon-arrow {
margin-left: -30px;
transform: scale(1.4);
color: #fff;
}
}
.navActive {
opacity: 1;
visibility: visible;
height: 60px;
padding: 10px 20px;
-webkit-box-shadow: 0px 0px 28px 0px rgba(0, 0, 0, 0.13);
box-shadow: 0px 0px 28px 0px rgba(0, 0, 0, 0.13);
-webkit-transform: scale(1);
transform: scale(1);
}
.info-card {
position: relative;
overflow: hidden;
width: 220px;
height: 0;
background: url('../../../assets/images/info-card-cover.png') no-repeat;
opacity: 0;
visibility: hidden;
-webkit-transition: all 400ms cubic-bezier(0.34, 1.25, 0.3, 1);
transition: all 400ms cubic-bezier(0.34, 1.25, 0.3, 1);
.arrow-icon {
height: 21px;
background: rgba(0, 0, 0, 0.4);
padding: 0px 12px;
border: 1px solid rgba(0, 0, 0, 0.4);
border-radius: 0 0 20px 20px;
position: absolute;
left: 50%;
transform: translateX(-50%);
color: #fff;
-webkit-transition: all 200ms cubic-bezier(0.34, 1.25, 0.6, 1);
transition: all 200ms cubic-bezier(0.34, 1.25, 0.6, 1);
-webkit-box-shadow: 0px 0px 2px rgba(136, 106, 181, 0.3);
box-shadow: 0px 0px 2px rgba(136, 106, 181, 0.3);
&:hover {
cursor: pointer;
background: #4679cc;
border-color: #366bc3;
}
}
&-content {
width: 100%;
height: 100%;
color: #fff;
.vh-center;
}
&-avatar {
margin-right: 15px;
background-color: @defaultLightBlueColor;
}
&-user {
width: 100px;
span:last-child {
margin-top: 10px;
}
}
}
.infoActive {
opacity: 1;
height: 150px;
visibility: visible;
}
</style>