hookehuyr

fix: 修复学习记录页显示问题并调整热门课程数量

修改学习记录页的显示字段,使用后端返回的格式化数据替代前端计算
调整热门课程获取数量从4增加到8
修复分页初始值错误问题
<!--
* @Date: 2025-03-20 19:55:21
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-06-11 13:20:30
* @LastEditTime: 2025-06-11 17:10:09
* @FilePath: /mlaj/src/views/HomePage.vue
* @Description: 美乐爱觉教育首页组件
*
......@@ -577,7 +577,6 @@ const checkInTypes = ref([]);
// 自动轮播
let carouselInterval
onMounted(async () => {
// 获取课程列表
const res = await getCourseListAPI({ sn: 'RMKC' })
if (res.code) {
......@@ -588,7 +587,7 @@ onMounted(async () => {
// 获取热门课程
const res2 = await getCourseListAPI({
sn: 'RMKC',
limit: 4
limit: 8
})
if (res2.code) {
hotCourses.value = res2.data
......
......@@ -47,7 +47,7 @@
d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"
/>
</svg>
<span>学习时长:{{ formatDuration(record.study_duration) }}</span>
<span>学习时长:{{ record.study_duration_desc }}</span>
</div>
<div class="flex items-center text-sm text-gray-500 mb-3">
<svg
......@@ -64,12 +64,12 @@
d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"
/>
</svg>
<span>最近学习:{{ formatDate(record.recent_study_time) }}</span>
<span>最近学习:{{ record.recent_study_time }}</span>
</div>
<div class="flex items-center">
<div class="flex-1">
<van-progress
:percentage="record.study_progress"
:percentage="record.record_progress"
:stroke-width="4"
color="#10B981"
/>
......@@ -110,7 +110,7 @@ import { ref } from 'vue';
import { useRoute } from 'vue-router';
import { useTitle } from '@vueuse/core';
import FrostedGlass from '@/components/ui/FrostedGlass.vue';
import { formatDate, formatDuration } from '@/utils/tools';
import { formatDate } from '@/utils/tools';
// 导入接口
import { getStudyRecordListAPI } from "@/api/record";
......@@ -121,7 +121,7 @@ useTitle($route.meta.title);
const records = ref([]);
const loading = ref(false);
const finished = ref(false);
const page = ref(1);
const page = ref(0);
const limit = ref(10);
const finishText = ref('没有更多了');
......@@ -135,6 +135,9 @@ const onLoad = async () => {
page: nextPage,
});
if (code) {
data.forEach((item) => {
item.record_progress = Math.floor((item?.study_count/item?.count)*100);
});
records.value.push(...data);
finished.value = data.length < limit.value;
page.value = nextPage + 1;
......