|
|
|
@ -1,7 +1,7 @@ |
|
|
|
|
import {ScrollView, Text, View} from "@tarojs/components"; |
|
|
|
|
import {FC, useEffect, useState} from "react"; |
|
|
|
|
import HVideo from "@/components/video/video"; |
|
|
|
|
import {CurEndParam, curriculum, HourPlayData} from "@/api"; |
|
|
|
|
import {curriculum, HourPlayData} from "@/api"; |
|
|
|
|
import {Profile} from '@/store' |
|
|
|
|
import Taro from "@tarojs/taro"; |
|
|
|
|
import Judge from "@/components/topic/judge"; |
|
|
|
@ -28,11 +28,10 @@ const Course: FC<Props> = ({id, courseId, preview, curEnd}) => { |
|
|
|
|
const [validate, setValidate] = useState(false) // 开启验证
|
|
|
|
|
const [record, setRecord] = useState<boolean[]>([]) // 考题记录
|
|
|
|
|
const [testId, setTestId] = useState<number | null>(null) |
|
|
|
|
const [startRecording, setStartRecording] = useState<CurEndParam | null>(null) // 视频开始记录
|
|
|
|
|
const {user} = Profile.useContainer() |
|
|
|
|
|
|
|
|
|
async function onEnded() { |
|
|
|
|
unique_ident.put(data?.duration, Date.now()) // 记录
|
|
|
|
|
const startRecording = unique_ident.get() |
|
|
|
|
startRecording && await curriculum.curEnd(courseId, id, {...startRecording, duration: data?.duration!}) // 结束
|
|
|
|
|
|
|
|
|
|
if (testId) { |
|
|
|
@ -64,31 +63,13 @@ const Course: FC<Props> = ({id, courseId, preview, curEnd}) => { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async function getData() { |
|
|
|
|
unique_ident.put() |
|
|
|
|
|
|
|
|
|
unique_ident.put(id, Date.now()) |
|
|
|
|
const res = await curriculum.hourPlay(courseId, id) |
|
|
|
|
|
|
|
|
|
if (res) { |
|
|
|
|
setData(res) |
|
|
|
|
setBreakpoint(res.timeList) |
|
|
|
|
setExamAll(res.hourExamQuestions || []) |
|
|
|
|
setTestId(res?.hour_test?.id || null) |
|
|
|
|
|
|
|
|
|
setStartRecording({ |
|
|
|
|
duration: 0, |
|
|
|
|
unique_ident: res.unique_ident, |
|
|
|
|
start_date: Date.now() |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
unique_ident.set({ |
|
|
|
|
courseId: Number(courseId), |
|
|
|
|
user_id: user?.id!, |
|
|
|
|
duration: 0, |
|
|
|
|
start_date: Date.now(), |
|
|
|
|
end_date: Date.now(), |
|
|
|
|
hour_id: id, |
|
|
|
|
unique_ident: res.unique_ident |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|