Authored by qxm

Merge branch 'master' into feature/qxm

... ... @@ -3,9 +3,26 @@
<scroll-view class="action-container" scroll-y>
<view class="header" v-if="type == 1">
<view class="explain">
<image v-if="modeTab < 2" :src="modeTab == 0 ? actionDetail.url3dAnimation : actionDetail.urlRealPerson"
class="media-content" mode="aspectFill" />
<view class="video" v-else @click="playVideo(actionDetail.urlTutorial)">
<!-- 3D 固定图片 -->
<image v-if="modeTab === 0" :src="actionDetail.url3dAnimation" class="media-content" mode="aspectFill" />
<!-- 真人模块:自动区分图片/视频 -->
<template v-else-if="modeTab === 1">
<!-- 是图片 -->
<image v-if="!isVideoUrl(actionDetail.urlRealPerson)" :src="actionDetail.urlRealPerson"
class="media-content" mode="aspectFill" />
<!-- 是视频 -->
<view v-else class="video" @click="playVideo(actionDetail.urlRealPerson)">
<video :src="actionDetail.urlRealPerson" class="media-content" :autoplay="false"
:show-center-play-btn="false" :controls="false" />
<view class="play-icon">
<up-icon name="play-right" size="28" class="icon" color="#fff"></up-icon>
</view>
</view>
</template>
<!-- 讲解 固定视频 -->
<view v-else class="video" @click="playVideo(actionDetail.urlTutorial)">
<video :src="actionDetail.urlTutorial" class="media-content" :autoplay="false" :show-center-play-btn="false"
:controls="false" />
<view class="play-icon">
... ... @@ -150,7 +167,7 @@
<!-- <view class="difficulty">困难</view> -->
<view class="difficulty">{{
item.weight ? item.weight + 'kg' : '无负重'
}}</view>
}}</view>
</view>
<view class="group-chips">
<view class="chip" v-for="(set, index) in item.setConfigList" :key="index">
... ... @@ -218,6 +235,7 @@ const actionId = ref(0);
// 记录是超级组还是动作组 1=动作组,2=超级组
const type = ref(0);
const showBeizhuRef = ref(null);
const historyList = ref([]); // 训练历史列表接口数据
const lostImage =
'https://fitness-hcxtec-bucket.oss-cn-shenzhen.aliyuncs.com/20260316/order-empty_1773628059920.png';
... ... @@ -227,6 +245,14 @@ const switchModeTab = (index) => {
modeTab.value = index;
};
// 判断链接是否为视频链接
const isVideoUrl = (url) => {
if (!url) return false;
const videoExts = ['.mp4', '.mov', '.avi', '.mkv', '.webm'];
const lowerUrl = url.toLowerCase();
return videoExts.some(ext => lowerUrl.includes(ext));
};
// 跳转到视频播放的页面
const playVideo = (url) => {
uni.navigateTo({
... ... @@ -276,9 +302,9 @@ const startTraining = () => {
const open = (id, typeData) => {
actionId.value = Number(id);
type.value = typeData;
contentTab.value = 0;
console.log('动作详情页面接收id和类型:', actionId.value, type.value);
// 如何判断是动作还是超级组
if (typeData == 1) {
loadexercisedetail(actionId.value);
... ... @@ -289,6 +315,9 @@ const open = (id, typeData) => {
checkSupersetFavorited();
}
console.log('请求参数actionId/typeData', actionId.value, type.value);
loadTrainHistoryDetail(actionId.value, type.value);
actionShow.value = true;
};
... ... @@ -381,12 +410,21 @@ const loadAlternativeActions = async (id) => {
// 加载训练历史
const loadTrainHistoryDetail = async (id, type) => {
// 新增参数校验
if (!id || isNaN(Number(id)) || type === undefined || type === null) {
console.warn('训练历史参数非法,跳过请求', { id, type });
historyList.value = [];
return;
}
console.log('训练历史请求参数:', id, type);
try {
const res = await TrainingApi.getTrainHistoryList(id, type);
historyList.value = res.data;
const res = await TrainingApi.getTrainHistoryList(Number(id), Number(type));
historyList.value = res.data || [];
console.log('训练历史列表接口返回结果historyList.value', historyList.value);
} catch (error) {
console.error('加载训练历史失败:', error);
historyList.value = [];
}
};
// 格式化时间
... ...
... ... @@ -242,6 +242,7 @@ const loadsupersetsinfo = async () => {
// 页面跳转
const goToDetail = (id, type) => {
console.log('type=', type);
nextTick(() => {
actionDetailRef.value.open(id, type);
});
... ...
import request from '@/sheep/request';
const TrainingApi = {
//创建训练历史
creatTrainHistory:(data)=>{
return request({
url:'/app/training/history',
method:'POST',
data:data
});
},
// 获得训练历史
getTrainHistoryList: (id)=>{
return request({
url:'/app/training/history',
method:'GET',
params:{id}
});
}
}
//创建训练历史
creatTrainHistory: (data) => {
return request({
url: '/app/training/history',
method: 'POST',
data: data,
});
},
// 获得训练历史
getTrainHistoryList: (id, unitType) => {
return request({
url: '/app/training/history',
method: 'GET',
params: { id, unitType },
});
},
};
export default TrainingApi;
\ No newline at end of file
export default TrainingApi;
... ...