hookehuyr

fix(HomePage): 修复精选课程评分显示和条件渲染问题

修复精选课程评分显示字段错误,将rating改为comment_score
修复精选课程人数统计字段错误,将ratingCount改为comment_count
添加精选课程列表空值判断,避免空数组时渲染组件
更新获取精选课程的API参数,从RMKC改为JXKC
<!--
* @Date: 2025-03-20 19:55:21
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-06-11 13:15:30
* @LastEditTime: 2025-06-11 13:20:30
* @FilePath: /mlaj/src/views/HomePage.vue
* @Description: 美乐爱觉教育首页组件
*
......@@ -178,7 +178,7 @@
</div> -->
<!-- Featured Courses Carousel -->
<div class="mb-6">
<div v-if="goodCourses.length" class="mb-6">
<div class="px-4 mb-2">
<h3 class="font-medium">精选课程</h3>
</div>
......@@ -212,14 +212,14 @@
v-for="i in 5"
:key="i"
xmlns="http://www.w3.org/2000/svg"
:class="[`h-4 w-4`, i <= course.rating ? 'text-amber-400' : 'text-gray-300']"
:class="[`h-4 w-4`, i <= course.comment_score ? 'text-amber-400' : 'text-gray-300']"
viewBox="0 0 20 20"
fill="currentColor"
>
<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" />
</svg>
</div>
<span class="text-white text-xs ml-1">{{ course.ratingCount }}人评</span>
<span class="text-white text-xs ml-1">{{ course.comment_count }}人评</span>
</div>
<router-link
:to="`/courses/${course.id}`"
......@@ -593,9 +593,9 @@ onMounted(async () => {
if (res2.code) {
hotCourses.value = res2.data
}
// TODO: 获取精选课程
// 获取精选课程
const res3 = await getCourseListAPI({
sn: 'RMKC', // JXKC
sn: 'JXKC',
limit: 4
})
if (res3.code) {
......