最近学习页面

This commit is contained in:
禺狨 2023-03-27 16:55:12 +08:00
parent c26bf2f9c5
commit ecdcc47d7d
3 changed files with 172 additions and 8 deletions

View File

@ -3,7 +3,6 @@ import { Image, Progress } from "antd";
import { useNavigate } from "react-router-dom";
import styles from "./courses-model.module.scss";
import mediaIcon from "../../../assets/images/commen/icon-medal.png";
import { Navigate } from "react-router-dom";
interface PropInterface {
id: number;

View File

@ -5,6 +5,101 @@
margin: 0 auto;
box-sizing: border-box;
padding: 50px 0;
.item {
width: 100%;
height: 138px;
background: #ffffff;
border: 2px solid #f6f6f6;
border-radius: 12px;
margin-bottom: 24px;
display: flex;
align-items: center;
box-sizing: border-box;
padding: 24px;
cursor: pointer;
&:hover {
border: none;
box-shadow: 0px 4px 16px 8px rgba(0, 0, 0, 0.04);
}
.item-info {
flex: 1;
height: 90px;
margin-left: 16px;
.top {
width: 100%;
display: flex;
align-items: center;
height: 24px;
.type {
width: 52px;
height: 24px;
background: rgba(255, 77, 79, 0.1);
border-radius: 6px;
font-size: 14px;
font-weight: 400;
color: #ff4d4f;
line-height: 24px;
display: flex;
align-items: center;
justify-content: center;
}
.active-type {
width: 52px;
height: 24px;
background: rgba(#ff9900, 0.1);
border-radius: 6px;
font-size: 14px;
font-weight: 400;
color: #ff9900;
line-height: 24px;
display: flex;
align-items: center;
justify-content: center;
}
.title {
width: 966px;
height: 24px;
font-size: 16px;
font-weight: 500;
color: rgba(0, 0, 0, 0.88);
line-height: 24px;
margin-left: 8px;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
text-align: left;
}
}
.record {
width: 100%;
height: 24px;
font-size: 14px;
font-weight: 400;
color: rgba(0, 0, 0, 0.45);
line-height: 24px;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
text-align: left;
margin-top: 9px;
}
.progress {
width: 336px;
margin-top: 9px;
height: 24px;
display: flex;
align-items: center;
.tip {
margin-left: 8px;
height: 24px;
font-size: 14px;
font-weight: 400;
color: #ff4d4f;
line-height: 24px;
}
}
}
}
}
.extra {
width: 1200px;

View File

@ -1,12 +1,14 @@
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";
import { Row, Col, Empty, Spin, Image, Progress } from "antd";
import mediaIcon from "../../assets/images/commen/icon-medal.png";
import { useNavigate } from "react-router-dom";
const LatestLearnPage = () => {
const navigate = useNavigate();
const [loading, setLoading] = useState<boolean>(false);
const [courses, setCourses] = useState<any>([]);
useEffect(() => {
getCourses();
@ -15,10 +17,7 @@ const LatestLearnPage = () => {
const getCourses = () => {
setLoading(true);
course.latestLearn().then((res: any) => {
setCourses(res.data);
setCourses(res.data);
setLoading(false);
});
};
@ -26,7 +25,7 @@ const LatestLearnPage = () => {
return (
<div>
<div className={styles["content"]}>
<Row style={{ width: 1200, margin: "0 auto", paddingTop: 50 }}>
<Row style={{ width: 1200 }}>
{loading && (
<div className="float-left d-j-flex mt-50">
<Spin size="large" />
@ -38,6 +37,77 @@ const LatestLearnPage = () => {
</Col>
)}
</Row>
{courses.length > 0 &&
courses.map((item: any) => (
<div
key={item.course.id}
className={styles["item"]}
onClick={() => {
navigate(`/course/${item.course.id}`);
}}
>
<Image
src={item.course.thumb}
width={120}
height={90}
style={{ borderRadius: 10 }}
preview={false}
/>
<div className={styles["item-info"]}>
<div className={styles["top"]}>
{item.course.is_required === 1 && (
<div className={styles["type"]}></div>
)}
{item.course.is_required === 0 && (
<div className={styles["active-type"]}></div>
)}
<div className={styles["title"]}>{item.course.title}</div>
</div>
{item.record && (
<>
<div className={styles["record"]}>
{item.record.finished_count}/
{item.record.hour_count}
</div>
<div className={styles["progress"]}>
{item.record.progress < 10000 && (
<Progress
percent={item.record.progress / 100}
strokeColor="#FF4D4F"
trailColor="#F6F6F6"
/>
)}
{item.record.progress >= 10000 && (
<>
<Image
width={24}
height={24}
src={mediaIcon}
preview={false}
/>
<span className={styles["tip"]}>
!
</span>
</>
)}
</div>
</>
)}
{!item.record && (
<>
<div className={styles["record"]}></div>
<div className={styles["progress"]}>
<Progress
percent={1}
strokeColor="#FF4D4F"
trailColor="#F6F6F6"
/>
</div>
</>
)}
</div>
</div>
))}
</div>
<div className={styles["extra"]}>~~</div>
</div>