welcome-banner.vue
3.07 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
<template>
<workbench-card variant="banner">
<div class="welcome">
<div class="welcome__glow" aria-hidden="true" />
<div class="welcome__avatar">
<i class="el-icon-user-solid" />
</div>
<div class="welcome__content">
<div class="welcome__hello">{{ greeting }},{{ userName }}</div>
<div class="welcome__meta">
<span><i class="el-icon-office-building" />{{ storeName || '未绑定门店' }}</span>
<span class="welcome__sep">·</span>
<span><i class="el-icon-date" />{{ todayText }}</span>
</div>
</div>
<div class="welcome__chip">今日工作台</div>
</div>
</workbench-card>
</template>
<script>
import { mapGetters } from 'vuex'
import WorkbenchCard from '../workbench-card.vue'
export default {
name: 'WidgetWelcomeBanner',
components: { WorkbenchCard },
computed: {
...mapGetters(['userInfo']),
userName() {
return (this.userInfo && (this.userInfo.realName || this.userInfo.userName)) || '用户'
},
storeName() {
return (this.userInfo && (this.userInfo.organizeName || this.userInfo.departmentName)) || ''
},
todayText() {
const d = new Date()
const week = ['日', '一', '二', '三', '四', '五', '六'][d.getDay()]
return `${d.getFullYear()}年${d.getMonth() + 1}月${d.getDate()}日 周${week}`
},
greeting() {
const h = new Date().getHours()
if (h < 12) return '上午好'
if (h < 18) return '下午好'
return '晚上好'
}
}
}
</script>
<style lang="scss" scoped>
.welcome {
position: relative;
display: flex;
align-items: center;
height: 100%;
min-height: 72px;
padding: 16px 20px;
border-radius: 12px;
overflow: hidden;
background: linear-gradient(120deg, #2f7fd4 0%, #409eff 48%, #79bbff 100%);
color: #fff;
box-shadow: 0 8px 24px rgba(64, 158, 255, 0.22);
}
.welcome__glow {
position: absolute;
right: -40px;
top: -50px;
width: 180px;
height: 180px;
border-radius: 50%;
background: rgba(255, 255, 255, 0.12);
pointer-events: none;
}
.welcome__avatar {
width: 46px;
height: 46px;
border-radius: 14px;
background: rgba(255, 255, 255, 0.2);
border: 1px solid rgba(255, 255, 255, 0.28);
display: flex;
align-items: center;
justify-content: center;
font-size: 22px;
margin-right: 14px;
flex-shrink: 0;
position: relative;
z-index: 1;
}
.welcome__content {
flex: 1;
min-width: 0;
position: relative;
z-index: 1;
}
.welcome__hello {
font-size: 18px;
font-weight: 700;
letter-spacing: 0.02em;
}
.welcome__meta {
margin-top: 6px;
font-size: 12px;
color: rgba(255, 255, 255, 0.88);
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 4px;
i { margin-right: 4px; opacity: 0.9; }
}
.welcome__sep { opacity: 0.55; margin: 0 2px; }
.welcome__chip {
position: relative;
z-index: 1;
padding: 6px 12px;
border-radius: 999px;
background: rgba(255, 255, 255, 0.18);
border: 1px solid rgba(255, 255, 255, 0.25);
font-size: 12px;
font-weight: 500;
flex-shrink: 0;
backdrop-filter: blur(4px);
}
</style>