feat(认证): 合并用户打卡数据并更新首页统计显示
在认证上下文中合并用户基本信息和打卡数据,同时在首页展示累计打卡、连续打卡和最长连续打卡天数
Showing
3 changed files
with
35 additions
and
11 deletions
| ... | @@ -29,14 +29,38 @@ declare module 'vue' { | ... | @@ -29,14 +29,38 @@ declare module 'vue' { |
| 29 | TermsPopup: typeof import('./components/ui/TermsPopup.vue')['default'] | 29 | TermsPopup: typeof import('./components/ui/TermsPopup.vue')['default'] |
| 30 | UploadVideoPopup: typeof import('./components/ui/UploadVideoPopup.vue')['default'] | 30 | UploadVideoPopup: typeof import('./components/ui/UploadVideoPopup.vue')['default'] |
| 31 | UserAgreement: typeof import('./components/ui/UserAgreement.vue')['default'] | 31 | UserAgreement: typeof import('./components/ui/UserAgreement.vue')['default'] |
| 32 | + VanActionSheet: typeof import('vant/es')['ActionSheet'] | ||
| 32 | VanButton: typeof import('vant/es')['Button'] | 33 | VanButton: typeof import('vant/es')['Button'] |
| 34 | + VanCalendar: typeof import('vant/es')['Calendar'] | ||
| 35 | + VanCellGroup: typeof import('vant/es')['CellGroup'] | ||
| 36 | + VanCheckbox: typeof import('vant/es')['Checkbox'] | ||
| 37 | + VanCol: typeof import('vant/es')['Col'] | ||
| 38 | + VanConfigProvider: typeof import('vant/es')['ConfigProvider'] | ||
| 39 | + VanDatePicker: typeof import('vant/es')['DatePicker'] | ||
| 40 | + VanDialog: typeof import('vant/es')['Dialog'] | ||
| 41 | + VanDivider: typeof import('vant/es')['Divider'] | ||
| 42 | + VanEmpty: typeof import('vant/es')['Empty'] | ||
| 33 | VanField: typeof import('vant/es')['Field'] | 43 | VanField: typeof import('vant/es')['Field'] |
| 44 | + VanForm: typeof import('vant/es')['Form'] | ||
| 34 | VanIcon: typeof import('vant/es')['Icon'] | 45 | VanIcon: typeof import('vant/es')['Icon'] |
| 35 | VanImage: typeof import('vant/es')['Image'] | 46 | VanImage: typeof import('vant/es')['Image'] |
| 47 | + VanImagePreview: typeof import('vant/es')['ImagePreview'] | ||
| 36 | VanList: typeof import('vant/es')['List'] | 48 | VanList: typeof import('vant/es')['List'] |
| 49 | + VanLoading: typeof import('vant/es')['Loading'] | ||
| 50 | + VanNavBar: typeof import('vant/es')['NavBar'] | ||
| 51 | + VanOverlay: typeof import('vant/es')['Overlay'] | ||
| 52 | + VanPicker: typeof import('vant/es')['Picker'] | ||
| 53 | + VanPickerGroup: typeof import('vant/es')['PickerGroup'] | ||
| 37 | VanPopup: typeof import('vant/es')['Popup'] | 54 | VanPopup: typeof import('vant/es')['Popup'] |
| 38 | VanProgress: typeof import('vant/es')['Progress'] | 55 | VanProgress: typeof import('vant/es')['Progress'] |
| 39 | VanRate: typeof import('vant/es')['Rate'] | 56 | VanRate: typeof import('vant/es')['Rate'] |
| 57 | + VanRow: typeof import('vant/es')['Row'] | ||
| 58 | + VanSwipe: typeof import('vant/es')['Swipe'] | ||
| 59 | + VanSwipeItem: typeof import('vant/es')['SwipeItem'] | ||
| 60 | + VanTab: typeof import('vant/es')['Tab'] | ||
| 61 | + VanTabs: typeof import('vant/es')['Tabs'] | ||
| 62 | + VanTag: typeof import('vant/es')['Tag'] | ||
| 63 | + VanUploader: typeof import('vant/es')['Uploader'] | ||
| 40 | VideoPlayer: typeof import('./components/ui/VideoPlayer.vue')['default'] | 64 | VideoPlayer: typeof import('./components/ui/VideoPlayer.vue')['default'] |
| 41 | WechatPayment: typeof import('./components/payment/WechatPayment.vue')['default'] | 65 | WechatPayment: typeof import('./components/payment/WechatPayment.vue')['default'] |
| 42 | } | 66 | } | ... | ... |
| 1 | /* | 1 | /* |
| 2 | * @Date: 2025-03-20 21:11:31 | 2 | * @Date: 2025-03-20 21:11:31 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-06-13 11:09:37 | 4 | + * @LastEditTime: 2025-06-15 20:06:25 |
| 5 | * @FilePath: /mlaj/src/contexts/auth.js | 5 | * @FilePath: /mlaj/src/contexts/auth.js |
| 6 | * @Description: 认证上下文管理模块,提供用户认证状态管理、登录登出功能 | 6 | * @Description: 认证上下文管理模块,提供用户认证状态管理、登录登出功能 |
| 7 | */ | 7 | */ |
| ... | @@ -64,7 +64,7 @@ export function provideAuth() { | ... | @@ -64,7 +64,7 @@ export function provideAuth() { |
| 64 | // 从服务器获取用户信息并更新本地存储 | 64 | // 从服务器获取用户信息并更新本地存储 |
| 65 | const { code, data } = await getUserInfoAPI(); | 65 | const { code, data } = await getUserInfoAPI(); |
| 66 | if (code) { | 66 | if (code) { |
| 67 | - currentUser.value = data.user | 67 | + currentUser.value = { ...data.user, ...data.checkin } |
| 68 | localStorage.setItem('currentUser', JSON.stringify(currentUser.value)) | 68 | localStorage.setItem('currentUser', JSON.stringify(currentUser.value)) |
| 69 | } else { | 69 | } else { |
| 70 | logout() | 70 | logout() |
| ... | @@ -74,7 +74,7 @@ export function provideAuth() { | ... | @@ -74,7 +74,7 @@ export function provideAuth() { |
| 74 | const { code, data } = await getAuthInfoAPI(); | 74 | const { code, data } = await getAuthInfoAPI(); |
| 75 | if(code) { | 75 | if(code) { |
| 76 | if (data.openid_has) { | 76 | if (data.openid_has) { |
| 77 | - currentUser.value = data.user | 77 | + currentUser.value = { ...data.user, ...data.checkin } |
| 78 | localStorage.setItem('currentUser', JSON.stringify(currentUser.value)) | 78 | localStorage.setItem('currentUser', JSON.stringify(currentUser.value)) |
| 79 | } | 79 | } |
| 80 | } | 80 | } | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2025-03-20 19:55:21 | 2 | * @Date: 2025-03-20 19:55:21 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-06-13 16:26:25 | 4 | + * @LastEditTime: 2025-06-15 20:07:21 |
| 5 | * @FilePath: /mlaj/src/views/HomePage.vue | 5 | * @FilePath: /mlaj/src/views/HomePage.vue |
| 6 | * @Description: 美乐爱觉教育首页组件 | 6 | * @Description: 美乐爱觉教育首页组件 |
| 7 | * | 7 | * |
| ... | @@ -59,17 +59,17 @@ | ... | @@ -59,17 +59,17 @@ |
| 59 | <!-- User Stats --> | 59 | <!-- User Stats --> |
| 60 | <div class="flex justify-between text-center py-2"> | 60 | <div class="flex justify-between text-center py-2"> |
| 61 | <div class="border-r border-gray-200 flex-1"> | 61 | <div class="border-r border-gray-200 flex-1"> |
| 62 | - <div class="text-lg font-bold">3</div> | 62 | + <div class="text-lg font-bold">{{ currentUser?.total_days || 0 }}</div> |
| 63 | + <div class="text-xs text-gray-500">累计打卡</div> | ||
| 64 | + </div> | ||
| 65 | + <div class="border-gray-200 flex-1"> | ||
| 66 | + <div class="text-lg font-bold">{{ currentUser?.consecutive_days || 0 }}</div> | ||
| 63 | <div class="text-xs text-gray-500">连续打卡</div> | 67 | <div class="text-xs text-gray-500">连续打卡</div> |
| 64 | </div> | 68 | </div> |
| 65 | <div class="border-gray-200 flex-1"> | 69 | <div class="border-gray-200 flex-1"> |
| 66 | - <div class="text-lg font-bold">12</div> | 70 | + <div class="text-lg font-bold">{{ currentUser?.longest_consecutive_days || 0 }}</div> |
| 67 | - <div class="text-xs text-gray-500">已学课程</div> | 71 | + <div class="text-xs text-gray-500">最长连续</div> |
| 68 | </div> | 72 | </div> |
| 69 | - <!-- <div class="flex-1"> | ||
| 70 | - <div class="text-lg font-bold">25</div> | ||
| 71 | - <div class="text-xs text-gray-500">积分</div> | ||
| 72 | - </div> --> | ||
| 73 | </div> | 73 | </div> |
| 74 | </FrostedGlass> | 74 | </FrostedGlass> |
| 75 | 75 | ... | ... |
-
Please register or login to post a comment