|
|
|
@ -1,26 +1,22 @@ |
|
|
|
|
import {FC, useEffect, useState} from "react"; |
|
|
|
|
import {FC, ReactNode, useEffect, useState} from "react"; |
|
|
|
|
import {Image, View} from "@tarojs/components"; |
|
|
|
|
import {HomeApi} from "@/api"; |
|
|
|
|
import Taro, {useReachBottom} from "@tarojs/taro"; |
|
|
|
|
import {useReachBottom} from "@tarojs/taro"; |
|
|
|
|
import styles from "../home.module.scss"; |
|
|
|
|
import VideoCover from "@/components/videoCover/videoCover"; |
|
|
|
|
import courseTag from '@/static/img/courseTag.png' |
|
|
|
|
import {rfc33392time} from "@/utils/day"; |
|
|
|
|
import Img from "@/components/image/image"; |
|
|
|
|
|
|
|
|
|
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) |
|
|
|
|
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) |
|
|
|
@ -42,17 +38,33 @@ const CurRecommended: FC = () => { |
|
|
|
|
data.length < total && setPage(page + 1) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
<> |
|
|
|
|
{ |
|
|
|
|
examine ? |
|
|
|
|
<> |
|
|
|
|
let examines: ReactNode | undefined |
|
|
|
|
if (articles.length > 0) { |
|
|
|
|
examines = ( |
|
|
|
|
<View className="mb-5"> |
|
|
|
|
<View className='text-center my-2'>推荐文章</View> |
|
|
|
|
{ |
|
|
|
|
articles.map(d => <View className='bg-white p-2 mb-2'>{d.title}</View>) |
|
|
|
|
<View className='bg-white rounded-20 clip'> |
|
|
|
|
{articles.map((d, i) => <View className='p-3 relative'> |
|
|
|
|
{i > 0 && <View className='absolute top left right divided ml-3 mr-3' />} |
|
|
|
|
<View className="font-34 bold text-black">{d.title}</View> |
|
|
|
|
{(d.intro || '').length > 40 && (<View className='flex mt-1'> |
|
|
|
|
<View className="flex-1 font-24 lh1_5">{d.intro}文章结束阿斯卡极乐空间是你拉卡萨文章结束阿斯卡极乐空间是你拉卡萨文章结束阿斯卡极乐空间是你拉卡萨文章结束阿斯卡极乐空间是你拉卡萨文章结束阿斯卡极乐空间是你拉卡萨文章结束阿斯卡极乐空间是你拉卡萨</View> |
|
|
|
|
{d.cover && <Img className='ml-l' width={140} height={100} src={d.cover} errorType="acquiesce" />} |
|
|
|
|
</View>)} |
|
|
|
|
<View className="flex mt-3 justify-between font-24 text-muted"> |
|
|
|
|
<View>{rfc33392time(d.created_at).split(' ')[0]}</View> |
|
|
|
|
<View>阅读 {d.page_view || 0}</View> |
|
|
|
|
</View> |
|
|
|
|
</View>)} |
|
|
|
|
</View> |
|
|
|
|
</View> |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
</> |
|
|
|
|
: data.length > 0 && <View> |
|
|
|
|
|
|
|
|
|
let videos: ReactNode | undefined |
|
|
|
|
if (data.length > 0) { |
|
|
|
|
videos = ( |
|
|
|
|
<View> |
|
|
|
|
<Image src={courseTag} mode='widthFix' className={styles.courseTag}/> |
|
|
|
|
<View className={'pb-2 flex justify-between flex-wrap ' + styles.videoListBox}> |
|
|
|
|
{ |
|
|
|
@ -67,7 +79,13 @@ const CurRecommended: FC = () => { |
|
|
|
|
} |
|
|
|
|
</View> |
|
|
|
|
</View> |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
<> |
|
|
|
|
{examines} |
|
|
|
|
{videos} |
|
|
|
|
<View className='text-center text-muted font-28'>- 暂无更多 -</View> |
|
|
|
|
</> |
|
|
|
|
) |
|
|
|
|