diff --git a/src/api/course.ts b/src/api/course.ts index a704d26..cbd1701 100644 --- a/src/api/course.ts +++ b/src/api/course.ts @@ -16,3 +16,8 @@ export function record(courseId: number, hourId: number, duration: number) { duration, }); } + +//最近学习课程 +export function latestLearn() { + return client.get(`/api/v1/user/latest-learn`, {}); +} diff --git a/src/pages/course/compenents/hour.tsx b/src/pages/course/compenents/hour.tsx index 9e2f918..9f1ddbf 100644 --- a/src/pages/course/compenents/hour.tsx +++ b/src/pages/course/compenents/hour.tsx @@ -74,7 +74,7 @@ export const HourCompenent: React.FC = ({ )} )} - {progress === 100 &&
已学完
} + {progress >= 100 &&
已学完
} ); diff --git a/src/pages/course/index.tsx b/src/pages/course/index.tsx index 49a6bb0..537a591 100644 --- a/src/pages/course/index.tsx +++ b/src/pages/course/index.tsx @@ -56,7 +56,7 @@ const CoursePage = () => { {course.is_required === 0 && (
选修课
)} - {learnRecord.progress === 100 && ( + {learnRecord.progress / 100 === 100 && (
{ trailColor="#F6F6F6" size={90} strokeWidth={8} - percent={learnRecord.progress} + percent={learnRecord.progress / 100} format={(percent) => `${percent}%`} /> )} diff --git a/src/pages/latest-learn/index.module.scss b/src/pages/latest-learn/index.module.scss index e69de29..be44757 100644 --- a/src/pages/latest-learn/index.module.scss +++ b/src/pages/latest-learn/index.module.scss @@ -0,0 +1,19 @@ +.content { + width: 1200px; + min-height: 581px; + height: auto; + margin: 0 auto; + box-sizing: border-box; + padding: 50px 0; +} +.extra { + width: 1200px; + margin: 0 auto; + margin-top: 80px; + text-align: center; + height: 40px; + font-size: 16px; + font-weight: 400; + color: rgba(0, 0, 0, 0.2); + line-height: 40px; +} diff --git a/src/pages/latest-learn/index.tsx b/src/pages/latest-learn/index.tsx index a83a007..0da0605 100644 --- a/src/pages/latest-learn/index.tsx +++ b/src/pages/latest-learn/index.tsx @@ -1,7 +1,43 @@ +import React, { useState, useEffect } from "react"; import styles from "./index.module.scss"; +import { course } from "../../api/index"; +import { Row, Col, Empty, Spin, Image } from "antd"; const LatestLearnPage = () => { - return <>最近学习; + const [loading, setLoading] = useState(false); + const [courses, setCourses] = useState([]); + + useEffect(() => { + getCourses(); + }, []); + + const getCourses = () => { + setLoading(true); + course.latestLearn().then((res: any) => { + setCourses(res.data); + setLoading(false); + }); + }; + + return ( +
+
+ + {loading && ( +
+ +
+ )} + {courses.length === 0 && ( + + + + )} +
+
+
~莫道桑榆晚,为霞尚满天~
+
+ ); }; export default LatestLearnPage;