Commit 9151ad2c by zhanghaozhe

Merge branch 'limit-free' into dev

parents e6264056 2b111921
...@@ -69,10 +69,17 @@ class Index extends Component { ...@@ -69,10 +69,17 @@ class Index extends Component {
http.get(`${API.home}/m/home`).then((res) => { http.get(`${API.home}/m/home`).then((res) => {
if (res.data.code === 200) { if (res.data.code === 200) {
const {data} = res.data || {} const {data} = res.data || {}
const modules = Array.isArray(data.modules) ? data.modules : []
modules.forEach(item => {
if (item.name === '限时免费') {
item.showMoreButon = item.list.length && item.list.length > 4
item.list = item.list.slice(0, 4)
}
})
this.setState({ this.setState({
banner: data.banner, banner: data.banner,
lives: data.lives, lives: data.lives,
modules: typeof data.modules === 'object' && data.modules.length > 0 ? data.modules : [] modules
}) })
} else { } else {
Toast.info(res.data.msg, 2) Toast.info(res.data.msg, 2)
...@@ -217,15 +224,23 @@ class Index extends Component { ...@@ -217,15 +224,23 @@ class Index extends Component {
// 课程模块儿公共组件 // 课程模块儿公共组件
// 课程数量是奇数第一个课程需要横着展示沾满一行,课程数量是偶数一行显示两个 // 课程数量是奇数第一个课程需要横着展示沾满一行,课程数量是偶数一行显示两个
function CourseList({modules, toDetail}) { function CourseList({modules, toDetail}) {
let filterList = []
let isOdd = modules.list.length % 2 === 0 let isOdd = modules.list.length % 2 === 0
// 数量为奇数时,第一个课程显示大图(如后台未上传,前台显示小图),课程数量为偶数时,均显示小图
let filterList = ''
if (isOdd) { if (modules.name === '限时免费') {
filterList = modules.list filterList = modules.list
} else { } else {
filterList = modules.list[0].course_img === modules.list[0].course_img_small ? modules.list : modules.list.slice(1) // 数量为奇数时,第一个课程显示大图(如后台未上传,前台显示小图),课程数量为偶数时,均显示小图
if (isOdd) {
filterList = modules.list
} else {
filterList = modules.list[0].course_img === modules.list[0].course_img_small ? modules.list : modules.list.slice(1)
}
} }
return ( return (
<div className='category'> <div className='category'>
<h2 className="title"> <h2 className="title">
...@@ -240,13 +255,17 @@ function CourseList({modules, toDetail}) { ...@@ -240,13 +255,17 @@ function CourseList({modules, toDetail}) {
<Link className="more" to='/classify'>更多 ></Link> <Link className="more" to='/classify'>更多 ></Link>
} }
{ {
modules.show_more === 2 && modules.show_more === 2 ?
<Link className="more" to={modules.name === '限时免费' ? '/free' : modules.more_page}>更多 ></Link> modules.name === '限时免费'
? modules.showMoreButon &&
<Link className="more" to={'/free'}>更多 ></Link>
: <Link className="more" to={modules.more_page}>更多 ></Link>
: null
} }
<LazyLoad offset={50}> <LazyLoad offset={50}>
<ul className='index-course-detail'> <ul className='index-course-detail'>
{ {
!isOdd && modules.list[0].course_img !== modules.list[0].course_img_small && modules.name !== '限时免费' && !isOdd && modules.list[0].course_img !== modules.list[0].course_img_small &&
<div className="category-vip" onClick={() => toDetail(modules.list[0].course_id)}> <div className="category-vip" onClick={() => toDetail(modules.list[0].course_id)}>
<img src={modules.list[0].course_img} alt=""/> <img src={modules.list[0].course_img} alt=""/>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment