|
|
|
@ -1,5 +1,5 @@ |
|
|
|
|
import {Image, Text, View} from "@tarojs/components"; |
|
|
|
|
import {FC, useEffect, useState} from "react"; |
|
|
|
|
import {FC, useCallback, useEffect, useState} from "react"; |
|
|
|
|
import {CourseDepData, curriculum} from "@/api"; |
|
|
|
|
import './videoInfo.scss' |
|
|
|
|
import {Profile} from '@/store' |
|
|
|
@ -24,7 +24,7 @@ const VideoInfo: FC = () => { |
|
|
|
|
} |
|
|
|
|
/** 用于自动播放 判断当前课程是否完成 */ |
|
|
|
|
if (playId) { |
|
|
|
|
currentVideo() |
|
|
|
|
currentVideo(res) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -37,8 +37,9 @@ const VideoInfo: FC = () => { |
|
|
|
|
getData() |
|
|
|
|
}, []) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** 播放下一个视频 */ |
|
|
|
|
function playNext() { |
|
|
|
|
const playNext = useCallback(() => { |
|
|
|
|
const flats: Hour[] = Object.values(data?.hours || {}).flat(Infinity) as Hour[] |
|
|
|
|
if (playId === flats?.[flats.length - 1]?.id) { |
|
|
|
|
Taro.showModal({title: '当前课程结束'}) |
|
|
|
@ -61,12 +62,12 @@ const VideoInfo: FC = () => { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}, [playId, data]) |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 判断当前课程是否完成 |
|
|
|
|
*/ |
|
|
|
|
function currentVideo() { |
|
|
|
|
const currentVideo = useCallback((data: CourseDepData) => { |
|
|
|
|
const courseHourRecordsFinish = data?.learn_hour_records.find(d => d.id === playId)?.courseHourRecordsFinish |
|
|
|
|
if (typeof courseHourRecordsFinish === 'number') { |
|
|
|
|
if (courseHourRecordsFinish === 1) { |
|
|
|
@ -82,7 +83,7 @@ const VideoInfo: FC = () => { |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}, [playId, data]) |
|
|
|
|
|
|
|
|
|
Taro.useDidShow(() => { |
|
|
|
|
data && getData() |
|
|
|
|