|
|
|
@ -1,7 +1,7 @@ |
|
|
|
|
import {FC, useEffect, useState} from "react"; |
|
|
|
|
import {Image, View} from "@tarojs/components"; |
|
|
|
|
import {HomeApi} from "@/api"; |
|
|
|
|
import {useReachBottom} from "@tarojs/taro"; |
|
|
|
|
import Taro, {useReachBottom} from "@tarojs/taro"; |
|
|
|
|
import styles from "../home.module.scss"; |
|
|
|
|
import VideoCover from "@/components/videoCover/videoCover"; |
|
|
|
|
import courseTag from '@/static/img/courseTag.png' |
|
|
|
@ -10,11 +10,19 @@ const CurRecommended: FC = () => { |
|
|
|
|
const [page, setPage] = useState(1) |
|
|
|
|
const [data, setData] = useState<Curriculum[]>([]) |
|
|
|
|
const [total, setTotal] = useState(0) |
|
|
|
|
const [examine, setExamine] = useState(false) |
|
|
|
|
const [articles, setArticles] = useState<any[]>([]) |
|
|
|
|
|
|
|
|
|
async function getData() { |
|
|
|
|
const res = await HomeApi.course(page, 4) |
|
|
|
|
setTotal(res.total) |
|
|
|
|
const newData = res.data.reduce((pre, cut) => { |
|
|
|
|
if (res.audit_mode) { |
|
|
|
|
Taro.setTabBarItem({index: 1, text: '文章'}) |
|
|
|
|
setArticles(res.articles) |
|
|
|
|
setExamine(res.audit_mode) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
setTotal(res.course.total) |
|
|
|
|
const newData = res.course.data.reduce((pre, cut) => { |
|
|
|
|
const index = pre.findIndex(d => d.id === cut.id) |
|
|
|
|
if (index === -1) { |
|
|
|
|
pre.push(cut) |
|
|
|
@ -37,7 +45,14 @@ const CurRecommended: FC = () => { |
|
|
|
|
return ( |
|
|
|
|
<> |
|
|
|
|
{ |
|
|
|
|
data.length > 0 && <View> |
|
|
|
|
examine ? |
|
|
|
|
<> |
|
|
|
|
<View className='text-center my-2'>推荐文章</View> |
|
|
|
|
{ |
|
|
|
|
articles.map(d => <View className='bg-white p-2 mb-2'>{d.title}</View>) |
|
|
|
|
} |
|
|
|
|
</> |
|
|
|
|
: data.length > 0 && <View> |
|
|
|
|
<Image src={courseTag} mode='widthFix' className={styles.courseTag}/> |
|
|
|
|
<View className={'pb-2 flex justify-between flex-wrap ' + styles.videoListBox}> |
|
|
|
|
{ |
|
|
|
@ -53,7 +68,7 @@ const CurRecommended: FC = () => { |
|
|
|
|
</View> |
|
|
|
|
</View> |
|
|
|
|
} |
|
|
|
|
<View className='text-center text-muted pb-3 font-28'>- 暂无更多 -</View> |
|
|
|
|
<View className='text-center text-muted font-28'>- 暂无更多 -</View> |
|
|
|
|
</> |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|