|
|
|
@ -5,6 +5,7 @@ import {CoursesKey, Cur, publicApi} from "@/api/public"; |
|
|
|
|
import VideoCover from "@/components/videoCover/videoCover"; |
|
|
|
|
import styles from '../index.module.scss' |
|
|
|
|
import {formatMinute} from "@/utils/time"; |
|
|
|
|
import {userApi} from "@/api"; |
|
|
|
|
|
|
|
|
|
interface Props { |
|
|
|
|
categoryId: CoursesKey |
|
|
|
@ -13,6 +14,7 @@ interface Props { |
|
|
|
|
export const VideoList: FC<Props> = ({categoryId}: Props) => { |
|
|
|
|
const [data, setDta] = useState<Cur[] | null>(null) |
|
|
|
|
const [index, setIndex] = useState(3) |
|
|
|
|
const [records, setRecords] = useState<LearnRecord[]>([]) |
|
|
|
|
|
|
|
|
|
async function getData() { |
|
|
|
|
try { |
|
|
|
@ -35,10 +37,29 @@ export const VideoList: FC<Props> = ({categoryId}: Props) => { |
|
|
|
|
Taro.hideLoading() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async function getRecords() { |
|
|
|
|
try { |
|
|
|
|
const {user_course_records} = await userApi.learningRecord() |
|
|
|
|
setRecords(user_course_records) |
|
|
|
|
} catch (e) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function rateOfLearning(id: number, class_hour: number): JSX.Element { |
|
|
|
|
console.log(id) |
|
|
|
|
return (<View>{`共${class_hour}节/已学${0}节`}</View>) |
|
|
|
|
switch (categoryId) { |
|
|
|
|
case "is_finished": |
|
|
|
|
case "is_not_required": |
|
|
|
|
const find = records.find(d => d.course_id === id) |
|
|
|
|
if (find) { |
|
|
|
|
return (<View>{`共${class_hour}节/已学${find.finished_count}节`}</View>) |
|
|
|
|
} |
|
|
|
|
return (<View>{`共${class_hour}节/已学0节`}</View>) |
|
|
|
|
case "is_not_finished": |
|
|
|
|
return (<View>{`共${class_hour}节/已学0节`}</View>) |
|
|
|
|
case "is_required": |
|
|
|
|
return (<View>{`共${class_hour}节/已学${class_hour}节`}</View>) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function jumpCategoryCur(id: number) { |
|
|
|
@ -51,7 +72,10 @@ export const VideoList: FC<Props> = ({categoryId}: Props) => { |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
Taro.useDidShow(getData) |
|
|
|
|
Taro.useDidShow(() => { |
|
|
|
|
getData() |
|
|
|
|
getRecords() |
|
|
|
|
}) |
|
|
|
|
return ( |
|
|
|
|
<> |
|
|
|
|
{data?.slice(0, index).map(d => ( |
|
|
|
|