|
|
@ -1,26 +1,22 @@ |
|
|
|
import {FC, useEffect, useState} from "react"; |
|
|
|
import {FC, ReactNode, useEffect, useState} from "react"; |
|
|
|
import {Image, View} from "@tarojs/components"; |
|
|
|
import {Image, View} from "@tarojs/components"; |
|
|
|
import {HomeApi} from "@/api"; |
|
|
|
import {HomeApi} from "@/api"; |
|
|
|
import Taro, {useReachBottom} from "@tarojs/taro"; |
|
|
|
import {useReachBottom} from "@tarojs/taro"; |
|
|
|
import styles from "../home.module.scss"; |
|
|
|
import styles from "../home.module.scss"; |
|
|
|
import VideoCover from "@/components/videoCover/videoCover"; |
|
|
|
import VideoCover from "@/components/videoCover/videoCover"; |
|
|
|
import courseTag from '@/static/img/courseTag.png' |
|
|
|
import courseTag from '@/static/img/courseTag.png' |
|
|
|
|
|
|
|
import {rfc33392time} from "@/utils/day"; |
|
|
|
|
|
|
|
import Img from "@/components/image/image"; |
|
|
|
|
|
|
|
|
|
|
|
const CurRecommended: FC = () => { |
|
|
|
const CurRecommended: FC = () => { |
|
|
|
const [page, setPage] = useState(1) |
|
|
|
const [page, setPage] = useState(1) |
|
|
|
const [data, setData] = useState<Curriculum[]>([]) |
|
|
|
const [data, setData] = useState<Curriculum[]>([]) |
|
|
|
const [total, setTotal] = useState(0) |
|
|
|
const [total, setTotal] = useState(0) |
|
|
|
const [examine, setExamine] = useState(false) |
|
|
|
|
|
|
|
const [articles, setArticles] = useState<any[]>([]) |
|
|
|
const [articles, setArticles] = useState<any[]>([]) |
|
|
|
|
|
|
|
|
|
|
|
async function getData() { |
|
|
|
async function getData() { |
|
|
|
const res = await HomeApi.course(page, 4) |
|
|
|
const res = await HomeApi.course(page, 4) |
|
|
|
if (res.audit_mode) { |
|
|
|
setArticles(res.articles) |
|
|
|
Taro.setTabBarItem({index: 1, text: '文章'}) |
|
|
|
|
|
|
|
setArticles(res.articles) |
|
|
|
|
|
|
|
setExamine(res.audit_mode) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
setTotal(res.course.total) |
|
|
|
setTotal(res.course.total) |
|
|
|
const newData = res.course.data.reduce((pre, cut) => { |
|
|
|
const newData = res.course.data.reduce((pre, cut) => { |
|
|
|
const index = pre.findIndex(d => d.id === cut.id) |
|
|
|
const index = pre.findIndex(d => d.id === cut.id) |
|
|
@ -42,32 +38,54 @@ const CurRecommended: FC = () => { |
|
|
|
data.length < total && setPage(page + 1) |
|
|
|
data.length < total && setPage(page + 1) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let examines: ReactNode | undefined |
|
|
|
|
|
|
|
if (articles.length > 0) { |
|
|
|
|
|
|
|
examines = ( |
|
|
|
|
|
|
|
<View className="mb-5"> |
|
|
|
|
|
|
|
<View className='text-center my-2'>推荐文章</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> |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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}> |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
data.map(c => <VideoCover |
|
|
|
|
|
|
|
thumb={c.thumb} |
|
|
|
|
|
|
|
title={c.title} |
|
|
|
|
|
|
|
id={c.id} |
|
|
|
|
|
|
|
depId={c.id} |
|
|
|
|
|
|
|
key={c.id} |
|
|
|
|
|
|
|
marker={`共${c.class_hour}节`} |
|
|
|
|
|
|
|
/>) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
</View> |
|
|
|
|
|
|
|
</View> |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<> |
|
|
|
<> |
|
|
|
{ |
|
|
|
{examines} |
|
|
|
examine ? |
|
|
|
{videos} |
|
|
|
<> |
|
|
|
|
|
|
|
<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}> |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
data.map(c => <VideoCover |
|
|
|
|
|
|
|
thumb={c.thumb} |
|
|
|
|
|
|
|
title={c.title} |
|
|
|
|
|
|
|
id={c.id} |
|
|
|
|
|
|
|
depId={c.id} |
|
|
|
|
|
|
|
key={c.id} |
|
|
|
|
|
|
|
marker={`共${c.class_hour}节`} |
|
|
|
|
|
|
|
/>) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
</View> |
|
|
|
|
|
|
|
</View> |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
<View className='text-center text-muted font-28'>- 暂无更多 -</View> |
|
|
|
<View className='text-center text-muted font-28'>- 暂无更多 -</View> |
|
|
|
</> |
|
|
|
</> |
|
|
|
) |
|
|
|
) |
|
|
|