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

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

2  
xuzhenghua committed
18 19 20 21 22
    componentDidMount() {
        this.getList()
    }


xuzhenghua committed
23
    htmlDecode = (content) => {
2  
xuzhenghua committed
24 25 26 27 28 29
        if (content) {
            content = content.replace(/&lt;/g, '<');
            content = content.replace(/&gt;/g, '>');
            content = content.replace(/&amp;gt;/g, '');
            content = content.replace(/&quot;/g, '"');
            content = content.replace(/&amp;nbsp;/g, '');
wangshuo committed
30 31
        }
        return content;
xuzhenghua committed
32 33
    }

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

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

2  
xuzhenghua committed
125 126 127 128 129 130
                                                                {
                                                                    // 返现课程 是返现课程  未开课 已开课   是返现课程  未开课  已开课  已练习
                                                                    introduce.is_aist && item.is_open && introduce.is_baoming === 1 &&
                                                                    <Link
                                                                        to={`/play/video?id=${introduce.v_course_id + '&video_id=' + item.video_id}`}
                                                                        className='aist aist_open'></Link>
xuzhenghua committed
131

2  
xuzhenghua committed
132
                                                                }
xuzhenghua committed
133

2  
xuzhenghua committed
134 135 136
                                                                {
                                                                    // 返现课程 是返现课程  未开课 已开课   是返现课程  未开课  已开课  已练习
                                                                    introduce.is_aist && (!item.is_open || introduce.is_baoming === 0) &&
zhanghaozhe committed
137

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

2  
xuzhenghua committed
156 157 158 159
                                                                    return (
                                                                        <li className='points text-overflow-1'
                                                                            key={index}>{type}{item.name}</li>
                                                                    )
xuzhenghua committed
160

2  
xuzhenghua committed
161 162 163 164 165 166 167
                                                                })
                                                            }
                                                            {
                                                                <>
                                                                    {
                                                                        introduce.is_aist && item.practice.title !== "" && (!item.is_open || introduce.is_baoming === 0) &&
                                                                        <span className='camp camp_test' key={index}>
xuzhenghua committed
168
                                                                        <span>课后练习:{item.practice.title}</span>
2  
xuzhenghua committed
169
                                                                        <i className='exam exam_close'/>
xuzhenghua committed
170
                                                                    </span>
2  
xuzhenghua committed
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205
                                                                    }
                                                                    {
                                                                        introduce.is_aist && item.practice.title !== "" && item.is_open && introduce.is_baoming === 1 && !item.practice.is_tested &&
                                                                        <Link to={{
                                                                            pathname: `/campTest`,
                                                                            search: `?keshi_id=${item.video_id}&qid=${item.practice.qid}`,
                                                                            state: {from: `/detail${window.location.search}`}
                                                                        }} className='camp camp_test' key={index}>
                                                                            <span>课后练习:{item.practice.title}</span>
                                                                        </Link>
                                                                    }
                                                                    {
                                                                        introduce.is_aist && item.practice.title !== "" && item.is_open && introduce.is_baoming === 1 && item.practice.is_tested &&
                                                                        <Link to={{
                                                                            pathname: `/campResolve`,
                                                                            search: `?keshi_id=${item.video_id}&qid=${item.practice.qid}`,
                                                                            state: {from: `/detail${window.location.search}`}
                                                                        }} className='camp camp_test' key={index}>
                                                                            <span>课后练习:{item.practice.title}</span>
                                                                            <i className='exam exam_open'/>
                                                                        </Link>
                                                                    }
                                                                </>
                                                            }
                                                        </ul>
                                                    )
                                                })
                                            }
                                        </div>
                                    )
                                })
                            }
                        </div>
                    </Tabs>
                </StickyContainer>
xuzhenghua committed
206 207 208 209 210 211 212
                <WhiteSpace/>
            </div>
        );
    }

}

xuzhenghua committed
213
export default OutLine;