index.js 2.71 KB
Newer Older
1
import React, { Component } from 'react'
2
import './video-catalog.scss'
zhanghaozhe committed
3
import { Link } from "react-router-dom";
4 5 6 7 8
import classnames from 'classnames'


class VideoCatalog extends Component {

zhanghaozhe committed
9
    handleClick = (i) => {
10
        this.props.selectVideo(i)
zhanghaozhe committed
11 12
    }

13 14 15 16 17
    render() {
        return (
            <div className='video-catalog'>
                <ul>
                    {
zhanghaozhe committed
18
                        this.props.videoCatalog.map((item, index) => {
19
                            return (
xuzhenghua committed
20 21
                                <li 
                                    key={item.id}
zhanghaozhe committed
22 23
                                    className={classnames({active: this.props.activeIndex === index})}
                                >
xuzhenghua committed
24 25 26 27
                                    <div 
                                        className="video-title" 
                                        onClick={this.handleClick.bind(this, index)}
                                    >
28 29 30 31 32 33 34 35 36
                                        <span className="title">{item.name}</span>
                                        <span className='duration'>{item.duration}</span>
                                        <i className={classnames(`iconfont`,
                                            [item.video_auth === 0
                                                ? 'iconiconfront-74'
                                                : 'iconplay_hovericon'],
                                        )}/>
                                    </div>
                                    {
zhanghaozhe committed
37 38
                                        (item.practice && item.practice.qid)
                                            ? <Link to={{
xuzhenghua committed
39
                                                pathname: item.practice.is_tested ? '/campResolve' : '/campTest',
40 41
                                                search: `?keshi_id=${item.id}&qid=${item.practice.qid}`,
                                                state: {from: `/play/video${window.location.search}`}
zhanghaozhe committed
42 43 44
                                            }}>
                                                <div className="exercise">
                                                    课后练习:{item.practice.title}
45
                                                    <i className={classnames('iconfont',!item.video_auth ? 'iconiconfront-74' : item.practice.is_tested ? 'iconiconfront-3' : '')}/>
zhanghaozhe committed
46 47
                                                </div>
                                            </Link>
48 49
                                            : null
                                    }
50 51 52 53 54 55 56 57 58 59 60
                                </li>
                            )
                        })
                    }
                </ul>
            </div>
        );
    }
}

export default VideoCatalog;