diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts index 0f503f1..a018980 100644 --- a/frontend/src/router/index.ts +++ b/frontend/src/router/index.ts @@ -144,6 +144,30 @@ const routes: RouteRecordRaw[] = [ title: '激励中心' } }, + { + path: '/my-badges', + name: 'MyBadges', + component: () => import('@/views/MyBadges.vue'), + meta: { + title: '我的徽章' + } + }, + { + path: '/my-titles', + name: 'MyTitles', + component: () => import('@/views/MyTitles.vue'), + meta: { + title: '我的称号' + } + }, + { + path: '/reward-records', + name: 'RewardRecords', + component: () => import('@/views/RewardRecords.vue'), + meta: { + title: '奖励记录' + } + }, { path: '/admin/tasks', name: 'AdminTaskManagement', diff --git a/frontend/src/views/IncentiveCenter.vue b/frontend/src/views/IncentiveCenter.vue index 2e823f2..64f0279 100644 --- a/frontend/src/views/IncentiveCenter.vue +++ b/frontend/src/views/IncentiveCenter.vue @@ -23,6 +23,10 @@ {{ continuousCheckIn }} 连续签到 +
+ {{ badgeCount }} + 获得徽章 +
{{ achievementCount }} 已获成就 @@ -35,6 +39,15 @@
+ +
+
+ {{ activeTitle.titleName }} +
+ 当前佩戴的称号 + 更换称号 +
+
@@ -55,10 +68,40 @@
+ +
+
+ +
+
+

我的徽章

+

收集徽章,展示成就

+
+
+ 已获 {{ badgeCount }} 个 +
+ +
+ + +
+
+ +
+
+

我的称号

+

解锁称号,彰显身份

+
+
+ 已有 {{ titleCount }} 个 +
+ +
+
- +

成就中心

@@ -118,7 +161,7 @@
- +

排行榜

@@ -131,30 +174,52 @@
- +

- 积分记录 + 奖励记录

- 查看全部 + 查看全部
-
+
- +
- {{ record.title }} - {{ formatTime(record.time) }} + {{ record.ruleName || '系统奖励' }} + {{ formatTime(record.createTime) }}
-
- {{ record.score > 0 ? '+' : '' }}{{ record.score }} +
+ {{ parseRewardValue(record.rewardValue) }}
- 暂无积分记录 + 暂无奖励记录,快去完成任务获取奖励吧! +
+
+
+ +
+
+ + +
+
+

+ + 我的徽章 +

+ 查看全部 +
+
+
+
+ {{ badge.badgeName.charAt(0) }} +
+ {{ badge.badgeName }}
@@ -174,6 +239,15 @@ import { hasCheckedInToday, getCheckInStats } from '@/api/incentive' import { getMyGoals } from '@/api/goal' import { getContestList } from '@/api/contest' import { getTeamPKList } from '@/api/teamPK' +import { + getMyRewardRecords, + getMyBadges, + getMyTitles, + getMyActiveTitle, + type RewardRecord, + type UserBadge, + type UserTitle +} from '@/api/rewardRule' const router = useRouter() const authStore = useAuthStore() @@ -189,18 +263,15 @@ const myRank = ref(0) const unclaimedAchievements = ref(0) const hasCheckedIn = ref(false) -// 积分记录 -const recentRecords = ref>([ - { id: 1, type: 'checkin', title: '每日签到奖励', score: 10, time: new Date().toISOString() }, - { id: 2, type: 'task', title: '完成任务获得积分', score: 50, time: new Date(Date.now() - 86400000).toISOString() }, - { id: 3, type: 'achievement', title: '解锁成就「初出茅庐」', score: 100, time: new Date(Date.now() - 172800000).toISOString() }, -]) +// 新增:徽章和称号数据 +const badgeCount = ref(0) +const titleCount = ref(0) +const myBadges = ref([]) +const activeTitle = ref(null) + +// 奖励记录 +const recordsLoading = ref(false) +const recentRecords = ref([]) const loadData = async () => { try { @@ -224,18 +295,41 @@ const loadData = async () => { activePKCount.value = pks.records?.length || 0 } catch (error) { - console.error('加载数据失败:', error) + console.error('加载基础数据失败:', error) + } +} + +const loadRewardData = async () => { + try { + // 加载奖励记录 + recordsLoading.value = true + const recordsResult = await getMyRewardRecords({ page: 1, pageSize: 5 }) + recentRecords.value = recordsResult.records || [] + + // 加载我的徽章 + myBadges.value = await getMyBadges() + badgeCount.value = myBadges.value.length + + // 加载我的称号 + const titles = await getMyTitles() + titleCount.value = titles.length + + // 加载当前激活称号 + activeTitle.value = await getMyActiveTitle() + + } catch (error) { + console.error('加载奖励数据失败:', error) + } finally { + recordsLoading.value = false } } const getRecordIcon = (type: string) => { const iconMap: Record = { - checkin: 'calendar', - task: 'document', - achievement: 'trophy', - contest: 'fire', - pk: 'bolt', - goal: 'flag' + score: 'star', + badge: 'star', + title: 'badge', + exp: 'zap' } return iconMap[type] || 'star' } @@ -244,19 +338,31 @@ const formatTime = (time: string) => { return dayjs(time).format('MM-DD HH:mm') } -const viewAllRecords = () => { - // TODO: 跳转到积分记录详情页 +const parseRewardValue = (value: string) => { + try { + const obj = JSON.parse(value) + if (obj.score) return `+${obj.score} 积分` + if (obj.badge) return `获得徽章` + if (obj.title) return `获得称号` + return '+奖励' + } catch { + return value + } } onMounted(() => { loadData() + loadRewardData() }) diff --git a/frontend/src/views/MyBadges.vue b/frontend/src/views/MyBadges.vue new file mode 100644 index 0000000..99694d8 --- /dev/null +++ b/frontend/src/views/MyBadges.vue @@ -0,0 +1,270 @@ + + + + + + diff --git a/frontend/src/views/MyTitles.vue b/frontend/src/views/MyTitles.vue new file mode 100644 index 0000000..f7aab23 --- /dev/null +++ b/frontend/src/views/MyTitles.vue @@ -0,0 +1,318 @@ + + + + + + diff --git a/frontend/src/views/RewardRecords.vue b/frontend/src/views/RewardRecords.vue new file mode 100644 index 0000000..d7b5c37 --- /dev/null +++ b/frontend/src/views/RewardRecords.vue @@ -0,0 +1,264 @@ + + + + + +