|
|
@ -12,9 +12,10 @@ const VideoInfo: FC = () => { |
|
|
|
const [data, setData] = useState<CourseDepData | null>(null) |
|
|
|
const [data, setData] = useState<CourseDepData | null>(null) |
|
|
|
const [playId, setPlayId] = useState<number | null>(null) |
|
|
|
const [playId, setPlayId] = useState<number | null>(null) |
|
|
|
const [preview, setPreview] = useState(false) |
|
|
|
const [preview, setPreview] = useState(false) |
|
|
|
|
|
|
|
const [playing, setPlaying] = useState(false) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const getData = async () => { |
|
|
|
const getData = useCallback(async () => { |
|
|
|
const res = await curriculum.courseDep(id, depId) |
|
|
|
const res = await curriculum.courseDep(id, depId) |
|
|
|
if (res) { |
|
|
|
if (res) { |
|
|
|
setData(res) |
|
|
|
setData(res) |
|
|
@ -22,9 +23,15 @@ const VideoInfo: FC = () => { |
|
|
|
if (playId) { // 用于自动播放 判断当前课程是否完成
|
|
|
|
if (playId) { // 用于自动播放 判断当前课程是否完成
|
|
|
|
currentVideo(res) |
|
|
|
currentVideo(res) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}, [playing]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function curEnd() { |
|
|
|
|
|
|
|
setPlaying(false) |
|
|
|
|
|
|
|
getData().then() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function setHors(is_complete: boolean, play_id: number) { |
|
|
|
function setHors(is_complete: boolean, play_id: number) { |
|
|
|
|
|
|
|
setPlaying(true) |
|
|
|
setPreview(is_complete) |
|
|
|
setPreview(is_complete) |
|
|
|
setPlayId(play_id) |
|
|
|
setPlayId(play_id) |
|
|
|
} |
|
|
|
} |
|
|
@ -86,14 +93,12 @@ const VideoInfo: FC = () => { |
|
|
|
data && getData() |
|
|
|
data && getData() |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<> |
|
|
|
<> |
|
|
|
<View className='content'> |
|
|
|
<View className='content'> |
|
|
|
<View className='content-video'> |
|
|
|
<View className='content-video'> |
|
|
|
{playId ? |
|
|
|
{playId ? |
|
|
|
<Course id={playId} courseId={id} curEnd={getData} preview={preview}/> |
|
|
|
<Course id={playId} courseId={id} curEnd={curEnd} preview={preview}/> |
|
|
|
: <Image src={data?.course.thumb || ''} className='image' mode='scaleToFill'/>} |
|
|
|
: <Image src={data?.course.thumb || ''} className='image' mode='scaleToFill'/>} |
|
|
|
</View> |
|
|
|
</View> |
|
|
|
|
|
|
|
|
|
|
|