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
| <template>
| <div class="userCard">
| <div class="profile">
| <img src="/images/index/默认头像-01.png" alt="" />
| </div>
| <div class="notification" v-if="!userInfo">
| Hi!请
| <span class="login" @click="jump('/login')">登录</span>或<span
| class="register"
| @click="jump('/register')"
| >注册</span
| >
| </div>
| <div class="des" v-if="!userInfo">登录后查看个人工具栏</div>
| <div class="userName" v-else>{{ userInfo.username }}</div>
| <div class="bottom">
| <div class="bottomItem" v-for="(item, index) in userCardArr" :key="index">
| <div class="num">{{ item.num }}</div>
| <div class="label">{{ item.label }}</div>
| </div>
| </div>
| </div>
| </template>
|
| <script>
| export default {
| props: {
| userCardArr: {
| type: Array,
| default: () => {
| return [
| {
| num: "_",
| label: "待付款",
| },
| {
| num: "_",
| label: "待消费",
| },
| {
| num: "_",
| label: "消息中心",
| },
| ];
| },
| },
| },
| created() {
| //尝试从session中拿用户信息
| this.userInfo = JSON.parse(sessionStorage.getItem("userInfo"));
| },
| data() {
| return {
| userInfo: null, //用户信息
| };
| },
| methods: {
| jump(url) {
| this.$router.push(url);
| },
| },
| };
| </script>
|
| <style scoped lang="scss">
| .userCard {
| width: 302px;
| height: 250px;
| display: flex;
| flex-direction: column;
| align-items: center;
| box-sizing: border-box;
| padding: 40px 0 20px 0;
|
| background: #ffffff;
| box-shadow: 0px 4px 12px rgba(0, 43, 106, 0.12);
|
| img {
| width: 70px;
| }
|
| .notification {
| margin-top: 5px;
| font-weight: 700;
| font-size: 14px;
|
| span {
| color: #0065ff;
| cursor: pointer;
| }
| }
|
| .userName {
| font-size: 14px;
| font-weight: 700;
| margin-top: 10px;
| }
|
| .des {
| font-size: 12px;
| color: #999999;
| }
|
| .bottom {
| display: flex;
| margin-top: 20px;
| width: 100%;
| .bottomItem {
| flex: 1;
| text-align: center;
|
| .num {
| margin-bottom: 5px;
| color: #0065ff;
| font-weight: 700;
| }
|
| .label {
| color: #999999;
| font-size: 14px;
| }
| }
| }
| }
| </style>
|
|