feat(ProfilePage): 添加打卡次数格式化功能
添加 formatCheckInCount 方法,将超过99的打卡次数显示为'99+'
Showing
1 changed file
with
8 additions
and
3 deletions
| ... | @@ -39,19 +39,19 @@ | ... | @@ -39,19 +39,19 @@ |
| 39 | <div class="flex justify-around"> | 39 | <div class="flex justify-around"> |
| 40 | <div class="flex flex-col items-center min-w-[4rem]"> | 40 | <div class="flex flex-col items-center min-w-[4rem]"> |
| 41 | <div class="font-bold text-gray-800 px-2 leading-normal text-center w-full" style="font-size: 1.5rem;"> | 41 | <div class="font-bold text-gray-800 px-2 leading-normal text-center w-full" style="font-size: 1.5rem;"> |
| 42 | - {{ checkIns?.total_days || 0 }} | 42 | + {{ formatCheckInCount(checkIns?.total_days) }} |
| 43 | </div> | 43 | </div> |
| 44 | <div class="text-xs text-gray-500 mt-1">累计打卡</div> | 44 | <div class="text-xs text-gray-500 mt-1">累计打卡</div> |
| 45 | </div> | 45 | </div> |
| 46 | <div class="flex flex-col items-center min-w-[4rem]"> | 46 | <div class="flex flex-col items-center min-w-[4rem]"> |
| 47 | <div class="font-bold text-green-600 px-2 leading-normal text-center w-full" style="font-size: 1.5rem;"> | 47 | <div class="font-bold text-green-600 px-2 leading-normal text-center w-full" style="font-size: 1.5rem;"> |
| 48 | - {{ checkIns?.consecutive_days || 0 }} | 48 | + {{ formatCheckInCount(checkIns?.consecutive_days) }} |
| 49 | </div> | 49 | </div> |
| 50 | <div class="text-xs text-gray-500 mt-1">连续打卡</div> | 50 | <div class="text-xs text-gray-500 mt-1">连续打卡</div> |
| 51 | </div> | 51 | </div> |
| 52 | <div class="flex flex-col items-center min-w-[4rem]"> | 52 | <div class="flex flex-col items-center min-w-[4rem]"> |
| 53 | <div class="font-bold text-blue-600 px-2 leading-normal text-center w-full" style="font-size: 1.5rem;"> | 53 | <div class="font-bold text-blue-600 px-2 leading-normal text-center w-full" style="font-size: 1.5rem;"> |
| 54 | - {{ checkIns?.longest_consecutive_days || 0 }} | 54 | + {{ formatCheckInCount(checkIns?.longest_consecutive_days) }} |
| 55 | </div> | 55 | </div> |
| 56 | <div class="text-xs text-gray-500 mt-1">最长连续</div> | 56 | <div class="text-xs text-gray-500 mt-1">最长连续</div> |
| 57 | </div> | 57 | </div> |
| ... | @@ -148,6 +148,11 @@ const profile = ref({}); | ... | @@ -148,6 +148,11 @@ const profile = ref({}); |
| 148 | const checkIns = ref({}); | 148 | const checkIns = ref({}); |
| 149 | const isTeacher = ref(false); | 149 | const isTeacher = ref(false); |
| 150 | 150 | ||
| 151 | +const formatCheckInCount = (count) => { | ||
| 152 | + const num = Number(count) || 0; | ||
| 153 | + return num > 99 ? '99+' : num; | ||
| 154 | +}; | ||
| 155 | + | ||
| 151 | onMounted(async () => { | 156 | onMounted(async () => { |
| 152 | const { code, data } = await getUserInfoAPI(); | 157 | const { code, data } = await getUserInfoAPI(); |
| 153 | if (code) { | 158 | if (code) { | ... | ... |
-
Please register or login to post a comment