|
@@ -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个
|