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