fix(HomePage): 修复精选课程评分显示和条件渲染问题
修复精选课程评分显示字段错误,将rating改为comment_score 修复精选课程人数统计字段错误,将ratingCount改为comment_count 添加精选课程列表空值判断,避免空数组时渲染组件 更新获取精选课程的API参数,从RMKC改为JXKC
Showing
1 changed file
with
6 additions
and
6 deletions
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2025-03-20 19:55:21 | 2 | * @Date: 2025-03-20 19:55:21 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-06-11 13:15:30 | 4 | + * @LastEditTime: 2025-06-11 13:20:30 |
| 5 | * @FilePath: /mlaj/src/views/HomePage.vue | 5 | * @FilePath: /mlaj/src/views/HomePage.vue |
| 6 | * @Description: 美乐爱觉教育首页组件 | 6 | * @Description: 美乐爱觉教育首页组件 |
| 7 | * | 7 | * |
| ... | @@ -178,7 +178,7 @@ | ... | @@ -178,7 +178,7 @@ |
| 178 | </div> --> | 178 | </div> --> |
| 179 | 179 | ||
| 180 | <!-- Featured Courses Carousel --> | 180 | <!-- Featured Courses Carousel --> |
| 181 | - <div class="mb-6"> | 181 | + <div v-if="goodCourses.length" class="mb-6"> |
| 182 | <div class="px-4 mb-2"> | 182 | <div class="px-4 mb-2"> |
| 183 | <h3 class="font-medium">精选课程</h3> | 183 | <h3 class="font-medium">精选课程</h3> |
| 184 | </div> | 184 | </div> |
| ... | @@ -212,14 +212,14 @@ | ... | @@ -212,14 +212,14 @@ |
| 212 | v-for="i in 5" | 212 | v-for="i in 5" |
| 213 | :key="i" | 213 | :key="i" |
| 214 | xmlns="http://www.w3.org/2000/svg" | 214 | xmlns="http://www.w3.org/2000/svg" |
| 215 | - :class="[`h-4 w-4`, i <= course.rating ? 'text-amber-400' : 'text-gray-300']" | 215 | + :class="[`h-4 w-4`, i <= course.comment_score ? 'text-amber-400' : 'text-gray-300']" |
| 216 | viewBox="0 0 20 20" | 216 | viewBox="0 0 20 20" |
| 217 | fill="currentColor" | 217 | fill="currentColor" |
| 218 | > | 218 | > |
| 219 | <path d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z" /> | 219 | <path d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z" /> |
| 220 | </svg> | 220 | </svg> |
| 221 | </div> | 221 | </div> |
| 222 | - <span class="text-white text-xs ml-1">{{ course.ratingCount }}人评</span> | 222 | + <span class="text-white text-xs ml-1">{{ course.comment_count }}人评</span> |
| 223 | </div> | 223 | </div> |
| 224 | <router-link | 224 | <router-link |
| 225 | :to="`/courses/${course.id}`" | 225 | :to="`/courses/${course.id}`" |
| ... | @@ -593,9 +593,9 @@ onMounted(async () => { | ... | @@ -593,9 +593,9 @@ onMounted(async () => { |
| 593 | if (res2.code) { | 593 | if (res2.code) { |
| 594 | hotCourses.value = res2.data | 594 | hotCourses.value = res2.data |
| 595 | } | 595 | } |
| 596 | - // TODO: 获取精选课程 | 596 | + // 获取精选课程 |
| 597 | const res3 = await getCourseListAPI({ | 597 | const res3 = await getCourseListAPI({ |
| 598 | - sn: 'RMKC', // JXKC | 598 | + sn: 'JXKC', |
| 599 | limit: 4 | 599 | limit: 4 |
| 600 | }) | 600 | }) |
| 601 | if (res3.code) { | 601 | if (res3.code) { | ... | ... |
-
Please register or login to post a comment