From 7cb936837ba68ec92742569ed78715cd7b9787f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A6=BA=E7=8B=A8?= <18119604035@163.com> Date: Mon, 27 Mar 2023 16:02:08 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=AD=A6=E4=B9=A0=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E6=98=BE=E7=A4=BA=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/course.ts | 5 ++++ src/pages/course/compenents/hour.tsx | 2 +- src/pages/course/index.tsx | 4 +-- src/pages/latest-learn/index.module.scss | 19 ++++++++++++ src/pages/latest-learn/index.tsx | 38 +++++++++++++++++++++++- 5 files changed, 64 insertions(+), 4 deletions(-) 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;