diff --git a/src/assets/images/commen/empty.png b/src/assets/images/commen/empty.png index 5e867fa..dec7185 100644 Binary files a/src/assets/images/commen/empty.png and b/src/assets/images/commen/empty.png differ diff --git a/src/pages/course/compenents/hour.tsx b/src/pages/course/compenents/hour.tsx index 34a50ce..7bcbe15 100644 --- a/src/pages/course/compenents/hour.tsx +++ b/src/pages/course/compenents/hour.tsx @@ -1,4 +1,4 @@ -import React, { useState } from "react"; +import React, { useState, useEffect } from "react"; import { useNavigate } from "react-router-dom"; import styles from "./hour.module.scss"; import { durationFormat } from "../../../utils/index"; @@ -11,6 +11,7 @@ interface PropInterface { duration: number; record: any; progress: number; + totalHours: any; onChange: () => void; } @@ -21,21 +22,56 @@ export const HourCompenent: React.FC = ({ duration, record, progress, + totalHours, onChange, }) => { // const navigate = useNavigate(); const [visible, setVisible] = useState(false); + const [currentId, setCurrentId] = useState(id); + const [currentTitle, setCurrentTitle] = useState(title); + const [isLastpage, setIsLastpage] = useState(false); + + useEffect(() => { + getData(); + }, [totalHours]); + + const getData = () => { + const index = totalHours.findIndex((i: any) => i.id === id); + if (index === totalHours.length - 1) { + setIsLastpage(true); + } + }; + + const goNextVideo = () => { + const index = totalHours.findIndex((i: any) => i.id === id); + if (index === totalHours.length - 1) { + setIsLastpage(true); + } else if (index < totalHours.length - 1) { + setCurrentId(totalHours[index + 1].id); + setCurrentTitle(totalHours[index + 1].title); + if (index + 1 === totalHours.length - 1) { + setIsLastpage(true); + } + } + setVisible(true); + }; + return (
{ setVisible(false); onChange(); }} + goNextVideo={() => { + setVisible(false); + goNextVideo(); + }} >
diff --git a/src/pages/course/compenents/video.module.scss b/src/pages/course/compenents/video.module.scss index 0ab4fce..9c2f13c 100644 --- a/src/pages/course/compenents/video.module.scss +++ b/src/pages/course/compenents/video.module.scss @@ -70,6 +70,35 @@ background: linear-gradient(90deg, #f2f2f2 25%, #e6e6e6 37%, #f2f2f2 63%); background-size: 400% 100%; animation: el-skeleton-loading 1.4s ease infinite; + position: relative; + .alert-message { + width: 100%; + height: 100%; + background: rgba(0, 0, 0); + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + font-size: 18px; + color: white; + .alert-button { + width: 200px; + height: 54px; + background: #ff4d4f; + border-radius: 27px; + display: flex; + align-items: center; + justify-content: center; + cursor: pointer; + margin-bottom: 30px; + &:hover { + opacity: 0.8; + } + &:last-child { + margin-bottom: 0px; + } + } + } } } } diff --git a/src/pages/course/compenents/video.tsx b/src/pages/course/compenents/video.tsx index 611e58f..64cd080 100644 --- a/src/pages/course/compenents/video.tsx +++ b/src/pages/course/compenents/video.tsx @@ -2,6 +2,7 @@ import React, { useState, useRef, useEffect } from "react"; import styles from "./video.module.scss"; import { course } from "../../../api/index"; import { ArrowLeftOutlined } from "@ant-design/icons"; +import { useSelector } from "react-redux"; declare const window: any; @@ -10,7 +11,9 @@ interface PropInterface { cid: number; title: string; open: boolean; + isLastpage: boolean; onCancel: () => void; + goNextVideo: () => void; } export const VideoModel: React.FC = ({ @@ -18,11 +21,14 @@ export const VideoModel: React.FC = ({ cid, title, open, + isLastpage, onCancel, + goNextVideo, }) => { + const systemConfig = useSelector((state: any) => state.systemConfig.value); const [playUrl, setPlayUrl] = useState(""); const [playDuration, setPlayDuration] = useState(0); - const [playendedStatus,setPlayendedStatus]= useState(false); + const [playendedStatus, setPlayendedStatus] = useState(false); const myRef = useRef(0); useEffect(() => { @@ -48,14 +54,15 @@ export const VideoModel: React.FC = ({ autoplay: false, video: { url: playUrl, + pic: systemConfig.playerPoster, }, try: isTrySee === 1, bulletSecret: { - enabled: false, - text: "18119604035", + enabled: systemConfig.playerIsEnabledBulletSecret, + text: systemConfig.playerBulletSecretText, size: "15px", - color: "red", - opacity: 0.8, + color: systemConfig.playerBulletSecretColor || "red", + opacity: Number(systemConfig.playerBulletSecretOpacity), }, ban_drag: false, last_see_pos: 0, @@ -66,8 +73,9 @@ export const VideoModel: React.FC = ({ playTimeUpdate(parseInt(window.player.video.currentTime), false); }); window.player.on("ended", () => { + setPlayendedStatus(true); playTimeUpdate(parseInt(window.player.video.currentTime), true); - window.player.destroy(); + window.player && window.player.destroy(); }); }; @@ -101,6 +109,25 @@ export const VideoModel: React.FC = ({
{title}
+ {playendedStatus && ( +
+ {isLastpage && ( +
+ 恭喜你学完最后一节 +
+ )} + {!isLastpage && ( +
{ + setPlayendedStatus(false); + goNextVideo()}} + > + 播放下一节 +
+ )} +
+ )}
diff --git a/src/pages/course/index.tsx b/src/pages/course/index.tsx index 3dec3f7..8c9951b 100644 --- a/src/pages/course/index.tsx +++ b/src/pages/course/index.tsx @@ -15,6 +15,7 @@ const CoursePage = () => { const [hours, setHours] = useState({}); const [learnRecord, setLearnRecord] = useState({}); const [learnHourRecord, setLearnHourRecord] = useState({}); + const [totalHours, setTotalHours] = useState([]); useEffect(() => { getDetail(); @@ -32,6 +33,15 @@ const CoursePage = () => { if (res.data.learn_hour_records) { setLearnHourRecord(res.data.learn_hour_records); } + if (res.data.chapters.length === 0) { + setTotalHours(res.data.hours[0]); + } else if (res.data.chapters.length > 0) { + const arr: any = []; + chapters.map((item: any) => { + arr.concat(res.data.hours[item.id]); + }); + setTotalHours(arr); + } setLoading(false); }); }; @@ -116,7 +126,7 @@ const CoursePage = () => { {chapters.length === 0 && JSON.stringify(hours) === "{}" && } {chapters.length === 0 && JSON.stringify(hours) !== "{}" && (
- {hours[0].map((item: any) => ( + {hours[0].map((item: any, index: number) => (
{learnHourRecord[item.id] && ( { (learnHourRecord[item.id].finished_duration * 100) / learnHourRecord[item.id].total_duration } + totalHours={totalHours} onChange={() => getDetail()} > )} @@ -140,6 +151,7 @@ const CoursePage = () => { record={null} duration={item.duration} progress={0} + totalHours={totalHours} onChange={() => getDetail()} > )} @@ -149,10 +161,10 @@ const CoursePage = () => { )} {chapters.length > 0 && JSON.stringify(hours) !== "{}" && (
- {chapters.map((item: any) => ( + {chapters.map((item: any, index: number) => (
{item.name}
- {hours[item.id].map((it: any) => ( + {hours[item.id].map((it: any, int: number) => (
{learnHourRecord[it.id] && ( { learnHourRecord[it.id].total_duration } onChange={() => getDetail()} + totalHours={totalHours} > )} {!learnHourRecord[it.id] && ( @@ -176,6 +189,7 @@ const CoursePage = () => { record={null} duration={it.duration} progress={0} + totalHours={totalHours} onChange={() => getDetail()} > )}