Commit e1df1739 by FE

to course detail modify

parent 6e9fd950
...@@ -6,8 +6,10 @@ import {Link} from 'react-router-dom' ...@@ -6,8 +6,10 @@ import {Link} from 'react-router-dom'
import {Toast} from 'antd-mobile' import {Toast} from 'antd-mobile'
import {HeaderBar} from "@/common" import {HeaderBar} from "@/common"
import Loading from '@/common/Loading' import Loading from '@/common/Loading'
import {connet} from 'react-redux';
import {getCourses} from './../detail/actions';
@connet()
class Classify extends Component { class Classify extends Component {
constructor(props) { constructor(props) {
super(props) super(props)
...@@ -50,21 +52,31 @@ class Classify extends Component { ...@@ -50,21 +52,31 @@ class Classify extends Component {
}) })
} }
toCourseDetail = (id) => {
const { dispatch, history } = this.props;
dispatch(getCourses(id, () => {
history.push(`/detail?id=${id}`);
return false;
}));
}
render() { render() {
return ( return (
<div className='class-box'> <div className='class-box'>
<HeaderBar title='分类' arrow={false} cart={false}></HeaderBar> <HeaderBar title='分类' arrow={false} cart={false}></HeaderBar>
<Loading isLoading={this.state.isLoading}> <Loading isLoading={this.state.isLoading}>
<ClassCourseBox data={this.state.camp.list} title={this.state.camp.name} type={1}/> <ClassCourseBox toDetail={this.toCourseDetail} data={this.state.camp.list} title={this.state.camp.name} type={1}/>
<ClassCourseBox data={this.state.employment.list} title={this.state.employment.name} type={1}/> <ClassCourseBox toDetail={this.toCourseDetail} data={this.state.employment.list} title={this.state.employment.name} type={1}/>
<ClassCourseBox data={this.state.basics.list} title={this.state.basics.name} type={2}/> <ClassCourseBox toDetail={this.toCourseDetail} data={this.state.basics.list} title={this.state.basics.name} type={2}/>
<ClassCourseBox data={this.state.advanced.list} title={this.state.advanced.name} type={2}/> <ClassCourseBox toDetail={this.toCourseDetail} data={this.state.advanced.list} title={this.state.advanced.name} type={2}/>
<div className="vip"> <div className="vip">
{this.state.special.list && this.state.special.list.length > 0 && this.state.special.list.map((item, index) => { {this.state.special.list && this.state.special.list.length > 0 && this.state.special.list.map((item, index) => {
return ( return (
<Link key={index} to={`/detail?id=${item.course_id}`}> <a href="javascript:;" onClick={() => this.toCourseDetail(item.course_id)} key={index}>
{/* <Link key={index} to={`/detail?id=${item.course_id}`}> */}
<img src={item.course_img} alt=""/> <img src={item.course_img} alt=""/>
</Link> {/* </Link> */}
</a>
) )
}) })
} }
...@@ -76,19 +88,21 @@ class Classify extends Component { ...@@ -76,19 +88,21 @@ class Classify extends Component {
} }
// 课程图片形式展示 点击图片直接跳转课程详情页面 // 课程图片形式展示 点击图片直接跳转课程详情页面
function ClassCourseA({data}) { function ClassCourseA({data, toDetail}) {
return ( return (
<div className='items-box'> <div className='items-box'>
{ {
data && data.length > 0 && data.map((item, index) => { data && data.length > 0 && data.map((item, index) => {
return ( return (
<Link to={`/detail?id=${item.course_id}`} key={index} className='item-banner'> <a href="javascript:;" onClick={() => toDetail(item.course_id)} key={index} className='item-banner'>
{/* <Link to={`/detail?id=${item.course_id}`} key={index} className='item-banner'> */}
<img src={item.course_img} alt=""/> <img src={item.course_img} alt=""/>
{ {
(item.is_aist && (item.is_aist &&
<span className='return_cash'></span>) <span className='return_cash'></span>)
} }
</Link> {/* </Link> */}
</a>
) )
}) })
} }
...@@ -121,7 +135,7 @@ function ClassCourseBox(props) { ...@@ -121,7 +135,7 @@ function ClassCourseBox(props) {
{props.title} {props.title}
</p> </p>
{props.type === 1 && {props.type === 1 &&
<ClassCourseA data={props.data}/> <ClassCourseA data={props.data} toDetail={props.toDetail} />
} }
{props.type === 2 && {props.type === 2 &&
<ClassCourseB data={props.data}/> <ClassCourseB data={props.data}/>
......
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