Authored by qxm

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

... ... @@ -6,9 +6,9 @@ SHOPRO_VERSION=v2.4.1
# SHOPRO_BASE_URL=http://mall.hcxtec.com
# 后端接口 - 测试环境(通过 process.env.NODE_ENV = development)
SHOPRO_DEV_BASE_URL=http://192.168.1.200:48081
#SHOPRO_DEV_BASE_URL=http://192.168.1.200:48081
# SHOPRO_DEV_BASE_URL=http://192.168.1.85:48080
# SHOPRO_DEV_BASE_URL=https://fitness.hcxtec.com
SHOPRO_DEV_BASE_URL=https:/xunji.geaktec.com
# SHOPRO_DEV_BASE_URL=http://api-dashboard.yudao.iocoder.cn/
### SHOPRO_DEV_BASE_URL=http://10.171.1.188:48080
### SHOPRO_DEV_BASE_URL = http://yunai.natapp1.cc
... ...
{
"name": "鸿星健身",
"appid": "__UNI__0A1E345",
"name": "智能健身",
"appid": "__UNI__7CAA18B",
"description": "基于 uni-app + Vue3 技术驱动的在线商城系统,内含诸多功能与丰富的活动,期待您的使用和反馈。",
"versionName": "2025.10",
"versionCode": "183",
... ...
... ... @@ -339,7 +339,7 @@ const hasWeightExercise = computed(() => {
// 删除动作
const deleteAction = () => {
// 如何是每日模板的就返回一个删除印象
if (props.isDailyTemplates) {
showTips.value = false;
emit('deleteAction');
... ...
... ... @@ -274,6 +274,8 @@ const handleConfirm = async () => {
console.log("【完整选中动作】", selectedAction.value);
console.log("【当前store类型】", trainingStore.type);
console.log('trainingStore.type=', trainingStore.type);
// ==============================================
// 【1】如果是模板训练 → 先请求详情,再修改 units 数组
// ==============================================
... ... @@ -295,7 +297,7 @@ const handleConfirm = async () => {
exerciseId: detail.id,
exerciseName: detail.name,
exerciseType: detail.exerciseType || 1,
urlImage: detail.url3dAnimation || detail.urlImage,
urlImage: detail.url3dAnimation || detail.exerciseCover,
categoryDescription: detail.categoryDescription,
equipmentDescription: detail.equipmentDescription,
}
... ... @@ -313,7 +315,7 @@ const handleConfirm = async () => {
exerciseId: e.id,
exerciseName: e.name,
exerciseType: e.exerciseType || 1,
urlImage: e.url3dAnimation || e.urlImage,
urlImage: e.url3dAnimation || e.exerciseCover,
// urlImage: e.urlImage || e.url3dAnimation,
}))
};
... ... @@ -353,6 +355,8 @@ const handleConfirm = async () => {
selectedType.value
)
setTimeout(() => {
emit('close');
}, 800);
... ...
... ... @@ -199,7 +199,6 @@
</template>
</view>
</view>
</view>
</view>
</view>
... ...
... ... @@ -43,32 +43,43 @@ const isRenderDongzuo = ref(false)
// 标记是否需要删除当前动作组
const needDeleteUnit = ref(false)
watch(
() => templateStore.replaceId,
(id) => {
if (id) {
needReplaceUnit.value = true
uni.showToast({
title: '已标记替换',
icon: 'success'
})
}
}
)
// watch(
// () => templateStore.replaceId,
// (id) => {
// if (id) {
// needReplaceUnit.value = true
// uni.showToast({
// title: '已标记替换',
// icon: 'success'
// })
// }
// }
// )
// 原watch不动,补充拉取新数据、替换source.unit
watch(
() => templateStore.replaceId,
async (id) => {
if (id) {
console.log('+++++每日模板修改替换++++++');
needReplaceUnit.value = true
uni.showToast({ title: '已标记替换', icon: 'success' })
// 新增代码:拉取新动作,替换弹窗数据源,触发页面刷新
const rid = templateStore.replaceId
const rtype = templateStore.replaceType
console.log('rid=', rid, 'rtype=', rtype);
let res, detail
if (rtype === 1) res = await ExercisesApi.getExerciseById(rid)
else res = await SupersetsApi.getSupersetsInfo(rid)
if (rtype === 1) {
res = await ExercisesApi.getExerciseById(rid)
console.log('每日模板res=', res);
}
else {
res = await SupersetsApi.getSupersetsInfo(rid)
console.log('每日模板res=', res);
}
console.log('每日模板res=', res);
detail = res.data
// 拼装新unit覆盖原sourceInfo.unit
let newUnit
... ... @@ -77,11 +88,14 @@ watch(
unitType: 1, unitId: detail.id, unitName: detail.name,
exercises: [{ exerciseId: detail.id, exerciseName: detail.name, exerciseType: detail.exerciseType, urlImage: detail.url3dAnimation || detail.urlImage, categoryDescription: detail.categoryDescription || '', equipmentDescription: detail.equipmentDescription || '', sets: [] }]
}
console.log('newUnit', newUnit);
} else {
newUnit = {
unitType: 2, unitId: detail.id, unitName: detail.name,
exercises: detail.exercises.map(e => ({ exerciseId: e.id, exerciseName: e.name, exerciseType: e.exerciseType, urlImage: e.urlImage || e.url3dAnimation, sets: [] }))
exercises: detail.exercises.map(e => ({ exerciseId: e.id, exerciseName: e.name, exerciseType: e.exerciseType, urlImage: e.url3dAnimation || e.exerciseCover, sets: [] }))
}
console.log('newUnit', newUnit);
}
sourceInfo.value.unit = newUnit
// 销毁重建dongzuo实现刷新
... ... @@ -146,7 +160,7 @@ const formatDongzuoData = (unit) => {
result = {
id: ex.exerciseId,
name: ex.exerciseName,
urlImage: ex.url3dAnimation,
urlImage: ex.url3dAnimation || ex.exerciseCover || ex.urlImage,
exerciseType: ex.exerciseType,
categoryDescription: ex.categoryDescription || '',
equipmentDescription: ex.equipmentDescription || '',
... ... @@ -160,7 +174,7 @@ const formatDongzuoData = (unit) => {
exercises: unit.exercises?.map(ex => ({
id: ex.exerciseId,
name: ex.exerciseName,
urlImage: ex.url3dAnimation,
urlImage: ex.url3dAnimation || ex.exerciseCover || ex.urlImage,
exerciseType: ex.exerciseType,
})) || []
}
... ... @@ -255,6 +269,10 @@ const saveEdit = async () => {
if (needDeleteUnit.value) {
// 1. 复制所有 unit,删掉当前这个
const allUnits = [...dailyTemplate.units]
if (allUnits.length <= 1) {
uni.showToast({ title: '每日模板至少保留1个动作组,无法删除', icon: 'none' })
return
}
allUnits.splice(unitIndex, 1)
// 2. 调用你原来的保存接口
... ... @@ -288,16 +306,19 @@ const saveEdit = async () => {
let detail = null
// ======================
// 👇 完全移植你现成的接口逻辑
// 👇 完全移植你现成的接口逻辑(动作替换)
// ======================
if (replaceType === 1) {
// 普通动作
const res = await ExercisesApi.getExerciseById(replaceId)
detail = res.data
console.log('detail=', detail);
} else if (replaceType === 2) {
// 超级组
const res = await SupersetsApi.getSupersetsInfo(replaceId)
detail = res.data
console.log('detail=', detail);
}
if (!detail) {
... ... @@ -309,7 +330,6 @@ const saveEdit = async () => {
// 组装 newUnit
// ======================
let newUnit = null
if (replaceType === 1) {
newUnit = {
unitType: 1,
... ... @@ -320,7 +340,8 @@ const saveEdit = async () => {
exerciseId: detail.id,
exerciseName: detail.name,
exerciseType: detail.exerciseType,
urlImage: detail.urlImage || detail.url3dAnimation,
urlImage: detail.url3dAnimation || detail.exerciseCover,
// urlImage: detail.urlImage || detail.url3dAnimation,
categoryDescription: detail.categoryDescription || '',
equipmentDescription: detail.equipmentDescription || '',
sets: []
... ... @@ -336,7 +357,7 @@ const saveEdit = async () => {
exerciseId: e.id,
exerciseName: e.name,
exerciseType: e.exerciseType,
urlImage: e.urlImage || e.url3dAnimation,
urlImage: e.url3dAnimation || e.exerciseCover,
sets: []
}))
}
... ... @@ -356,6 +377,7 @@ const saveEdit = async () => {
})
uni.showToast({ title: '替换成功', icon: 'success' })
needReplaceUnit.value = false
emit('saveSuccess')
closePop()
return
... ... @@ -368,6 +390,11 @@ const saveEdit = async () => {
}
}
// 动作替换
let targetExercises = [...unit.exercises]
if (unit.unitType === 1) {
// 单动作:exercises只有1个
... ...