Files
digital-pilates/services/circumferenceAnalysis.ts
2025-09-24 18:04:12 +08:00

42 lines
1.2 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { api } from './api';
export type CircumferencePeriod = 'week' | 'month' | 'year';
export type CircumferenceAnalysisData = {
label: string;
chestCircumference: number | null;
waistCircumference: number | null;
upperHipCircumference: number | null;
armCircumference: number | null;
thighCircumference: number | null;
calfCircumference: number | null;
};
export type CircumferenceAnalysisResponse = {
code: number;
message: string;
data: CircumferenceAnalysisData[];
};
/**
* 获取围度分析报表数据
* @param period 时间范围week(按周)、month(按月)、year(按年)
* @returns 围度分析数据
*/
export async function getCircumferenceAnalysis(period: CircumferencePeriod): Promise<CircumferenceAnalysisData[]> {
try {
const response = await api.get<CircumferenceAnalysisResponse>(
`/users/body-measurements/analysis?period=${period}`
);
// 根据API文档支持返回 { data: ... } 或直接返回数组
if (Array.isArray(response)) {
return response;
}
return response.data || [];
} catch (error) {
console.error('获取围度分析数据失败:', error);
throw error;
}
}