feat(家庭积分): 从家庭仪表盘API获取总积分数据而非使用硬编码值
当用户是创建者时,现在通过调用getFamilyDashboardAPI获取家庭总积分数据,替代之前硬编码的9856积分值。这使积分显示与实际家庭数据保持同步。
Showing
1 changed file
with
9 additions
and
2 deletions
| ... | @@ -75,6 +75,7 @@ import { ref, computed, onMounted } from 'vue'; | ... | @@ -75,6 +75,7 @@ import { ref, computed, onMounted } from 'vue'; |
| 75 | import Taro, { useDidShow } from '@tarojs/taro'; | 75 | import Taro, { useDidShow } from '@tarojs/taro'; |
| 76 | import { ScreenLittle, Search2 } from '@nutui/icons-vue-taro'; | 76 | import { ScreenLittle, Search2 } from '@nutui/icons-vue-taro'; |
| 77 | import { getUserProfileAPI } from '@/api/user'; | 77 | import { getUserProfileAPI } from '@/api/user'; |
| 78 | +import { getFamilyDashboardAPI } from '@/api/family'; | ||
| 78 | 79 | ||
| 79 | const searchQuery = ref(''); | 80 | const searchQuery = ref(''); |
| 80 | const selectedPoints = ref(null); | 81 | const selectedPoints = ref(null); |
| ... | @@ -163,9 +164,15 @@ const initData = async () => { | ... | @@ -163,9 +164,15 @@ const initData = async () => { |
| 163 | const { code, data } = await getUserProfileAPI(); | 164 | const { code, data } = await getUserProfileAPI(); |
| 164 | if (code) { | 165 | if (code) { |
| 165 | isCreator.value = data?.user?.is_creator || false; | 166 | isCreator.value = data?.user?.is_creator || false; |
| 166 | - // 只有创建者才显示积分 | 167 | + // 只有创建者才显示积分并获取家庭数据 |
| 167 | if (isCreator.value) { | 168 | if (isCreator.value) { |
| 168 | - totalPoints.value = '9856'; | 169 | + // 获取家庭首页数据,从中提取总积分 |
| 170 | + const familyData = await getFamilyDashboardAPI(); | ||
| 171 | + if (familyData.code) { | ||
| 172 | + totalPoints.value = familyData.data.family.total_points || 0; | ||
| 173 | + } else { | ||
| 174 | + totalPoints.value = 0; | ||
| 175 | + } | ||
| 169 | } | 176 | } |
| 170 | } | 177 | } |
| 171 | } catch (error) { | 178 | } catch (error) { | ... | ... |
-
Please register or login to post a comment