hookehuyr

refactor(首页): 移除夏令营推广区块并改用API获取精选课程数据

- 注释掉静态夏令营推广区块代码
- 从API获取精选课程数据替换原有模拟数据
- 更新轮播逻辑使用精选课程数据
- 更新课程封面图片字段匹配API返回格式
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-09 16:10:07 4 + * @LastEditTime: 2025-06-11 13:15:30
5 * @FilePath: /mlaj/src/views/HomePage.vue 5 * @FilePath: /mlaj/src/views/HomePage.vue
6 * @Description: 美乐爱觉教育首页组件 6 * @Description: 美乐爱觉教育首页组件
7 * 7 *
...@@ -142,7 +142,7 @@ ...@@ -142,7 +142,7 @@
142 </div> 142 </div>
143 143
144 <!-- Summer Camp Promotion --> 144 <!-- Summer Camp Promotion -->
145 - <div class="px-4 mb-6"> 145 + <!-- <div class="px-4 mb-6">
146 <SummerCampCard :items="[ 146 <SummerCampCard :items="[
147 { 147 {
148 title: '大国少年-世界正东方', 148 title: '大国少年-世界正东方',
...@@ -175,7 +175,7 @@ ...@@ -175,7 +175,7 @@
175 imageUrl: 'https://cdn.ipadbiz.cn/mlaj/images/summer-camp-3.jpg' 175 imageUrl: 'https://cdn.ipadbiz.cn/mlaj/images/summer-camp-3.jpg'
176 } 176 }
177 ]" /> 177 ]" />
178 - </div> 178 + </div> -->
179 179
180 <!-- Featured Courses Carousel --> 180 <!-- Featured Courses Carousel -->
181 <div class="mb-6"> 181 <div class="mb-6">
...@@ -189,13 +189,13 @@ ...@@ -189,13 +189,13 @@
189 style="scrollbar-width: none; -ms-overflow-style: none;" 189 style="scrollbar-width: none; -ms-overflow-style: none;"
190 > 190 >
191 <div 191 <div
192 - v-for="(course, index) in courses.slice(0, 4)" 192 + v-for="(course, index) in goodCourses"
193 :key="course.id" 193 :key="course.id"
194 class="flex-shrink-0 w-full snap-center px-4" 194 class="flex-shrink-0 w-full snap-center px-4"
195 > 195 >
196 <div class="relative rounded-xl overflow-hidden shadow-lg h-48"> 196 <div class="relative rounded-xl overflow-hidden shadow-lg h-48">
197 <img 197 <img
198 - :src="course.imageUrl || 'https://cdn.ipadbiz.cn/mlaj/images/featured-course.jpg'" 198 + :src="course.cover || 'https://cdn.ipadbiz.cn/mlaj/images/default_block.png'"
199 :alt="course.title" 199 :alt="course.title"
200 class="w-full h-full object-cover" 200 class="w-full h-full object-cover"
201 /> 201 />
...@@ -236,7 +236,7 @@ ...@@ -236,7 +236,7 @@
236 <!-- Carousel Indicators --> 236 <!-- Carousel Indicators -->
237 <div class="flex justify-center mt-4"> 237 <div class="flex justify-center mt-4">
238 <button 238 <button
239 - v-for="(_, index) in courses.slice(0, 4)" 239 + v-for="(_, index) in goodCourses.slice(0, 4)"
240 :key="index" 240 :key="index"
241 @click="scrollToSlide(index)" 241 @click="scrollToSlide(index)"
242 :class="[ 242 :class="[
...@@ -522,7 +522,7 @@ import SummerCampCard from '@/components/ui/SummerCampCard.vue' ...@@ -522,7 +522,7 @@ import SummerCampCard from '@/components/ui/SummerCampCard.vue'
522 import VideoPlayer from '@/components/ui/VideoPlayer.vue' 522 import VideoPlayer from '@/components/ui/VideoPlayer.vue'
523 523
524 // 导入模拟数据和工具函数 524 // 导入模拟数据和工具函数
525 -import { courses, liveStreams, activities } from '@/utils/mockData' 525 +import { liveStreams, activities } from '@/utils/mockData'
526 import { useTitle } from '@vueuse/core' 526 import { useTitle } from '@vueuse/core'
527 import { useAuth } from '@/contexts/auth' 527 import { useAuth } from '@/contexts/auth'
528 import { showToast } from 'vant' 528 import { showToast } from 'vant'
...@@ -561,6 +561,7 @@ const displayedRecommendations = ref([]) // 当前显示的推荐内容 ...@@ -561,6 +561,7 @@ const displayedRecommendations = ref([]) // 当前显示的推荐内容
561 // 561 //
562 const userRecommendations = ref([]) 562 const userRecommendations = ref([])
563 const hotCourses = ref([]) 563 const hotCourses = ref([])
564 +const goodCourses = ref([])
564 // 获取推荐内容 565 // 获取推荐内容
565 const getRecommendations = (random = false) => { 566 const getRecommendations = (random = false) => {
566 if (random) { 567 if (random) {
...@@ -576,13 +577,7 @@ const checkInTypes = ref([]); ...@@ -576,13 +577,7 @@ const checkInTypes = ref([]);
576 // 自动轮播 577 // 自动轮播
577 let carouselInterval 578 let carouselInterval
578 onMounted(async () => { 579 onMounted(async () => {
579 - carouselInterval = setInterval(() => { 580 +
580 - if (carouselRef.value) {
581 - const nextSlide = (currentSlide.value + 1) % courses.slice(0, 4).length
582 - scrollToSlide(nextSlide)
583 - }
584 - }, 5000)
585 - // TODO: 模拟获取用户推荐内容
586 // 获取课程列表 581 // 获取课程列表
587 const res = await getCourseListAPI({ sn: 'RMKC' }) 582 const res = await getCourseListAPI({ sn: 'RMKC' })
588 if (res.code) { 583 if (res.code) {
...@@ -598,6 +593,20 @@ onMounted(async () => { ...@@ -598,6 +593,20 @@ onMounted(async () => {
598 if (res2.code) { 593 if (res2.code) {
599 hotCourses.value = res2.data 594 hotCourses.value = res2.data
600 } 595 }
596 + // TODO: 获取精选课程
597 + const res3 = await getCourseListAPI({
598 + sn: 'RMKC', // JXKC
599 + limit: 4
600 + })
601 + if (res3.code) {
602 + goodCourses.value = res3.data
603 + carouselInterval = setInterval(() => {
604 + if (carouselRef.value) {
605 + const nextSlide = (currentSlide.value + 1) % goodCourses.value.slice(0, 4).length
606 + scrollToSlide(nextSlide)
607 + }
608 + }, 5000)
609 + }
601 610
602 // 获取签到列表 611 // 获取签到列表
603 if(currentUser.value) { 612 if(currentUser.value) {
......