修正多处问题,添加骨架屏

This commit is contained in:
2026-06-29 16:41:36 +08:00
parent e85f39ab83
commit 13b99428de
124 changed files with 929 additions and 147 deletions
@@ -48,6 +48,8 @@ import { ref, onMounted } from 'vue'
import { onShow } from '@dcloudio/uni-app'
import { getActiveRecommendCourses } from '@/api/groupCourse.js'
import { getCourseCoverUrl } from '@/utils/request.js'
console.log('[TodayRecommend] 组件脚本已加载')
// 今日推荐数据列表
@@ -72,12 +74,7 @@ const getCourseLevel = (course) => {
return '初级'
}
// 处理图片URL
const getImageUrl = (coverImage) => {
if (!coverImage) return 'https://images.unsplash.com/photo-1571019613454-1cb2f99b2d8b?w=300&q=80'
if (coverImage.startsWith('http')) return coverImage
return `https://your-domain.com${coverImage}`
}
// 处理图片URL - 已由 getOssUrl 工具函数处理
// 获取今日推荐
const fetchTodayRecommend = async () => {
@@ -85,6 +82,10 @@ const fetchTodayRecommend = async () => {
try {
const res = await getActiveRecommendCourses()
console.log('[TodayRecommend] API 返回:', JSON.stringify(res).substring(0, 200))
if (res && Array.isArray(res) && res.length > 0) {
console.log('[TodayRecommend] 第一项 groupCourse.coverImage:', JSON.stringify(res[0]?.groupCourse?.coverImage))
console.log('[TodayRecommend] 第一项完整 groupCourse:', JSON.stringify(res[0]?.groupCourse))
}
if (res && Array.isArray(res)) {
// 提取推荐中的 groupCourse,只排除已满员的课程
const filteredCourses = res.filter(recommend => {
@@ -97,9 +98,17 @@ const fetchTodayRecommend = async () => {
recommends.value = filteredCourses.slice(0, 3).map(recommend => {
const course = recommend.groupCourse
const rawCover = course.coverImage
const finalImage = getCourseCoverUrl(rawCover) || 'https://images.unsplash.com/photo-1571019613454-1cb2f99b2d8b?w=300&q=80'
console.log('[TodayRecommend] 封面URL映射:', {
'courseName': course.courseName,
'原始coverImage': rawCover,
'转换后URL': finalImage,
'是否为完整URL': finalImage.startsWith('http')
})
return {
id: course.id,
image: getImageUrl(course.coverImage),
image: finalImage,
title: course.courseName || '未知课程',
tags: [calculateDuration(course.startTime, course.endTime), getCourseLevel(course)],
desc: course.description || '精彩课程,不容错过',