|
|
@ -1,9 +1,8 @@ |
|
|
|
import {FC, useEffect, useMemo, useState} from "react"; |
|
|
|
import {FC, useEffect, useMemo, useState} from "react"; |
|
|
|
import {useDidShow} from "@tarojs/taro"; |
|
|
|
import Taro, {useDidShow} from "@tarojs/taro"; |
|
|
|
import {ScrollView, Swiper, SwiperItem, View} from "@tarojs/components"; |
|
|
|
import {ScrollView, Swiper, SwiperItem, 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"; |
|
|
|
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"; |
|
|
@ -23,6 +22,9 @@ export const VideoList: FC<Props> = ({categoryKey, setCategoryKey}) => { |
|
|
|
const [page, setPage] = useState(1) |
|
|
|
const [page, setPage] = useState(1) |
|
|
|
const [records, setRecords] = useState<LearnRecord[]>([]) |
|
|
|
const [records, setRecords] = useState<LearnRecord[]>([]) |
|
|
|
const {token} = Profile.useContainer() |
|
|
|
const {token} = Profile.useContainer() |
|
|
|
|
|
|
|
const {windowHeight, textBarHeight, statusBarHeight} = Taro.getApp().globalData |
|
|
|
|
|
|
|
const pageHeight = windowHeight - textBarHeight - statusBarHeight |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function screen(oldData: Curriculum[], data: Curriculum[]): Curriculum[] { |
|
|
|
function screen(oldData: Curriculum[], data: Curriculum[]): Curriculum[] { |
|
|
|
return data.reduce((pre, cur) => { |
|
|
|
return data.reduce((pre, cur) => { |
|
|
@ -93,12 +95,12 @@ export const VideoList: FC<Props> = ({categoryKey, setCategoryKey}) => { |
|
|
|
}, [data, categoryKey]) |
|
|
|
}, [data, categoryKey]) |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<Swiper className={styles.swiper} |
|
|
|
<Swiper style={{height: pageHeight}} |
|
|
|
onChange={changeSwiper} |
|
|
|
onChange={changeSwiper} |
|
|
|
current={categoryIndex}> |
|
|
|
current={categoryIndex}> |
|
|
|
{ |
|
|
|
{ |
|
|
|
Object.entries(data).map(([key, value]) => <SwiperItem> |
|
|
|
Object.entries(data).map(([key, value]) => <SwiperItem> |
|
|
|
<ScrollView scrollY className={styles.swiper} onScrollToLower={() => setPage(page + 1)} enhanced |
|
|
|
<ScrollView scrollY style={{height: pageHeight}} onScrollToLower={() => setPage(page + 1)} enhanced |
|
|
|
showScrollbar={false}> |
|
|
|
showScrollbar={false}> |
|
|
|
{ |
|
|
|
{ |
|
|
|
!token && key === 'is_required' |
|
|
|
!token && key === 'is_required' |
|
|
|