hookehuyr

refactor(profile): 更新打卡数据字段名以匹配后端返回结构

将打卡数据字段从驼峰式改为下划线式以保持前后端一致
...@@ -39,19 +39,19 @@ ...@@ -39,19 +39,19 @@
39 <div class="flex justify-between"> 39 <div class="flex justify-between">
40 <div class="flex flex-col items-center"> 40 <div class="flex flex-col items-center">
41 <div class="text-2xl font-bold text-gray-800"> 41 <div class="text-2xl font-bold text-gray-800">
42 - {{ profile.checkIns?.totalDays || 0 }} 42 + {{ checkIns?.total_days || 0 }}
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"> 46 <div class="flex flex-col items-center">
47 <div class="text-2xl font-bold text-green-600"> 47 <div class="text-2xl font-bold text-green-600">
48 - {{ profile.checkIns?.currentStreak || 0 }} 48 + {{ checkIns?.consecutive_days || 0 }}
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"> 52 <div class="flex flex-col items-center">
53 <div class="text-2xl font-bold text-blue-600"> 53 <div class="text-2xl font-bold text-blue-600">
54 - {{ profile.checkIns?.longestStreak || 0 }} 54 + {{ checkIns?.longest_consecutive_days || 0 }}
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>
...@@ -136,11 +136,13 @@ const $route = useRoute(); ...@@ -136,11 +136,13 @@ const $route = useRoute();
136 useTitle($route.meta.title); 136 useTitle($route.meta.title);
137 137
138 const profile = ref({}); 138 const profile = ref({});
139 +const checkIns = ref({});
139 140
140 onMounted(async () => { 141 onMounted(async () => {
141 const { code, data } = await getUserInfoAPI(); 142 const { code, data } = await getUserInfoAPI();
142 if (code) { 143 if (code) {
143 profile.value = data.user; 144 profile.value = data.user;
145 + checkIns.value = data.checkin;
144 } 146 }
145 }) 147 })
146 148
...@@ -148,11 +150,11 @@ const showCheckInDialog = ref(false); ...@@ -148,11 +150,11 @@ const showCheckInDialog = ref(false);
148 150
149 // 处理打卡成功 151 // 处理打卡成功
150 const handleCheckInSuccess = () => { 152 const handleCheckInSuccess = () => {
151 - profile.value.checkIns.totalDays++; 153 + checkIns.value.total_days++;
152 - profile.value.checkIns.currentStreak++; 154 + checkIns.value.consecutive_days++;
153 - profile.value.checkIns.longestStreak = Math.max( 155 + checkIns.value.longest_consecutive_days = Math.max(
154 - profile.value.checkIns.longestStreak, 156 + checkIns.value.longest_consecutive_days,
155 - profile.value.checkIns.currentStreak 157 + checkIns.value.consecutive_days
156 ); 158 );
157 }; 159 };
158 160
......