|
@@ -143,21 +143,21 @@ onMounted(() => {
|
|
|
if (res && res.data && Array.isArray(res.data)) {
|
|
if (res && res.data && Array.isArray(res.data)) {
|
|
|
// 保存原始API返回的数据
|
|
// 保存原始API返回的数据
|
|
|
resData.value = res.data;
|
|
resData.value = res.data;
|
|
|
- // 创建映射,保持原有的图片和位置样式
|
|
|
|
|
- const positionMap = {
|
|
|
|
|
- 1: { image: explanation, positionClass: 'left-content-box' },
|
|
|
|
|
- 2: { image: practice, positionClass: 'center-content-box' },
|
|
|
|
|
- 3: { image: summary, positionClass: 'right-content-box' }
|
|
|
|
|
|
|
+ // 创建图片映射,根据bcLabel显示对应图片
|
|
|
|
|
+ const imageMap = {
|
|
|
|
|
+ '1': explanation,
|
|
|
|
|
+ '2': practice,
|
|
|
|
|
+ '3': summary
|
|
|
}
|
|
}
|
|
|
// 遍历接口返回的数据,设置课程项
|
|
// 遍历接口返回的数据,设置课程项
|
|
|
res.data.forEach((item, index) => {
|
|
res.data.forEach((item, index) => {
|
|
|
// 每个课程项都对应位置样式和图片
|
|
// 每个课程项都对应位置样式和图片
|
|
|
const positionIndex = (index % 3) + 1
|
|
const positionIndex = (index % 3) + 1
|
|
|
- const positionInfo = positionMap[positionIndex]
|
|
|
|
|
|
|
+ const image = imageMap[item.bcLabel]; // 根据bcLabel获取图片
|
|
|
courseItems.value.push({
|
|
courseItems.value.push({
|
|
|
id: item.id,
|
|
id: item.id,
|
|
|
title: item.bcName,
|
|
title: item.bcName,
|
|
|
- image: positionInfo.image,
|
|
|
|
|
|
|
+ image: image,
|
|
|
contentType: item.bcContentType
|
|
contentType: item.bcContentType
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|