Authored by qxm

训计的替换

@@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
4 <view class="top-bar"> 4 <view class="top-bar">
5 <view class="month-picker"> 5 <view class="month-picker">
6 <uni-datetime-picker type="date" v-model="currentMonth" :clear-icon="false" /> 6 <uni-datetime-picker type="date" v-model="currentMonth" :clear-icon="false" />
  7 + <up-icon name="arrow-down" color="#333" size="15"></up-icon>
7 </view> 8 </view>
8 <view class="action-buttons"> 9 <view class="action-buttons">
9 <button class="action-btn" @click="ShowExplainPopup = true">说明</button> 10 <button class="action-btn" @click="ShowExplainPopup = true">说明</button>
@@ -341,6 +342,7 @@ const selectDate = async (date) => { @@ -341,6 +342,7 @@ const selectDate = async (date) => {
341 border-radius: 50rpx; 342 border-radius: 50rpx;
342 overflow: hidden; 343 overflow: hidden;
343 padding: 0 20rpx; 344 padding: 0 20rpx;
  345 + gap: 10rpx;
344 346
345 :deep(.uni-date-x--border) { 347 :deep(.uni-date-x--border) {
346 border: none !important; 348 border: none !important;
@@ -280,6 +280,7 @@ @@ -280,6 +280,7 @@
280 url: `/pages4/pages/xunji/xunji-xunlian-jihua?planid=${plan.id}`, 280 url: `/pages4/pages/xunji/xunji-xunlian-jihua?planid=${plan.id}`,
281 }); 281 });
282 }; 282 };
  283 +
283 // ====== 返回按钮 ====== 284 // ====== 返回按钮 ======
284 const back = () => { 285 const back = () => {
285 const pages = getCurrentPages(); 286 const pages = getCurrentPages();
@@ -170,35 +170,35 @@ @@ -170,35 +170,35 @@
170 170
171 <!-- 2. 超级组:按【组号】循环(取第一个动作的组数作为总组数) --> 171 <!-- 2. 超级组:按【组号】循环(取第一个动作的组数作为总组数) -->
172 <view class="super-set-list"> 172 <view class="super-set-list">
173 - <view v-for="(setItem, idx) in (unit.exercises[0]?.sets || [])" :key="idx" class="super-set-item">  
174 - <text class="detail-label">{{ idx + 1 }}</text> 173 + <view v-for="idx in getSuperSetMaxGroupCount(unit.exercises)" :key="idx" class="super-set-item">
  174 + <text class="detail-label">{{ idx }}</text>
175 <view class="set-column"> 175 <view class="set-column">
176 <!-- 遍历当前组下的每一个动作 --> 176 <!-- 遍历当前组下的每一个动作 -->
177 <view v-for="(ex, exIdx) in unit.exercises" :key="ex.exerciseId" class="action-in-set"> 177 <view v-for="(ex, exIdx) in unit.exercises" :key="ex.exerciseId" class="action-in-set">
178 <!-- 容错:当前动作无该组则不渲染 --> 178 <!-- 容错:当前动作无该组则不渲染 -->
179 - <template v-if="ex.sets[idx]"> 179 + <template v-if="ex.sets[idx - 1]">
180 <view class="action-letter"> 180 <view class="action-letter">
181 - {{ idx + 1 }}{{ String.fromCharCode(65 + exIdx) }} 181 + {{ idx }}{{ String.fromCharCode(65 + exIdx) }}
182 </view> 182 </view>
183 <view class="set-content"> 183 <view class="set-content">
184 <!-- 复用你原有的 动作类型 文本逻辑 --> 184 <!-- 复用你原有的 动作类型 文本逻辑 -->
185 <text v-if="[0, 4, 5].includes(ex.exerciseType)"> 185 <text v-if="[0, 4, 5].includes(ex.exerciseType)">
186 - {{ ex.sets[idx].weight }}kg × {{ ex.sets[idx].reps }}次 186 + {{ ex.sets[idx - 1].weight }}kg × {{ ex.sets[idx - 1].reps }}次
187 </text> 187 </text>
188 <text v-if="ex.exerciseType === 1"> 188 <text v-if="ex.exerciseType === 1">
189 - {{ ex.sets[idx].distance }}km x {{ formatSeconds(ex.sets[idx].duration) }} 189 + {{ ex.sets[idx - 1].distance }}km x {{ formatSeconds(ex.sets[idx - 1].duration) }}
190 </text> 190 </text>
191 <text v-if="ex.exerciseType === 2"> 191 <text v-if="ex.exerciseType === 2">
192 - {{ ex.sets[idx].reps }}次 192 + {{ ex.sets[idx - 1].reps }}次
193 </text> 193 </text>
194 <text v-if="ex.exerciseType === 3"> 194 <text v-if="ex.exerciseType === 3">
195 - {{ ex.sets[idx].duration }}次 195 + {{ ex.sets[idx - 1].duration }}次
196 </text> 196 </text>
197 <text v-if="ex.exerciseType === 6"> 197 <text v-if="ex.exerciseType === 6">
198 - {{ ex.sets[idx].duration }}组 x {{ formatSeconds(ex.sets[idx].duration) }} 198 + {{ ex.sets[idx - 1].duration }}组 x {{ formatSeconds(ex.sets[idx - 1].duration) }}
199 </text> 199 </text>
200 - <view class="rest" v-if="ex.sets[idx].restTime">  
201 - {{ ex.sets[idx].restTime }}s 200 + <view class="rest" v-if="ex.sets[idx - 1].restTime">
  201 + {{ ex.sets[idx - 1].restTime }}s
202 </view> 202 </view>
203 </view> 203 </view>
204 </template> 204 </template>
@@ -378,6 +378,15 @@ const openColorPopup = () => { @@ -378,6 +378,15 @@ const openColorPopup = () => {
378 showColorPopup.value = true 378 showColorPopup.value = true
379 } 379 }
380 380
  381 +// 获取超级组内所有动作中最大的组数
  382 +const getSuperSetMaxGroupCount = (exercises) => {
  383 + if (!Array.isArray(exercises) || exercises.length === 0) return 0
  384 + return exercises.reduce((max, ex) => {
  385 + const len = Array.isArray(ex.sets) ? ex.sets.length : 0
  386 + return Math.max(max, len)
  387 + }, 0)
  388 +}
  389 +
381 390
382 // 391 //
383 const handleUnitClick = (unit) => { 392 const handleUnitClick = (unit) => {
@@ -105,11 +105,14 @@ @@ -105,11 +105,14 @@
105 <button type="default" size="mini" class="btn" 105 <button type="default" size="mini" class="btn"
106 style="background-color: #333; color: white; border-radius: 20rpx" 106 style="background-color: #333; color: white; border-radius: 20rpx"
107 @click.stop="openCalendarPopup(plandetail.id, item.id)">添加到日历</button> 107 @click.stop="openCalendarPopup(plandetail.id, item.id)">添加到日历</button>
  108 +
108 <button type="primary" size="mini" class="btn" 109 <button type="primary" size="mini" class="btn"
109 - style="background-color: #ffd700; color: black; border-radius: 20rpx" @click.stop> 110 + style="background-color: #ffd700; color: black; border-radius: 20rpx"
  111 + @click.stop="startTraining(item.id)">
110 <text>去训练</text> 112 <text>去训练</text>
111 <view class="go-text">GO</view> 113 <view class="go-text">GO</view>
112 </button> 114 </button>
  115 +
113 </view> 116 </view>
114 </view> 117 </view>
115 </view> 118 </view>
@@ -195,6 +198,9 @@ import { onLoad, onShareAppMessage } from '@dcloudio/uni-app'; @@ -195,6 +198,9 @@ import { onLoad, onShareAppMessage } from '@dcloudio/uni-app';
195 import AddToCalendarPopup from '@/pages/xunji/components/tianjia-dao-rili.vue'; 198 import AddToCalendarPopup from '@/pages/xunji/components/tianjia-dao-rili.vue';
196 import WodeJihuaTianjiaTancuang from '@/pages/xunji/components/wode-jihua-tianjia-tancuang.vue' 199 import WodeJihuaTianjiaTancuang from '@/pages/xunji/components/wode-jihua-tianjia-tancuang.vue'
197 import WeekSelectPopup from '@/pages4/components/week-select-popup.vue' 200 import WeekSelectPopup from '@/pages4/components/week-select-popup.vue'
  201 +import { useTrainingStore } from '@/sheep/store/trainingStore'
  202 +
  203 +const trainingStore = useTrainingStore()
198 204
199 // 获取页面参数 205 // 获取页面参数
200 const route = defineProps(['planid']); // Vue 3 + uni-app 支持 206 const route = defineProps(['planid']); // Vue 3 + uni-app 支持
@@ -304,6 +310,17 @@ const openArrageClass = () => { @@ -304,6 +310,17 @@ const openArrageClass = () => {
304 }) 310 })
305 } 311 }
306 312
  313 +// 开始训练
  314 +const startTraining = (templateId) => {
  315 +
  316 + trainingStore.isSystem = 1;
  317 + uni.navigateTo({
  318 + url: `/pages4/pages/xunji/xunji-dongzuo-lianxi?id=${templateId}&type=3`,
  319 + });
  320 + console.log('打印传递给动作训练页面的模板id', templateId);
  321 +
  322 +};
  323 +
307 //查看模板详情 324 //查看模板详情
308 const openTemplateDatil = (templateId, dateArr) => { 325 const openTemplateDatil = (templateId, dateArr) => {
309 console.log('templateId=', templateId); 326 console.log('templateId=', templateId);