Authored by qxm

每日模板的修改功能和编辑功能,替换功能,动作组件

@@ -6,9 +6,9 @@ SHOPRO_VERSION=v2.4.1 @@ -6,9 +6,9 @@ SHOPRO_VERSION=v2.4.1
6 # SHOPRO_BASE_URL=http://mall.hcxtec.com 6 # SHOPRO_BASE_URL=http://mall.hcxtec.com
7 7
8 # 后端接口 - 测试环境(通过 process.env.NODE_ENV = development) 8 # 后端接口 - 测试环境(通过 process.env.NODE_ENV = development)
9 -SHOPRO_DEV_BASE_URL=http://192.168.1.200:48081 9 +#SHOPRO_DEV_BASE_URL=http://192.168.1.200:48081
10 # SHOPRO_DEV_BASE_URL=http://192.168.1.85:48080 10 # SHOPRO_DEV_BASE_URL=http://192.168.1.85:48080
11 -# SHOPRO_DEV_BASE_URL=https://fitness.hcxtec.com 11 +SHOPRO_DEV_BASE_URL=https:/xunji.geaktec.com
12 # SHOPRO_DEV_BASE_URL=http://api-dashboard.yudao.iocoder.cn/ 12 # SHOPRO_DEV_BASE_URL=http://api-dashboard.yudao.iocoder.cn/
13 ### SHOPRO_DEV_BASE_URL=http://10.171.1.188:48080 13 ### SHOPRO_DEV_BASE_URL=http://10.171.1.188:48080
14 ### SHOPRO_DEV_BASE_URL = http://yunai.natapp1.cc 14 ### SHOPRO_DEV_BASE_URL = http://yunai.natapp1.cc
1 { 1 {
2 - "name": "鸿星健身",  
3 - "appid": "__UNI__0A1E345", 2 + "name": "智能健身",
  3 + "appid": "__UNI__7CAA18B",
4 "description": "基于 uni-app + Vue3 技术驱动的在线商城系统,内含诸多功能与丰富的活动,期待您的使用和反馈。", 4 "description": "基于 uni-app + Vue3 技术驱动的在线商城系统,内含诸多功能与丰富的活动,期待您的使用和反馈。",
5 "versionName": "2025.10", 5 "versionName": "2025.10",
6 "versionCode": "183", 6 "versionCode": "183",
@@ -339,7 +339,7 @@ const hasWeightExercise = computed(() => { @@ -339,7 +339,7 @@ const hasWeightExercise = computed(() => {
339 339
340 // 删除动作 340 // 删除动作
341 const deleteAction = () => { 341 const deleteAction = () => {
342 - 342 + // 如何是每日模板的就返回一个删除印象
343 if (props.isDailyTemplates) { 343 if (props.isDailyTemplates) {
344 showTips.value = false; 344 showTips.value = false;
345 emit('deleteAction'); 345 emit('deleteAction');
@@ -274,6 +274,8 @@ const handleConfirm = async () => { @@ -274,6 +274,8 @@ const handleConfirm = async () => {
274 console.log("【完整选中动作】", selectedAction.value); 274 console.log("【完整选中动作】", selectedAction.value);
275 console.log("【当前store类型】", trainingStore.type); 275 console.log("【当前store类型】", trainingStore.type);
276 276
  277 + console.log('trainingStore.type=', trainingStore.type);
  278 +
277 // ============================================== 279 // ==============================================
278 // 【1】如果是模板训练 → 先请求详情,再修改 units 数组 280 // 【1】如果是模板训练 → 先请求详情,再修改 units 数组
279 // ============================================== 281 // ==============================================
@@ -295,7 +297,7 @@ const handleConfirm = async () => { @@ -295,7 +297,7 @@ const handleConfirm = async () => {
295 exerciseId: detail.id, 297 exerciseId: detail.id,
296 exerciseName: detail.name, 298 exerciseName: detail.name,
297 exerciseType: detail.exerciseType || 1, 299 exerciseType: detail.exerciseType || 1,
298 - urlImage: detail.url3dAnimation || detail.urlImage, 300 + urlImage: detail.url3dAnimation || detail.exerciseCover,
299 categoryDescription: detail.categoryDescription, 301 categoryDescription: detail.categoryDescription,
300 equipmentDescription: detail.equipmentDescription, 302 equipmentDescription: detail.equipmentDescription,
301 } 303 }
@@ -313,7 +315,7 @@ const handleConfirm = async () => { @@ -313,7 +315,7 @@ const handleConfirm = async () => {
313 exerciseId: e.id, 315 exerciseId: e.id,
314 exerciseName: e.name, 316 exerciseName: e.name,
315 exerciseType: e.exerciseType || 1, 317 exerciseType: e.exerciseType || 1,
316 - urlImage: e.url3dAnimation || e.urlImage, 318 + urlImage: e.url3dAnimation || e.exerciseCover,
317 // urlImage: e.urlImage || e.url3dAnimation, 319 // urlImage: e.urlImage || e.url3dAnimation,
318 })) 320 }))
319 }; 321 };
@@ -353,6 +355,8 @@ const handleConfirm = async () => { @@ -353,6 +355,8 @@ const handleConfirm = async () => {
353 selectedType.value 355 selectedType.value
354 ) 356 )
355 357
  358 +
  359 +
356 setTimeout(() => { 360 setTimeout(() => {
357 emit('close'); 361 emit('close');
358 }, 800); 362 }, 800);
@@ -199,7 +199,6 @@ @@ -199,7 +199,6 @@
199 </template> 199 </template>
200 </view> 200 </view>
201 </view> 201 </view>
202 -  
203 </view> 202 </view>
204 </view> 203 </view>
205 </view> 204 </view>
@@ -43,32 +43,43 @@ const isRenderDongzuo = ref(false) @@ -43,32 +43,43 @@ const isRenderDongzuo = ref(false)
43 // 标记是否需要删除当前动作组 43 // 标记是否需要删除当前动作组
44 const needDeleteUnit = ref(false) 44 const needDeleteUnit = ref(false)
45 45
46 -watch(  
47 - () => templateStore.replaceId,  
48 - (id) => {  
49 - if (id) {  
50 - needReplaceUnit.value = true  
51 - uni.showToast({  
52 - title: '已标记替换',  
53 - icon: 'success'  
54 - })  
55 - }  
56 - }  
57 -) 46 +// watch(
  47 +// () => templateStore.replaceId,
  48 +// (id) => {
  49 +// if (id) {
  50 +// needReplaceUnit.value = true
  51 +// uni.showToast({
  52 +// title: '已标记替换',
  53 +// icon: 'success'
  54 +// })
  55 +// }
  56 +// }
  57 +// )
58 58
59 // 原watch不动,补充拉取新数据、替换source.unit 59 // 原watch不动,补充拉取新数据、替换source.unit
60 watch( 60 watch(
61 () => templateStore.replaceId, 61 () => templateStore.replaceId,
62 async (id) => { 62 async (id) => {
63 if (id) { 63 if (id) {
  64 + console.log('+++++每日模板修改替换++++++');
64 needReplaceUnit.value = true 65 needReplaceUnit.value = true
65 uni.showToast({ title: '已标记替换', icon: 'success' }) 66 uni.showToast({ title: '已标记替换', icon: 'success' })
66 // 新增代码:拉取新动作,替换弹窗数据源,触发页面刷新 67 // 新增代码:拉取新动作,替换弹窗数据源,触发页面刷新
67 const rid = templateStore.replaceId 68 const rid = templateStore.replaceId
68 const rtype = templateStore.replaceType 69 const rtype = templateStore.replaceType
  70 +
  71 + console.log('rid=', rid, 'rtype=', rtype);
  72 +
69 let res, detail 73 let res, detail
70 - if (rtype === 1) res = await ExercisesApi.getExerciseById(rid)  
71 - else res = await SupersetsApi.getSupersetsInfo(rid) 74 + if (rtype === 1) {
  75 + res = await ExercisesApi.getExerciseById(rid)
  76 + console.log('每日模板res=', res);
  77 + }
  78 + else {
  79 + res = await SupersetsApi.getSupersetsInfo(rid)
  80 + console.log('每日模板res=', res);
  81 + }
  82 + console.log('每日模板res=', res);
72 detail = res.data 83 detail = res.data
73 // 拼装新unit覆盖原sourceInfo.unit 84 // 拼装新unit覆盖原sourceInfo.unit
74 let newUnit 85 let newUnit
@@ -77,11 +88,14 @@ watch( @@ -77,11 +88,14 @@ watch(
77 unitType: 1, unitId: detail.id, unitName: detail.name, 88 unitType: 1, unitId: detail.id, unitName: detail.name,
78 exercises: [{ exerciseId: detail.id, exerciseName: detail.name, exerciseType: detail.exerciseType, urlImage: detail.url3dAnimation || detail.urlImage, categoryDescription: detail.categoryDescription || '', equipmentDescription: detail.equipmentDescription || '', sets: [] }] 89 exercises: [{ exerciseId: detail.id, exerciseName: detail.name, exerciseType: detail.exerciseType, urlImage: detail.url3dAnimation || detail.urlImage, categoryDescription: detail.categoryDescription || '', equipmentDescription: detail.equipmentDescription || '', sets: [] }]
79 } 90 }
  91 + console.log('newUnit', newUnit);
  92 +
80 } else { 93 } else {
81 newUnit = { 94 newUnit = {
82 unitType: 2, unitId: detail.id, unitName: detail.name, 95 unitType: 2, unitId: detail.id, unitName: detail.name,
83 - exercises: detail.exercises.map(e => ({ exerciseId: e.id, exerciseName: e.name, exerciseType: e.exerciseType, urlImage: e.urlImage || e.url3dAnimation, sets: [] })) 96 + exercises: detail.exercises.map(e => ({ exerciseId: e.id, exerciseName: e.name, exerciseType: e.exerciseType, urlImage: e.url3dAnimation || e.exerciseCover, sets: [] }))
84 } 97 }
  98 + console.log('newUnit', newUnit);
85 } 99 }
86 sourceInfo.value.unit = newUnit 100 sourceInfo.value.unit = newUnit
87 // 销毁重建dongzuo实现刷新 101 // 销毁重建dongzuo实现刷新
@@ -146,7 +160,7 @@ const formatDongzuoData = (unit) => { @@ -146,7 +160,7 @@ const formatDongzuoData = (unit) => {
146 result = { 160 result = {
147 id: ex.exerciseId, 161 id: ex.exerciseId,
148 name: ex.exerciseName, 162 name: ex.exerciseName,
149 - urlImage: ex.url3dAnimation, 163 + urlImage: ex.url3dAnimation || ex.exerciseCover || ex.urlImage,
150 exerciseType: ex.exerciseType, 164 exerciseType: ex.exerciseType,
151 categoryDescription: ex.categoryDescription || '', 165 categoryDescription: ex.categoryDescription || '',
152 equipmentDescription: ex.equipmentDescription || '', 166 equipmentDescription: ex.equipmentDescription || '',
@@ -160,7 +174,7 @@ const formatDongzuoData = (unit) => { @@ -160,7 +174,7 @@ const formatDongzuoData = (unit) => {
160 exercises: unit.exercises?.map(ex => ({ 174 exercises: unit.exercises?.map(ex => ({
161 id: ex.exerciseId, 175 id: ex.exerciseId,
162 name: ex.exerciseName, 176 name: ex.exerciseName,
163 - urlImage: ex.url3dAnimation, 177 + urlImage: ex.url3dAnimation || ex.exerciseCover || ex.urlImage,
164 exerciseType: ex.exerciseType, 178 exerciseType: ex.exerciseType,
165 })) || [] 179 })) || []
166 } 180 }
@@ -255,6 +269,10 @@ const saveEdit = async () => { @@ -255,6 +269,10 @@ const saveEdit = async () => {
255 if (needDeleteUnit.value) { 269 if (needDeleteUnit.value) {
256 // 1. 复制所有 unit,删掉当前这个 270 // 1. 复制所有 unit,删掉当前这个
257 const allUnits = [...dailyTemplate.units] 271 const allUnits = [...dailyTemplate.units]
  272 + if (allUnits.length <= 1) {
  273 + uni.showToast({ title: '每日模板至少保留1个动作组,无法删除', icon: 'none' })
  274 + return
  275 + }
258 allUnits.splice(unitIndex, 1) 276 allUnits.splice(unitIndex, 1)
259 277
260 // 2. 调用你原来的保存接口 278 // 2. 调用你原来的保存接口
@@ -288,16 +306,19 @@ const saveEdit = async () => { @@ -288,16 +306,19 @@ const saveEdit = async () => {
288 let detail = null 306 let detail = null
289 307
290 // ====================== 308 // ======================
291 - // 👇 完全移植你现成的接口逻辑 309 + // 👇 完全移植你现成的接口逻辑(动作替换)
292 // ====================== 310 // ======================
293 if (replaceType === 1) { 311 if (replaceType === 1) {
294 // 普通动作 312 // 普通动作
295 const res = await ExercisesApi.getExerciseById(replaceId) 313 const res = await ExercisesApi.getExerciseById(replaceId)
296 detail = res.data 314 detail = res.data
  315 + console.log('detail=', detail);
  316 +
297 } else if (replaceType === 2) { 317 } else if (replaceType === 2) {
298 // 超级组 318 // 超级组
299 const res = await SupersetsApi.getSupersetsInfo(replaceId) 319 const res = await SupersetsApi.getSupersetsInfo(replaceId)
300 detail = res.data 320 detail = res.data
  321 + console.log('detail=', detail);
301 } 322 }
302 323
303 if (!detail) { 324 if (!detail) {
@@ -309,7 +330,6 @@ const saveEdit = async () => { @@ -309,7 +330,6 @@ const saveEdit = async () => {
309 // 组装 newUnit 330 // 组装 newUnit
310 // ====================== 331 // ======================
311 let newUnit = null 332 let newUnit = null
312 -  
313 if (replaceType === 1) { 333 if (replaceType === 1) {
314 newUnit = { 334 newUnit = {
315 unitType: 1, 335 unitType: 1,
@@ -320,7 +340,8 @@ const saveEdit = async () => { @@ -320,7 +340,8 @@ const saveEdit = async () => {
320 exerciseId: detail.id, 340 exerciseId: detail.id,
321 exerciseName: detail.name, 341 exerciseName: detail.name,
322 exerciseType: detail.exerciseType, 342 exerciseType: detail.exerciseType,
323 - urlImage: detail.urlImage || detail.url3dAnimation, 343 + urlImage: detail.url3dAnimation || detail.exerciseCover,
  344 + // urlImage: detail.urlImage || detail.url3dAnimation,
324 categoryDescription: detail.categoryDescription || '', 345 categoryDescription: detail.categoryDescription || '',
325 equipmentDescription: detail.equipmentDescription || '', 346 equipmentDescription: detail.equipmentDescription || '',
326 sets: [] 347 sets: []
@@ -336,7 +357,7 @@ const saveEdit = async () => { @@ -336,7 +357,7 @@ const saveEdit = async () => {
336 exerciseId: e.id, 357 exerciseId: e.id,
337 exerciseName: e.name, 358 exerciseName: e.name,
338 exerciseType: e.exerciseType, 359 exerciseType: e.exerciseType,
339 - urlImage: e.urlImage || e.url3dAnimation, 360 + urlImage: e.url3dAnimation || e.exerciseCover,
340 sets: [] 361 sets: []
341 })) 362 }))
342 } 363 }
@@ -356,6 +377,7 @@ const saveEdit = async () => { @@ -356,6 +377,7 @@ const saveEdit = async () => {
356 }) 377 })
357 378
358 uni.showToast({ title: '替换成功', icon: 'success' }) 379 uni.showToast({ title: '替换成功', icon: 'success' })
  380 + needReplaceUnit.value = false
359 emit('saveSuccess') 381 emit('saveSuccess')
360 closePop() 382 closePop()
361 return 383 return
@@ -368,6 +390,11 @@ const saveEdit = async () => { @@ -368,6 +390,11 @@ const saveEdit = async () => {
368 } 390 }
369 } 391 }
370 392
  393 +
  394 +
  395 +
  396 + // 动作替换
  397 +
371 let targetExercises = [...unit.exercises] 398 let targetExercises = [...unit.exercises]
372 if (unit.unitType === 1) { 399 if (unit.unitType === 1) {
373 // 单动作:exercises只有1个 400 // 单动作:exercises只有1个