feat: 更新健康数据功能和用户个人信息页面
- 在 Explore 页面中添加日期选择功能,允许用户查看指定日期的健康数据 - 重构健康数据获取逻辑,支持根据日期获取健康数据 - 在个人信息页面中集成用户资料编辑功能,支持姓名、性别、年龄、体重和身高的输入 - 新增 AnimatedNumber 和 CircularRing 组件,优化数据展示效果 - 更新 package.json 和 package-lock.json,添加 react-native-svg 依赖 - 修改布局以支持新功能的显示和交互
This commit is contained in:
@@ -38,12 +38,15 @@ export async function ensureHealthPermissions(): Promise<boolean> {
|
||||
});
|
||||
}
|
||||
|
||||
export async function fetchTodayHealthData(): Promise<TodayHealthData> {
|
||||
console.log('开始获取今日健康数据...');
|
||||
export async function fetchHealthDataForDate(date: Date): Promise<TodayHealthData> {
|
||||
console.log('开始获取指定日期健康数据...', date);
|
||||
|
||||
const start = new Date();
|
||||
const start = new Date(date);
|
||||
start.setHours(0, 0, 0, 0);
|
||||
const options = { startDate: start.toISOString() } as any;
|
||||
const end = new Date(date);
|
||||
end.setHours(23, 59, 59, 999);
|
||||
|
||||
const options = { startDate: start.toISOString(), endDate: end.toISOString() } as any;
|
||||
|
||||
console.log('查询选项:', options);
|
||||
|
||||
@@ -73,11 +76,16 @@ export async function fetchTodayHealthData(): Promise<TodayHealthData> {
|
||||
return resolve(0);
|
||||
}
|
||||
console.log('卡路里数据:', res);
|
||||
// library returns value as number in kilocalories
|
||||
resolve(res[0]?.value || 0);
|
||||
// 求和该日内的所有记录(单位:千卡)
|
||||
const total = res.reduce((acc: number, item: any) => acc + (item?.value || 0), 0);
|
||||
resolve(total);
|
||||
});
|
||||
});
|
||||
|
||||
console.log('今日健康数据获取完成:', { steps, calories });
|
||||
console.log('指定日期健康数据获取完成:', { steps, calories });
|
||||
return { steps, activeEnergyBurned: calories };
|
||||
}
|
||||
|
||||
export async function fetchTodayHealthData(): Promise<TodayHealthData> {
|
||||
return fetchHealthDataForDate(new Date());
|
||||
}
|
||||
Reference in New Issue
Block a user