|
...
|
...
|
@@ -346,14 +346,14 @@ const chartSeries = computed(() => { |
|
|
|
const dataKey = TREND_DATA_KEYS[NumberTabIndex.value] || 'volume';
|
|
|
|
|
|
|
|
// 当前周期数据
|
|
|
|
const currData = fullDateKeys.map((dateStr) => currDataMap[dateStr]?.[dataKey] ?? 0);
|
|
|
|
const currData = fullDateKeys.map((dateStr) => convertUnit(currDataMap[dateStr]?.[dataKey], dataKey));
|
|
|
|
|
|
|
|
// 上一周期数据(按日期偏移匹配)
|
|
|
|
const lastData = fullDateKeys.map((dateStr) => {
|
|
|
|
const targetKey = isWeekly
|
|
|
|
? dayjs(dateStr).subtract(7, 'day').format('YYYY-MM-DD')
|
|
|
|
: dayjs(dateStr).subtract(1, 'month').format('YYYY-MM-DD');
|
|
|
|
return lastDataMap[targetKey]?.[dataKey] ?? 0;
|
|
|
|
return convertUnit(lastDataMap[targetKey]?.[dataKey], dataKey);
|
|
|
|
});
|
|
|
|
|
|
|
|
const currName = isWeekly ? '本周' : '本月';
|
|
...
|
...
|
@@ -373,25 +373,39 @@ const listData = computed(() => { |
|
|
|
|
|
|
|
const d = weeklyData.value;
|
|
|
|
const fields = [
|
|
|
|
{ label: '容量', last: d.lastWeekTotalVolume, curr: d.totalVolume },
|
|
|
|
{ label: '组数', last: d.lastWeekTotalSets, curr: d.totalSets },
|
|
|
|
{ label: '时长', last: d.lastWeekTotalDuration, curr: d.totalDuration },
|
|
|
|
{ label: '距离', last: d.lastWeekTotalDistance, curr: d.totalDistance },
|
|
|
|
{ label: '次数', last: d.lastWeekTotalCount, curr: d.totalCount },
|
|
|
|
{ label: '容量', key: 'volume', last: d.lastWeekTotalVolume, curr: d.totalVolume },
|
|
|
|
{ label: '组数', key: 'setCount', last: d.lastWeekTotalSets, curr: d.totalSets },
|
|
|
|
{ label: '时长', key: 'duration', last: d.lastWeekTotalDuration, curr: d.totalDuration },
|
|
|
|
{ label: '距离', key: 'distance', last: d.lastWeekTotalDistance, curr: d.totalDistance },
|
|
|
|
{ label: '次数', key: 'count', last: d.lastWeekTotalCount, curr: d.totalCount },
|
|
|
|
];
|
|
|
|
|
|
|
|
return fields.map(({ label, last, curr }) => {
|
|
|
|
const lastVal = last ?? 0;
|
|
|
|
const currVal = curr ?? 0;
|
|
|
|
return fields.map(({ label, key, last, curr }) => {
|
|
|
|
const lastVal = convertUnit(last, key);
|
|
|
|
const currVal = convertUnit(curr, key);
|
|
|
|
return {
|
|
|
|
label,
|
|
|
|
lastPeriod: lastVal,
|
|
|
|
currPeriod: currVal,
|
|
|
|
diff: currVal - lastVal,
|
|
|
|
diff: Number((currVal - lastVal).toFixed(1)),
|
|
|
|
};
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 字段单位换算:API 返回秒/米等,UI 展示为分/km 等
|
|
|
|
* duration(秒)→ 分钟
|
|
|
|
* 其它字段(volume/setCount/distance/count)保持原值
|
|
|
|
*/
|
|
|
|
const convertUnit = (val, key) => {
|
|
|
|
const v = Number(val) || 0;
|
|
|
|
if (key === 'duration') {
|
|
|
|
// 秒 → 分钟,保留 1 位小数(如 90s → 1.5)
|
|
|
|
return Math.round((v / 60) * 10) / 10;
|
|
|
|
}
|
|
|
|
return v;
|
|
|
|
};
|
|
|
|
|
|
|
|
/** 肌肉弹窗图表 X 轴 */
|
|
|
|
const muscleChartCategories = computed(() => {
|
|
|
|
if (MainCurrentDateType.value === 'week') {
|
...
|
...
|
|