ProfilePage.vue
10.6 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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
<template>
<AppLayout title="我的" :right-content="rightContent">
<div
class="bg-gradient-to-br from-green-50 via-green-100/30 to-blue-50/30 min-h-screen"
>
<!-- User Profile Header with Enhanced Design -->
<div class="pt-6 pb-8 relative">
<div
class="absolute inset-0 bg-gradient-to-r from-green-500 to-blue-500 opacity-15"
></div>
<div class="relative z-10 flex flex-col items-center">
<div
class="w-24 h-24 rounded-full overflow-hidden border-4 border-white shadow-lg mb-4"
>
<img
:src="profile.avatar || '/assets/images/user-avatar-1.jpg'"
:alt="profile.name"
class="w-full h-full object-cover"
@error="handleImageError"
/>
</div>
<h2 class="text-2xl font-bold mb-1">{{ profile.name }}</h2>
<div class="flex items-center text-sm text-gray-600">
<span>会员等级: 普通会员</span>
<span class="mx-2">|</span>
<span>ID: 88361425</span>
</div>
</div>
</div>
<!-- Check-in Statistics -->
<div class="px-4 mb-5">
<FrostedGlass class="p-4 rounded-xl">
<div class="flex justify-between items-center mb-4">
<h3 class="font-semibold text-base">打卡统计</h3>
<span class="text-xs text-blue-500">查看更多</span>
</div>
<div class="flex justify-between">
<div class="flex flex-col items-center">
<div class="text-2xl font-bold text-gray-800">
{{ profile.checkIns?.totalDays || 0 }}
</div>
<div class="text-xs text-gray-500 mt-1">累计打卡</div>
</div>
<div class="flex flex-col items-center">
<div class="text-2xl font-bold text-green-600">
{{ profile.checkIns?.currentStreak || 0 }}
</div>
<div class="text-xs text-gray-500 mt-1">连续打卡</div>
</div>
<div class="flex flex-col items-center">
<div class="text-2xl font-bold text-blue-600">
{{ profile.checkIns?.longestStreak || 0 }}
</div>
<div class="text-xs text-gray-500 mt-1">最长连续</div>
</div>
<div>
<div @click="showCheckInDialog = true" class="cursor-pointer">
<button
class="bg-gradient-to-r from-green-500 to-green-600 text-white py-2 px-6 rounded-full text-sm shadow-sm"
>
立即打卡
</button>
</div>
</div>
</div>
</FrostedGlass>
</div>
<!-- Check-in Types -->
<!-- <div class="px-4 mb-5">
<FrostedGlass class="p-4 rounded-xl">
<h3 class="font-semibold text-base mb-4">打卡项目</h3>
<div class="grid grid-cols-4 gap-2">
<div
v-for="type in checkInTypes"
:key="type.id"
class="flex flex-col items-center cursor-pointer"
@click="handleCheckInClick(type.path)"
>
<div
class="w-12 h-12 rounded-full bg-green-100 flex items-center justify-center mb-1"
>
<svg
v-if="type.icon === 'book'"
xmlns="http://www.w3.org/2000/svg"
class="h-6 w-6 text-green-600"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253"
/>
</svg>
<svg
v-if="type.icon === 'running'"
xmlns="http://www.w3.org/2000/svg"
class="h-6 w-6 text-green-600"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M13 10V3L4 14h7v7l9-11h-7z"
/>
</svg>
<svg
v-if="type.icon === 'graduation-cap'"
xmlns="http://www.w3.org/2000/svg"
class="h-6 w-6 text-green-600"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path d="M12 14l9-5-9-5-9 5 9 5z" />
<path
d="M12 14l6.16-3.422a12.083 12.083 0 01.665 6.479A11.952 11.952 0 0012 20.055a11.952 11.952 0 00-6.824-2.998 12.078 12.078 0 01.665-6.479L12 14z"
/>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M12 14l9-5-9-5-9 5 9 5zm0 0l6.16-3.422a12.083 12.083 0 01.665 6.479A11.952 11.952 0 0012 20.055a11.952 11.952 0 00-6.824-2.998 12.078 12.078 0 01.665-6.479L12 14zm-4 6v-7.5l4-2.222"
/>
</svg>
<svg
v-if="type.icon === 'pencil-alt'"
xmlns="http://www.w3.org/2000/svg"
class="h-6 w-6 text-green-600"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z"
/>
</svg>
</div>
<span class="text-xs">{{ type.name }}</span>
</div>
</div>
</FrostedGlass>
</div> -->
<!-- User Menu Options -->
<div class="px-4 pb-16">
<FrostedGlass class="rounded-xl overflow-hidden mb-5">
<MenuItem
v-for="item in menuItems1"
:key="item.path"
v-bind="item"
@click="handleMenuClick(item.path)"
/>
</FrostedGlass>
<FrostedGlass class="rounded-xl overflow-hidden mb-5">
<MenuItem
v-for="item in menuItems2"
:key="item.path"
v-bind="item"
@click="handleMenuClick(item.path)"
/>
</FrostedGlass>
<FrostedGlass class="rounded-xl overflow-hidden mb-5">
<MenuItem
v-for="item in menuItems3"
:key="item.path"
v-bind="item"
@click="handleMenuClick(item.path)"
/>
</FrostedGlass>
<!-- Version Info -->
<div class="text-center text-xs text-gray-400 mb-4">亲子教育 App v1.2.0</div>
<!-- Logout Button -->
<button
@click="handleLogout"
class="w-full bg-white/70 backdrop-blur-sm text-red-500 py-3 rounded-xl mb-6 font-medium shadow-sm"
>
退出登录
</button>
</div>
</div>
</AppLayout>
<CheckInDialog
v-model:show="showCheckInDialog"
@check-in-success="handleCheckInSuccess"
/>
</template>
<script setup>
import { ref, h } from "vue";
import { useRoute, useRouter } from "vue-router";
import AppLayout from "@/components/layout/AppLayout.vue";
import FrostedGlass from "@/components/ui/FrostedGlass.vue";
import MenuItem from "@/components/ui/MenuItem.vue";
import { useAuth } from "@/contexts/auth";
import { userProfile, checkInTypes } from "@/utils/mockData";
import CheckInDialog from "@/components/ui/CheckInDialog.vue";
import { useTitle } from "@vueuse/core";
const router = useRouter();
const $route = useRoute();
const $router = useRouter();
useTitle($route.meta.title);
const { currentUser, logout } = useAuth();
const profile = ref(userProfile);
const showCheckInDialog = ref(false);
// 处理打卡成功
const handleCheckInSuccess = () => {
profile.value.checkIns.totalDays++;
profile.value.checkIns.currentStreak++;
profile.value.checkIns.longestStreak = Math.max(
profile.value.checkIns.longestStreak,
profile.value.checkIns.currentStreak
);
};
// Handle logout
const handleLogout = () => {
logout();
router.push("/");
};
// Handle menu item click
const handleMenuClick = (path) => {
router.push(path);
};
// Handle image error
const handleImageError = (e) => {
e.target.onerror = null;
e.target.src = "/assets/images/user-avatar-1.jpg";
};
// Handle check-in type click
const handleCheckInClick = (path) => {
router.push(path);
};
// Right content component
const rightContent = h("div", { class: "flex items-center" }, [
h("button", { class: "p-2" }, [
h(
"svg",
{
xmlns: "http://www.w3.org/2000/svg",
class: "h-6 w-6 text-gray-700",
fill: "none",
viewBox: "0 0 24 24",
stroke: "currentColor",
},
[
h("path", {
"stroke-linecap": "round",
"stroke-linejoin": "round",
"stroke-width": "2",
d:
"M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9",
}),
]
),
]),
]);
// Menu items
const menuItems1 = [
{
icon: "clock",
title: "学习记录",
path: "/profile/learning-records",
badge: "NEW",
},
{
icon: "user",
title: "我的活动",
path: "/profile/activities",
},
{
icon: "book",
title: "我的课程",
path: "/profile/courses",
},
{
icon: "heart",
title: "我的收藏",
path: "/profile/favorites",
},
];
const menuItems2 = [
// {
// icon: "wallet",
// title: "我的钱包",
// path: "/profile/wallet",
// },
{
icon: "document",
title: "我的订单",
path: "/profile/orders",
},
{
icon: "chat",
title: "我的圈子",
path: "/profile/community",
},
];
const menuItems3 = [
{
icon: "email",
title: "消息中心",
path: "/profile/messages",
badge: "3",
},
{
icon: "question",
title: "帮助中心",
path: "/profile/help",
},
{
icon: "settings",
title: "设置",
path: "/profile/settings",
},
];
</script>