|
|
|
@ -1,5 +1,5 @@ |
|
|
|
|
import {FC, useEffect, useState} from "react"; |
|
|
|
|
import {useReachBottom} from "@tarojs/taro"; |
|
|
|
|
import {useDidShow, useReachBottom} from "@tarojs/taro"; |
|
|
|
|
import {View} from "@tarojs/components"; |
|
|
|
|
import {Courses, CoursesKey, publicApi} from "@/api/public"; |
|
|
|
|
import VideoCover from "@/components/videoCover/videoCover"; |
|
|
|
@ -7,6 +7,7 @@ import styles from '../index.module.scss' |
|
|
|
|
import {formatMinute} from "@/utils/time"; |
|
|
|
|
import {userApi} from "@/api"; |
|
|
|
|
import Empty from "@/components/empty/empty"; |
|
|
|
|
import eventsIndex from "@/hooks/eventsIndex"; |
|
|
|
|
|
|
|
|
|
interface Props { |
|
|
|
|
categoryKey: CoursesKey |
|
|
|
@ -23,7 +24,6 @@ export const VideoList: FC<Props> = ({categoryKey, ready}) => { |
|
|
|
|
const [page, setPage] = useState(1) |
|
|
|
|
const [records, setRecords] = useState<LearnRecord[]>([]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function getData() { |
|
|
|
|
try { |
|
|
|
|
const res = await publicApi.course({page: 1, pageSize: 10 * page}) |
|
|
|
@ -64,9 +64,21 @@ export const VideoList: FC<Props> = ({categoryKey, ready}) => { |
|
|
|
|
setPage(page + 1) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
// eventsIndex.on(()=>{
|
|
|
|
|
// getRecords()
|
|
|
|
|
// })
|
|
|
|
|
eventsIndex.on(({id}) => { |
|
|
|
|
for (const [index, notFinished] of data.is_not_finished.entries()) { |
|
|
|
|
if (notFinished.id === id) { |
|
|
|
|
data.is_finished.push(notFinished) |
|
|
|
|
data.is_not_finished.splice(index, 1) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
useDidShow(() => { |
|
|
|
|
if (ready) { |
|
|
|
|
getRecords().then() |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
if (ready) { |
|
|
|
|