index.js 12.1 KB
Newer Older
xuzhenghua committed
1
import React, {Component} from 'react'
xuzhenghua committed
2
import {Link} from 'react-router-dom'
xuzhenghua committed
3 4
import {Tabs, WhiteSpace} from 'antd-mobile'
import './index.scss'
xuzhenghua committed
5 6
import {api, getParam, http} from "@/utils"
import {Toast} from 'antd-mobile'
xuzhenghua committed
7 8 9


class OutLine extends Component {
xuzhenghua committed
10 11
    constructor(props) {
        super(props)
xuzhenghua committed
12 13 14
        this.state = {
            stageInfo: []
        }
xuzhenghua committed
15
    }
xuzhenghua committed
16 17 18 19 20 21 22

    htmlDecode = (content) => {
        let e = document.createElement('div');
        e.innerHTML = content;
        return e.childNodes.length === 0 ? "" : e.childNodes[0].nodeValue;
    }

23 24 25 26 27
    tabchange = (tab, index) => {
        if(index === 1) {
            this.getList()
        }
    };
xuzhenghua committed
28 29 30

    // 获取大纲数据
    getList = () => {
zhanghaozhe committed
31
        http.get(`${API.home}/m/course/syllabuses/${getParam('id')}`).then((res) => {
xuzhenghua committed
32 33 34 35
            if (res.data.code === 200) {
                this.setState({
                    stageInfo: res.data.data
                })
xuzhenghua committed
36 37
            } else {
                Toast.info(res.data.msg, 2)
xuzhenghua committed
38 39 40 41
            }
        })
    }

xuzhenghua committed
42 43 44 45 46
    render() {
        const tabs = [
            {title: '介绍'},
            {title: '大纲'}
        ];
xuzhenghua committed
47
        let introduce = ''
48 49
        if (this.props.data) {
            introduce = this.props.data
xuzhenghua committed
50
        }
xuzhenghua committed
51 52 53
        return (
            <div className='course-detail'>
                <WhiteSpace/>
54 55 56 57
                <Tabs tabs={tabs}
                initialPage={0}
                onChange={(tab, index) => { this.tabchange(tab, index) }}
                >
xuzhenghua committed
58 59
                    {/*介绍*/}
                    <div className='introduce'>
xuzhenghua committed
60 61 62
                        <p>讲师:{introduce.teachers}</p>
                        <p>课时:{introduce.course_hour}</p>
                        <p>时间:{introduce.start_time}</p>
xuzhenghua committed
63
                        <div className='dec' dangerouslySetInnerHTML={{__html: this.htmlDecode(introduce.intro)}}></div>
xuzhenghua committed
64 65 66 67
                    </div>
                    {/*大纲*/}
                    <div className='outline'>
                        {
xuzhenghua committed
68
                            this.state.stageInfo && this.state.stageInfo.length > 0 && this.state.stageInfo.map((item, index) => {
xuzhenghua committed
69 70 71 72 73 74 75
                                return (
                                    <div className='stagebox' key={index}>
                                        <h1 className='stage text-overflow-1'>{item.stage_name}</h1>
                                        {
                                            item.lesson.map((item, index) => {
                                                return (
                                                    <ul key={index}>
xuzhenghua committed
76 77
                                                        <h2 className='classhour'>
                                                            <span className='title text-overflow-1'>{item.name}</span>
xuzhenghua committed
78 79 80 81 82 83 84
                                                            {/*
                                                             class_status
                                                                 0-未购买未开单集购买
                                                                 1-未购买已开单集购买
                                                                 2-已购买直播结束已上传视频
                                                                 3-已购买未开课、已购买直播结束
                                                                 4-已购买直播中
xuzhenghua committed
85 86
                                                                 5-可试听且有试听权限
                                                                 6-可试听但无试听权限
xuzhenghua committed
87
                                                            */}
xuzhenghua committed
88
                                                            { // 试听
xuzhenghua committed
89
                                                                !introduce.is_aist && item.class_status === 6 &&
xuzhenghua committed
90
                                                                <span className='btn-right-10 audition'
xuzhenghua committed
91 92 93
                                                                      onClick={this.props.toAudition}>试听
                                                                <i className='iconfont iconcelluar'></i>
                                                                </span>
xuzhenghua committed
94 95
                                                            }
                                                            {  // 未购买未开单集购买:上锁标志,点击提示购买
xuzhenghua committed
96
                                                                !introduce.is_aist && item.class_status === 0 &&
xuzhenghua committed
97 98 99
                                                                <i className='iconfont iconiconfront-74 icon-right-22'></i>
                                                            }
                                                            {  // 未购买已开单集购买:显示单集价格,点击购买单集
xuzhenghua committed
100
                                                                !introduce.is_aist && item.class_status === 1 &&
xuzhenghua committed
101
                                                                <span className='btn-right-10 singleset'
xuzhenghua committed
102
                                                                      onClick={e => this.props.toSingleset(item)}>¥ {item.class_price}</span>
xuzhenghua committed
103 104
                                                            }
                                                            {
xuzhenghua committed
105
                                                                !introduce.is_aist && item.class_status === 4 &&
xuzhenghua committed
106
                                                                item.video_auth === 1 && item.is_video === 4 &&
xuzhenghua committed
107 108 109 110 111
                                                                <span className='live icon-right-22'>正在直播<i
                                                                    className='iconfont icondanseshixintubiao-23'></i></span>
                                                            }
                                                            {
                                                                // 已购买直播结束已上传视频:正常播放按钮,点击播放课程
xuzhenghua committed
112
                                                                !introduce.is_aist && item.class_status === 2 &&
xuzhenghua committed
113
                                                                <Link to={`/play/video?id=${introduce.v_course_id + '&video_id=' + item.video_id}`} className='iconfont icondanseshixintubiao-23 icon-right-22'></Link>
xuzhenghua committed
114
                                                            }
xuzhenghua committed
115 116 117

                                                            {
                                                                // 返现课程 是返现课程  未开课 已开课   是返现课程  未开课  已开课  已练习
xuzhenghua committed
118
                                                                introduce.is_aist && item.is_open && introduce.is_baoming === 1 &&
xuzhenghua committed
119
                                                                <Link to={`/play/video?id=${introduce.v_course_id + '&video_id=' + item.video_id}`} className='aist aist_open'></Link>
xuzhenghua committed
120

xuzhenghua committed
121 122 123 124
                                                            }

                                                            {
                                                                // 返现课程 是返现课程  未开课 已开课   是返现课程  未开课  已开课  已练习
xuzhenghua committed
125
                                                                introduce.is_aist && (!item.is_open || introduce.is_baoming === 0) &&
zhanghaozhe committed
126 127

                                                                <i className='aist iconfont iconiconfront-74'></i>
xuzhenghua committed
128
                                                            }
xuzhenghua committed
129 130
                                                        </h2>
                                                        {
xuzhenghua committed
131
                                                            item.point && item.point.length > 0 && item.point.map((item, index) => {
xuzhenghua committed
132 133
                                                                const type = (
                                                                    <span>
xuzhenghua committed
134 135 136 137 138 139 140 141 142
                                                                        {
                                                                            item.type === 1 &&
                                                                            <span>知识点{index + 1}</span>
                                                                        }
                                                                        {
                                                                            item.type === 2 &&
                                                                            <span className='red'>实战项目:</span>
                                                                        }
                                                                    </span>
xuzhenghua committed
143 144 145 146 147 148 149 150 151
                                                                )

                                                                return (
                                                                    <li className='points text-overflow-1'
                                                                        key={index}>{type}{item.name}</li>
                                                                )

                                                            })
                                                        }
xuzhenghua committed
152 153 154
                                                        {
                                                            <>
                                                                {
xuzhenghua committed
155
                                                                    introduce.is_aist && item.practice.title !== "" &&  (!item.is_open || introduce.is_baoming === 0) &&
xuzhenghua committed
156 157 158 159 160 161
                                                                    <span className='camp camp_test' key={index}>
                                                                        <span>课后练习:{item.practice.title}</span>
                                                                        <i className='exam exam_close' />
                                                                    </span>
                                                                }
                                                                {
xuzhenghua committed
162
                                                                    introduce.is_aist && item.practice.title !== "" &&  item.is_open && introduce.is_baoming === 1 && !item.practice.is_tested &&
xuzhenghua committed
163 164 165 166 167
                                                                    <Link to={`/campTest?keshi_id=${item.video_id}&qid=${item.practice.qid}`} className='camp camp_test' key={index}>
                                                                        <span>课后练习:{item.practice.title}</span>
                                                                    </Link>
                                                                }
                                                                {
xuzhenghua committed
168
                                                                    introduce.is_aist && item.practice.title !== "" &&  item.is_open && introduce.is_baoming === 1 && item.practice.is_tested &&
xuzhenghua committed
169 170 171 172 173 174 175
                                                                    <Link to={`/campResolve?keshi_id=${item.video_id}&qid=${item.practice.qid}`} className='camp camp_test' key={index}>
                                                                        <span>课后练习:{item.practice.title}</span>
                                                                        <i className='exam exam_open' />
                                                                    </Link>
                                                                }
                                                            </>
                                                        }
xuzhenghua committed
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
                                                    </ul>
                                                )
                                            })
                                        }
                                    </div>
                                )
                            })
                        }
                    </div>
                </Tabs>
                <WhiteSpace/>
            </div>
        );
    }

}

xuzhenghua committed
193
export default OutLine;