From 58ba3577a8c29b30098f7904ffe46727955a66e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A6=BA=E7=8B=A8?= <18119604035@163.com> Date: Thu, 29 Jun 2023 18:59:24 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E8=AF=A6=E6=83=85=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/course/compenents/hour.module.scss | 57 +++++++++++++ src/pages/course/compenents/hour.tsx | 57 +++++++++++++ src/pages/course/index.module.scss | 66 +++++++++++++++ src/pages/course/index.tsx | 86 +++++++++++++++++++- src/utils/index.ts | 9 ++ 5 files changed, 272 insertions(+), 3 deletions(-) create mode 100644 src/pages/course/compenents/hour.module.scss create mode 100644 src/pages/course/compenents/hour.tsx diff --git a/src/pages/course/compenents/hour.module.scss b/src/pages/course/compenents/hour.module.scss new file mode 100644 index 0000000..4de7cc8 --- /dev/null +++ b/src/pages/course/compenents/hour.module.scss @@ -0,0 +1,57 @@ +.item { + width: 100%; + height: auto; + background: #fafafa; + border-radius: 7px; + display: flex; + flex-direction: column; + box-sizing: border-box; + padding: 10px; + + .top-item { + width: 100%; + height: 15px; + display: flex; + align-items: center; + justify-content: space-between; + i { + color: rgba(0, 0, 0, 0.3); + } + + .label { + height: 16px; + font-size: 12px; + font-weight: 400; + color: rgba(0, 0, 0, 0.45); + line-height: 16px; + margin-left: 5px; + } + + .studying { + height: 16px; + font-size: 12px; + font-weight: 400; + color: #ff4d4f; + line-height: 16px; + } + + .complete { + height: 16px; + font-size: 12px; + font-weight: 400; + color: rgba(0, 0, 0, 0.45); + line-height: 16px; + } + } + + .title { + width: 100%; + height: auto; + font-size: 14px; + font-weight: 400; + color: rgba(0, 0, 0, 0.88); + line-height: 20px; + margin-top: 15px; + text-align: left; + } +} diff --git a/src/pages/course/compenents/hour.tsx b/src/pages/course/compenents/hour.tsx new file mode 100644 index 0000000..3c2100b --- /dev/null +++ b/src/pages/course/compenents/hour.tsx @@ -0,0 +1,57 @@ +import React from "react"; +import { useNavigate } from "react-router-dom"; +import styles from "./hour.module.scss"; +import { durationFormat } from "../../../utils/index"; + +interface PropInterface { + id: number; + cid: number; + title: string; + duration: number; + record: any; + progress: number; +} + +export const HourCompenent: React.FC = ({ + id, + cid, + title, + duration, + record, + progress, +}) => { + const navigate = useNavigate(); + return ( + <> +
{ + navigate(`/course/${cid}/hour/${id}`); + }} + > +
+
+ + 视频 +
+ {progress > 0 && progress < 100 && ( +
+ + 学习到 + {durationFormat(Number(record.finished_duration || 0))} + +
+ )} + {progress >= 100 && ( +
+ 已学完{" "} +
+ )} +
+
+ {title}({durationFormat(Number(duration))}) +
+
+ + ); +}; diff --git a/src/pages/course/index.module.scss b/src/pages/course/index.module.scss index 43306cb..bbe2a7e 100644 --- a/src/pages/course/index.module.scss +++ b/src/pages/course/index.module.scss @@ -27,6 +27,7 @@ display: flex; flex-direction: row; align-items: center; + margin-bottom: 20px; .info { flex: 1; display: flex; @@ -67,3 +68,68 @@ } } } + +.other-content { + width: 100%; + float: left; + height: auto; + border-radius: 16px 16px 0px 0px; + background-color: #ffffff; + box-sizing: border-box; + padding: 20px; + margin-top: -20px; + z-index: 10; + .desc { + width: 100%; + max-height: 72px; + font-size: 12px; + font-weight: 400; + color: rgba(0, 0, 0, 0.45); + line-height: 18px; + text-align: left; + overflow: hidden; + text-overflow: ellipsis; + display: -webkit-box; + -webkit-line-clamp: 4; + -webkit-box-orient: vertical; + } + .line { + width: 100%; + height: 1px; + background: rgba(0, 0, 0, 0.05); + margin-top: 20px; + } + .chapters-hours-cont { + width: 100%; + height: auto; + .hours-list-box { + width: 100%; + height: auto; + display: flex; + flex-direction: column; + .chapter-it { + width: 100%; + height: auto; + margin-top: 20px; + + .chapter-name { + width: 100%; + height: 15px; + font-size: 15px; + font-weight: 500; + color: rgba(0, 0, 0, 0.88); + line-height: 15px; + text-align: left; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + } + } + .hours-it { + width: 100%; + height: auto; + margin-top: 20px; + } + } + } +} diff --git a/src/pages/course/index.tsx b/src/pages/course/index.tsx index 0903dbc..37e989f 100644 --- a/src/pages/course/index.tsx +++ b/src/pages/course/index.tsx @@ -5,6 +5,7 @@ import { useNavigate, useParams } from "react-router-dom"; import backIcon from "../../assets/images/commen/icon-back-n.png"; import { course as Course } from "../../api/index"; import { Empty } from "../../components"; +import { HourCompenent } from "./compenents/hour"; const CoursePage = () => { const params = useParams(); @@ -75,7 +76,7 @@ const CoursePage = () => { style={{ "--size": "80px", "--fill-color": "#FFFFFF", - "--track-color": "#F6F6F6", + "--track-color": "#ffffff4D", "--track-width": "7px", }} > @@ -89,7 +90,7 @@ const CoursePage = () => { style={{ "--size": "80px", "--fill-color": "#FFFFFF", - "--track-color": "#F6F6F6", + "--track-color": "#ffffff4D", "--track-width": "7px", }} > @@ -103,7 +104,7 @@ const CoursePage = () => { style={{ "--size": "80px", "--fill-color": "#FFFFFF", - "--track-color": "#F6F6F6", + "--track-color": "#ffffff4D", "--track-width": "7px", }} > @@ -115,6 +116,85 @@ const CoursePage = () => { +
+ {course.short_desc && ( + <> +
{course.short_desc}
+
+ + )} +
+ {chapters.length === 0 && JSON.stringify(hours) === "{}" && }{" "} + {chapters.length === 0 && JSON.stringify(hours) !== "{}" && ( +
+ {hours[0].map((item: any, index: number) => ( +
+ {learnHourRecord[item.id] && ( + + )} + {!learnHourRecord[item.id] && ( + + )} +
+ ))} +
+ )} + {chapters.length > 0 && JSON.stringify(hours) !== "{}" && ( +
+ {chapters.map((item: any, index: number) => ( +
+
{item.name}
+ {hours[item.id] && + hours[item.id].map((it: any, int: number) => ( +
+ {learnHourRecord[it.id] && ( + + )} + {!learnHourRecord[it.id] && ( + + )} +
+ ))} +
+ ))} +
+ )} +
+
); }; diff --git a/src/utils/index.ts b/src/utils/index.ts index b952b7d..30782b9 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -60,3 +60,12 @@ export function studyTimeFormat(dateStr: number) { value.push(d.seconds()); return value; } + +export function durationFormat(dateStr: number) { + var d = moment.duration(dateStr, "seconds"); + let hour = d.hours() === 0 ? "" : d.hours() + ":"; + let minute = d.minutes() >= 10 ? d.minutes() + ":" : "0" + d.minutes() + ":"; + let second = d.seconds() >= 10 ? d.seconds() : "0" + d.seconds(); + + return hour + minute + second; +}