index.js 37.7 KB
Newer Older
xuzhenghua committed
1
import React, {Component} from 'react'
xuzhenghua committed
2
import './index.scss'
zhanghaozhe committed
3
import Bargain from './bargain'
xuzhenghua committed
4
import Group from './group'
xuzhenghua committed
5
import OutLine from './outline'
xuzhenghua committed
6
import {HeaderBar, CallApp} from '../../common'
xuzhenghua committed
7 8 9
import ShareRank from "./shareRank"
import Audition from "./audition"
import Single from "./single"
xuzhenghua committed
10
import SingleSuccess from './single/singleSuccess'
xuzhenghua committed
11
import BtnStatus from "./btnstatus"
2  
xuzhenghua committed
12
import Barrage from './barrage'
xuzhenghua committed
13
import Deposit from './deposit'
xuzhenghua committed
14 15 16 17 18 19 20 21 22
import {connect} from "react-redux"
import {getCourses, addCourseToCart} from "./actions"
import {getParam, http, browser, wxShare} from "@/utils"
import {Toast} from 'antd-mobile'
import {bindActionCreators} from "redux"
import {delCountryNum} from './../country/countryRedux'
import {Popup} from "@common/index"
import RedPacket from './redPacket'
import ExpandActiveToast from "../Index/expandActiveToast"
xuzhenghua committed
23
import {UserGift} from "@common"
FE committed
24

xuzhenghua committed
25
class Detail extends Component {
xuzhenghua committed
26

xuzhenghua committed
27
    courseId
zhanghaozhe committed
28

xuzhenghua committed
29 30 31 32 33 34
    constructor(props) {
        super(props)
        this.state = {
            isbuy: 0,
            isvip: 0,
            auditionBox: false,
zhanghaozhe committed
35

xuzhenghua committed
36 37
            singleBox: false,
            singleType: 1,
zhanghaozhe committed
38

xuzhenghua committed
39 40 41 42 43 44 45 46
            shareRank: false,
            singMess: '',
            barInfo: '',
            share: false,
            countdown: '00:00:00',
            outList: [],
            list: [],
            course: {},
zhanghaozhe committed
47

xuzhenghua committed
48 49 50 51
            nowPrice: 0,
            laterPrice: 0,
            isPdd: 0, // 是否是拼团课程 控制首次单集购买后的 全集购买 接口: 拼团课程走拼团接口,否则直接走购买接口
            isRedPacket: true,
zhanghaozhe committed
52

xuzhenghua committed
53 54
            countDownTime: '20s',
            isShowChannel: window.sessionStorage.getItem('isShowSiteWindowByChannel'),
xuzhenghua committed
55

xuzhenghua committed
56 57
            isShowUserGift: false
        }
zhanghaozhe committed
58
    }
FE committed
59

xuzhenghua committed
60 61 62 63 64 65 66 67 68 69 70 71
    componentDidMount() {
        this.fetchCourseInfo()
        const {location: {state = {}}} = this.props
        if (state.oid) {
            this.check(state.oid)
        }
        if (getParam('is_class') === 1 || getParam('weixinpay')) {
            this.payCallback()
        }
        if (browser.isWeixin) {
            this.isweixinPay()
        }
xuzhenghua committed
72

xuzhenghua committed
73 74 75 76 77 78 79 80
        this.judgeIsRedPacket()

        // 红包链接进入详情也
        if (getParam('share_code')) {
            this.setState({
                isRedPacket: true
            })
        }
xuzhenghua committed
81

xuzhenghua committed
82 83 84
        if (getParam('ac') && Number(getParam('ac')) === 11) {
            this.getBorwerCourse()
        }
xuzhenghua committed
85 86 87 88

        this.userStatus()
    }

xuzhenghua committed
89
    componentWillMount() {
xuzhenghua committed
90
        this.showUserGiftFun()
xuzhenghua committed
91
    }
xuzhenghua committed
92 93 94 95 96 97 98

    userStatus = () => {
        http.get(`${API['base-api']}/sys/user/new_user_status`).then((res) => {
            const {errno, data} = res.data
            if (errno === 0) {
                if (data.status == 1) {
                    // 新用户登录之后判断是否是新用户
xuzhenghua committed
99 100 101
                    this.setState({
                        isShowUserGift: false
                    })
xuzhenghua committed
102
                    Toast.info('新人大礼包已领取成功!', 2)
xuzhenghua committed
103 104 105 106
                } else {
                    this.setState({
                        isShowUserGift: false
                    })
xuzhenghua committed
107 108 109
                }
            }
        })
xuzhenghua committed
110
    }
xuzhenghua committed
111 112 113 114 115 116 117 118

    showUserGiftFun = () => {
        let newer_last_time = localStorage.getItem('newer_last_time') // 获取用户关闭大礼包的时间
        let now_time = (new Date()).valueOf()
        if (!newer_last_time || now_time - newer_last_time > 86400000) {
            this.setState({
                isShowUserGift: true
            })
zhanghaozhe committed
119
        } else {
xuzhenghua committed
120 121 122
            this.setState({
                isShowUserGift: false
            })
zhanghaozhe committed
123
        }
xuzhenghua committed
124 125
    }
    close = () => {
zhanghaozhe committed
126
        this.setState({
xuzhenghua committed
127 128 129 130 131
            isShowUserGift: false
        })
        let now_time = (new Date()).valueOf() // 获取当前时间
        localStorage.setItem('newer_last_time', now_time)  // 存储关闭时间
    }
xuzhenghua committed
132
    get_newerModal = () => {
xuzhenghua committed
133 134 135
        this.close()
        this.props.history.push('/passport/login')
    }
xuzhenghua committed
136

xuzhenghua committed
137 138 139 140 141 142 143 144 145 146 147 148 149 150
    getBorwerCourse = () => {
        http.get(`${API.home}/sys/user/blessing`, {type: 4, course_id: getParam('id')}).then(res => {
            let {code, data: {today_browsed_courses}} = res.data
            if (code === 200) {
                let currentCourseId = getParam('id')
                if (today_browsed_courses.includes(Number(currentCourseId))) {
                    this.setState({
                        countDownTime: '任务完成'
                    })
                } else {
                    this.startActivity()
                }
            }
        })
zhanghaozhe committed
151
    }
xuzhenghua committed
152 153 154 155 156 157 158

    startActivity = () => {
        let _this = this
        let countDownInterval = setInterval(function () {
            let countDown = parseInt(_this.state.countDownTime)
            countDown--
            if (countDown > 0) {
zhanghaozhe committed
159
                _this.setState({
xuzhenghua committed
160
                    countDownTime: countDown + 's'
zhanghaozhe committed
161
                })
xuzhenghua committed
162 163 164 165 166 167 168 169 170 171
            } else if (countDown === 0) {
                clearInterval(countDownInterval)
                countDownInterval = null
                http.post(`${API.home}/sys/add/blessing`, {type: 4, course_id: getParam('id')}).then(res => {
                    let {code} = res.data
                    if (code === 200) {
                        _this.setState({
                            countDownTime: '任务完成'
                        })
                    }
zhanghaozhe committed
172
                })
xuzhenghua committed
173 174 175 176 177 178 179 180 181 182 183
            }
        }, 1000)
    }

    // 判断时候未红包课程
    judgeIsRedPacket = () => {
        http.get(`${API.home}/sys/redPacket/showShareActive/${getParam('id')}`).then(res => {
            const {code, data} = res.data
            if (code === 200) {
                this.setState({
                    isRedPacket: data.is_show
zhanghaozhe committed
184
                })
xuzhenghua committed
185
            }
FE committed
186
        })
wangshuo committed
187
    }
xuzhenghua committed
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209

    componentDidUpdate(prevProps) {
        if (prevProps.user.hasError !== this.props.user.hasError) {
            this.fetchCourseInfo()
        }
    }

    payCallback = () => {
        const _this = this
        if (!getParam('oid')) {
            return
        } else {
            this.setState({
                singMess: JSON.parse(window.localStorage.getItem('singMess'))
            })
            _this.intervalPayStatus = setInterval(function () {
                http.get(`${API['base-api']}/m/orderState/oid/${getParam('oid')}`).then(res => {
                    if (res.data.errno === 401) {
                        clearInterval(_this.intervalPayStatus)
                        _this.intervalPayStatus = null
                        // 获取课程类型
                        http.get(`${API['base-api']}/class_order_status/${getParam('oid')}`).then((res) => {
wangshuo committed
210
                            if (Number(res.data.data.errno) === 200) {
xuzhenghua committed
211 212 213 214
                                // 正常购买单集成功
                                _this.setState({
                                    singleType: 6,
                                })
wangshuo committed
215
                            } else if (Number(res.data.data.errno) === 201) {
xuzhenghua committed
216 217 218 219
                                // 0元参团
                                _this.setState({
                                    singleType: 4,
                                })
wangshuo committed
220
                            } else if (Number(res.data.data.errno) === 202) {
xuzhenghua committed
221 222 223 224
                                // 0元购
                                _this.setState({
                                    singleType: 3,
                                })
wangshuo committed
225
                            } else if (Number(res.data.data.errno) === 203) {
xuzhenghua committed
226 227 228 229 230 231 232
                                // 三天内特价
                                _this.setState({
                                    nowPrice: res.data.data.data.now_price,
                                    laterPrice: res.data.data.data.three_day_later_price,
                                    singleType: 2,
                                    isPdd: res.data.data.data.is_pdd,
                                })
wangshuo committed
233
                            } else {
xuzhenghua committed
234
                                Toast.info(res.data.data.msg, 2)
wangshuo committed
235
                            }
xuzhenghua committed
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311
                        })
                    }
                })
            }, 1000)
        }
    }
    isweixinPay = () => {
        let _this = this
        let weixin_code = getParam('code')
        if (weixin_code) {
            if (!getParam('oid')) {
                return
            } else {
                // this.props.weixinPay(weixin_code)
                this.setState({
                    singMess: JSON.parse(window.localStorage.getItem('singMess'))
                })
                http.get(`${API['base-api']}/pay/wxpay/pub_charge/oid/${getParam('oid')}/code/${weixin_code}`).then((res) => {
                    if (res.data.errno === 0) {
                        const data = res.data.data

                        function onBridgeReady() {
                            WeixinJSBridge.invoke(
                                'getBrandWCPayRequest', {
                                    "appId": data.appId,                //公众号名称,由商户传入
                                    "timeStamp": data.timeStamp,        //时间戳,自1970年以来的秒数
                                    "nonceStr": data.nonceStr,          //随机串
                                    "package": data.package,
                                    "signType": data.signType,          //微信签名方式:
                                    "paySign": data.paySign             //微信签名
                                },
                                function (res) {
                                    if (res.err_msg == "get_brand_wcpay_request:ok") {
                                        Toast.info('支付成功', 2)
                                        _this.intervalPayStatus = setInterval(function () {
                                            http.get(`${API['base-api']}/m/orderState/oid/${getParam('oid')}`).then(res => {
                                                if (res.data.errno === 401) {
                                                    clearInterval(_this.intervalPayStatus)
                                                    _this.intervalPayStatus = null
                                                    // 获取课程类型
                                                    http.get(`${API['base-api']}/class_order_status/${getParam('oid')}`).then((res) => {
                                                        if (Number(res.data.data.errno) === 200) {
                                                            // 正常购买单集成功
                                                            _this.setState({
                                                                singleType: 6,
                                                            })
                                                        } else if (Number(res.data.data.errno) === 201) {
                                                            // 0元参团
                                                            _this.setState({
                                                                singleType: 4,
                                                            })
                                                        } else if (Number(res.data.data.errno) === 202) {
                                                            // 0元购
                                                            _this.setState({
                                                                singleType: 3,
                                                            })
                                                        } else if (Number(res.data.data.errno) === 203) {
                                                            // 三天内特价
                                                            _this.setState({
                                                                nowPrice: res.data.data.data.now_price,
                                                                laterPrice: res.data.data.data.three_day_later_price,
                                                                singleType: 2,
                                                                isPdd: res.data.data.data.is_pdd,
                                                            })
                                                        } else {
                                                            Toast.info(res.data.data.msg, 2)
                                                        }
                                                    })
                                                }
                                            })
                                        }, 1000)
                                    } else {
                                        alert('支付失败')
                                    }
                                }
                            )
wangshuo committed
312
                        }
2  
xuzhenghua committed
313

xuzhenghua committed
314 315 316 317 318 319 320 321 322 323 324 325 326 327
                        if (typeof WeixinJSBridge == "undefined") {
                            if (document.addEventListener) {
                                document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false)
                            } else if (document.attachEvent) {
                                document.attachEvent('WeixinJSBridgeReady', onBridgeReady)
                                document.attachEvent('onWeixinJSBridgeReady', onBridgeReady)
                            }
                        } else {
                            onBridgeReady()
                        }
                    } else {
                        Toast.info(res.data.msg, 2)
                    }
                })
wangshuo committed
328
            }
xuzhenghua committed
329
        }
FE committed
330
    }
zhanghaozhe committed
331

xuzhenghua committed
332 333
    // 判断支付是否成功
    check = (oid) => {
zhanghaozhe committed
334
        this.setState({
xuzhenghua committed
335
            singMess: JSON.parse(window.localStorage.getItem('singMess'))
zhanghaozhe committed
336
        })
xuzhenghua committed
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359
        http.get(`${API['base-api']}/class_order_status/${oid}`).then((res) => {
            if (Number(res.data.data.errno) === 200) {
                // 正常购买单集成功
                this.setState({
                    singleType: 6
                })
            } else if (Number(res.data.data.errno) === 201) {
                // 0元参团
                this.setState({
                    singleType: 4
                })
            } else if (Number(res.data.data.errno) === 202) {
                // 0元购
                this.setState({
                    singleType: 3
                })
            } else if (Number(res.data.data.errno) === 203) {
                // 三天内特价
                this.setState({
                    nowPrice: res.data.data.data.now_price,
                    laterPrice: res.data.data.data.three_day_later_price,
                    singleType: 2,
                    isPdd: res.data.data.data.is_pdd,
xuzhenghua committed
360

xuzhenghua committed
361 362 363 364
                })
            } else {
                Toast.info(res.data.data.msg, 2)
            }
FE committed
365
        })
366
    }
xuzhenghua committed
367 368 369 370 371 372 373 374 375 376 377 378 379

    payCallBack = (singleType, nowPrice, laterPrice) => {
        const _this = this
        if (singleType === 2) {
            _this.setState({
                singleType,
                nowPrice,
                laterPrice
            })
        } else {
            _this.setState({
                singleType,
            })
wangshuo committed
380
        }
xuzhenghua committed
381 382 383 384 385 386 387 388 389
    }
    fetchCourseInfo = () => {
        const id = getParam('id')
        http.get(`${API.home}/m/course/detail/${id}`).then((res) => {
            const {data, code} = res.data
            if (code === 200) {
                if (data['redirect_url'] !== '') {
                    window.location.href = data['redirect_url']
                }
390
                this.setState({
xuzhenghua committed
391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415
                    course: data
                })
                if (data.course_info) {
                    const mode = data.course_info.mode

                    if (mode) {
                        const {history} = this.props
                        /*
                        * mode: 课程模式 1集训营2普通小课3就业班4VIP 5AI特训营 6图文小课-python 7图文小课-ML
                        * */
                        const route = {
                            6: 'python',
                            7: 'ml'
                        }
                        if (Object.keys(route).includes(mode)) {
                            history.push(`${route[mode]}?id=${id}`)
                        }
                    }

                    let course_info = data.course_info
                    document.title = `${course_info.course_title} - 七月在线`
                    if (course_info.group_status === 3 || course_info.group_status === 4) {
                        let endTime = course_info.pdd_group_info.groupon_member.end_time
                        if (endTime && endTime > 0) {
                            let date = endTime * 1000,
xuzhenghua committed
416
                                day = 0,
xuzhenghua committed
417 418 419 420 421
                                hours = 0,
                                minutes = 0,
                                seconds = 0
                            setInterval(() => {
                                date -= 1000
xuzhenghua committed
422 423 424 425
                                if (endTime > 86400) {
                                    day = `${parseInt(date / (3600000 * 24))}`.padStart(2, 0)
                                    hours = `${parseInt((date - day * 3600000 * 24) / 3600000)}`.padStart(2, 0)
                                    minutes = `${parseInt((date - day * 3600000 * 24 - hours * 3600000) / 60000)}`.padStart(2, 0)
xuzhenghua committed
426 427
                                    // seconds = `${parseInt((date - day * 3600000 * 24 - hours * 3600000 - minutes * 60000) / 1000)}`.padStart(2, 0);

xuzhenghua committed
428 429 430 431 432 433 434 435 436 437 438
                                    this.setState({
                                        countdown: `${day}:${hours}:${minutes}`
                                    })
                                } else {
                                    hours = `${parseInt(date / (60 * 60 * 1000))}`.padStart(2, 0)
                                    minutes = `${parseInt((date - hours * 3600000) / 60000)}`.padStart(2, 0)
                                    seconds = `${parseInt((date - hours * 3600000 - minutes * 60000) / 1000)}`.padStart(2, 0)
                                    this.setState({
                                        countdown: `${hours}:${minutes}:${seconds}`
                                    })
                                }
xuzhenghua committed
439 440 441 442 443 444 445 446 447 448 449
                            }, 1000)
                        }
                    }
                    wxShare({
                        title: course_info.course_title,
                        desc: course_info.index_description,
                        link: encodeURI(location.origin + '/detail?id=' + getParam('id')),
                        imgUrl: course_info.image_name
                    })
                }

450
            }
xuzhenghua committed
451 452
        })
    }
xuzhenghua committed
453

xuzhenghua committed
454 455 456 457 458 459
    // 点击子组件试听按钮
    toAudition = (vCourseId, videoId) => {
        const {user} = this.props
        const uid = user && user.data && user.data.uid
        if (!uid) {
            this.props.history.push('/passport/login')
xuzhenghua committed
460
        } else {
xuzhenghua committed
461 462 463 464 465 466 467 468 469 470 471 472 473
            if (videoId == '' || videoId == 0 || videoId == undefined) {
                return false
            }
            http.post(`${API['base-api']}/sys/get_class_audition?video_id=${videoId}`).then((res) => {
                if (res.data.errno == 200) {
                    this.props.history.push(`/play/video?id=${vCourseId + '&video_id=' + videoId}`)
                } else {
                    Toast.info(res.data.msg, 2)
                }
            })
            // this.setState({
            //     auditionBox: true,
            // })
xuzhenghua committed
474
        }
zhanghaozhe committed
475
    }
xuzhenghua committed
476 477 478 479 480 481
    // 点击子组件单集购买按钮
    toSingleset = (item) => {
        const {user} = this.props
        const uid = user && user.data && user.data.uid
        if (!uid) {
            this.props.history.push('/passport/login')
xuzhenghua committed
482
        } else {
xuzhenghua committed
483 484 485 486 487 488
            this.setState({
                singleBox: true,
                singleType: 1,
                singMess: item
            })
            window.localStorage.setItem('singMess', JSON.stringify(item))
xuzhenghua committed
489
        }
xuzhenghua committed
490 491
    }

xuzhenghua committed
492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534
    // 加入购物车 type:1 加入购物车,2加入购物车并跳转到购物车页面去支付
    toCart = (type) => {
        const {history, addCourseToCart} = this.props
        let data = {
            course_id: getParam('id')
        }
        http.post(`${API.home}/m/cart/add`, data).then((res) => {
            if (res.data.code === 200) {
                if (type === 1) {
                    Toast.info('已加入购物车', 2)
                    // this.props.getCourses()
                    // document.location.reload()
                    addCourseToCart()
                    this.fetchCourseInfo()
                } else {
                    history.replace('/shopcart')
                }
            } else if (res.data.code === 15001) {
                history.replace('/shopcart')
            } else if (res.data.code === 4030) {
                history.replace('/passport')
            } else {
                Toast.info(res.data.msg, 2)
            }
        })
    }

    invitedFriends = () => {
        // const {course_title, image_name, course_id, pdd_group_info, pdd_group_info: {groupon_member, groupon_member: {number}, price}} = this.state.course.course_info;
        // if (browser.isWeixin) {
        //     wxShare({
        //         title: `【仅剩${number}个名额】我${price}元拼了《${course_title}》`,
        //         desc: course_title,
        //         link: location.href,
        //         imgUrl: image_name,
        //     });
        // } else {
        //     Toast.info('请在微信中使用分享功能!', 2);
        // }
        const {history} = this.props
        const {course = {}} = this.state
        if (course.course_info && course.course_info.self_oid) {
            history.push(`/togroup?id=${course.course_info.self_oid}`)
zhanghaozhe committed
535
        }
xuzhenghua committed
536
    }
wangshuo committed
537

xuzhenghua committed
538 539 540 541 542 543 544 545 546
    // 自组件传给父组件的boxHide
    boxHide = (val) => {
        this.setState({
            auditionBox: val,
            singleBox: val,
            singleType: 1
        })
        this.props.history.push(`/detail?id=${getParam('id')}`)
    }
FE committed
547

xuzhenghua committed
548 549 550 551 552
    formatTime = seconds => ({
        d: Math.floor(seconds / 60 / 60 / 24).toString().padStart(2, '0'),
        h: Math.floor(seconds / 60 / 60 % 24).toString().padStart(2, '0'),
        m: Math.floor(seconds / 60 % 60).toString().padStart(2, '0')
    })
xuzhenghua committed
553

xuzhenghua committed
554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584
    getCourse = (courseId, vCourseId) => {
        const {history} = this.props
        http.post(`${API.home}/sys/limitFree/receive`, {
            course_id: courseId
        })
            .then(res => {
                const {code, msg} = res.data
                if (code === 200) {

                    const instance = Popup({
                        className: 'get-course-popup',
                        closable: false,
                        clickMaskClose: false,
                        title: <div>
                            <img src="https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/time_limited_free/M/check.png"
                                 alt=""/>
                            <div>课程有效期7天,快去学习吧~</div>
                        </div>,
                        content: <div className={'btns'}>
                            <button onClick={() => {
                                instance.close()
                                this.fetchCourseInfo()
                            }}>知道了
                            </button>
                            <button onClick={() => {
                                history.push(`/play/video?id=${vCourseId}`)
                                instance.close()
                            }}>立即学习
                            </button>
                        </div>
                    })
xuzhenghua committed
585

xuzhenghua committed
586 587 588 589
                } else {
                    Toast.info(msg, 2, null, false)
                }
            })
zhanghaozhe committed
590

zhanghaozhe committed
591
    }
xuzhenghua committed
592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607


    render() {
        const {course: {course_info = {}}, barInfo, singleBox, singleType, isRedPacket, countDownTime} = this.state

        const {d, h, m} = this.formatTime(course_info.limit_free_time)

        let courseInfo = '',
            service = '',
            number = 0,
            endTime = 0
        // if (this.props.courseInfo.course_info) {
        //     courseInfo = this.props.courseInfo.course_info;
        //     service = courseInfo.service;
        if (course_info.group_status === 3 || course_info.group_status === 4) {
            number = course_info.pdd_group_info.groupon_member.number
608
        }
xuzhenghua committed
609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624
        // }
        const {share, countdown, list, outList} = this.state
        let href = ''
        const {location: {state = {}}} = this.props
        if (state.to && state.to === 'classify') {
            href = '/classify'
        }
        if (state.oid) {
            href = '/classify'
        }
        if (getParam('dist_code')) {
            href = '/'
        }
        let isCent = course_info.pdd_group_info && course_info.pdd_group_info.price != '0.01'
        return (
            <div>
zhanghaozhe committed
625
                {
xuzhenghua committed
626 627 628 629
                    Number(getParam('ac')) === 11 ? (
                        <div className='activity__blessing'>
                            <img src='https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/active19_1111/m/count_donw.png'/>
                            <span className='count__down__time'>{`${countDownTime}`}</span>
2  
xuzhenghua committed
630
                        </div>
xuzhenghua committed
631
                    ) : (null)
zhanghaozhe committed
632
                }
xuzhenghua committed
633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648
                <div className='detail-box'>
                    <HeaderBar
                        title='课程详情'
                        arrow={true}
                        cart={true}
                        toHref={href}
                    />

                    <ExpandActiveToast/>


                    {
                        this.state.isShowChannel == 1 &&
                        <CallApp className='toapp' path={`/detail/id=${getParam('id')}`}/>
                    }

649

xuzhenghua committed
650 651
                    {/*弹幕*/}
                    <Barrage isShow={course_info.is_show}/>
xuzhenghua committed
652

xuzhenghua committed
653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701
                    {/*课程*/}
                    <div className='course-content'>
                        <div className='cover'>
                            <img src={course_info.image_name} alt=""/>
                            {
                                course_info.is_aist &&
                                <span className='return_cash'/>
                            }
                        </div>
                        <div className="info">
                            <p className='title'>{course_info.course_title}</p>
                            <p className='contact text-overflow-2'>{course_info.simpledescription}</p>
                            <div className='des'>
                                {
                                    course_info.is_baoming === 0 && !course_info.is_limit_free &&
                                    <p className="course-price">
                                        <span className="new">¥{course_info.price1}</span>
                                        <span className="old">¥{course_info.price0}</span>
                                    </p>
                                }
                                {
                                    !!course_info.is_deposit && course_info.is_deposit != 0 &&
                                    <div className="openExpand">
                                        支付定金¥{course_info.deposit_info.deposit_amount},可抵扣¥{course_info.deposit_info.deduction_amount}
                                    </div>
                                }
                                {
                                    course_info.is_limit_free
                                        ?
                                        course_info.limit_free_status == 0
                                            ? <div className="limit-free">
                                                <span>限时免费</span>
                                                <span className={'origin-price'}>¥{course_info.price0}</span>
                                            </div>
                                            :
                                            course_info.limit_free_status == 1
                                                ? <div className={'time-limit'}>
                                                    <span>有效期7天,{d}{h}{m}分后过期</span>
                                                </div>
                                                : null
                                        : null
                                }
                            </div>
                        </div>
                    </div>

                    {/*正常课程已购买时显示*/}

                    {/*
xuzhenghua committed
702 703 704 705 706 707 708 709 710
                    没有权限:不显示
                    vip及赠课:显示黄的
                    不在vip范围内,单独购买:显示蓝的
                    单独买了课然后买了vip:显示蓝的

                    vip_range是vip里买的课,而且买了vip才会返回时间
                    is_pay 1是单独购买 0是买vip赠的
                    is_vip 1是属于vip赠的 0是不在vip范围内的
                    */}
xuzhenghua committed
711 712 713 714 715 716 717 718 719 720 721 722
                    {
                        !(course_info.is_limit_free && course_info.limit_free_status == 1) && course_info.is_baoming === 1 && course_info.is_pay == 1 && course_info.contact_type == 1 && course_info.course_qq &&
                        <div className='group'>
                            上课QQ群:{course_info.course_qq},加群请备注您的学号:{course_info.uid}
                        </div>
                    }
                    {
                        !(course_info.is_limit_free && course_info.limit_free_status == 1) && course_info.is_baoming === 1 && course_info.is_pay == 1 && course_info.contact_type == 2 && course_info.course_qq &&
                        <div className='group'>
                            请添加班主任微信:{course_info.course_qq},添加时备注学号:{course_info.uid}
                        </div>
                    }
xuzhenghua committed
723 724


xuzhenghua committed
725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836
                    {/*vip课程显示*/}
                    {
                        course_info.vip_range && course_info.is_vip == 1 && course_info.is_pay == 0 && course_info.contact_type == 1 && course_info.course_qq &&
                        <div className="vip">
                            <p>已开通年会员:{course_info.vip_range}</p>
                            <p>上课QQ群:{course_info.course_qq},加群请备注您的学号:{course_info.uid}</p>
                        </div>
                    }
                    {
                        course_info.vip_range && course_info.is_vip == 1 && course_info.is_pay == 0 && course_info.contact_type == 2 && course_info.course_qq &&
                        <div className="vip">
                            <p>已开通年会员:{course_info.vip_range}</p>
                            <p>请添加班主任微信:{course_info.course_qq},添加时备注学号:{course_info.uid}</p>
                        </div>
                    }


                    {/*定金相关信息*/}
                    {
                        !!course_info.is_deposit && course_info.is_deposit != 0 &&
                        <Deposit courseInfo={course_info}/>
                    }


                    {/*服务承诺*/}
                    <div className='promise'>
                        <label>服务承诺</label>
                        <p>
                            {
                                course_info.service && course_info.service.length > 0 && course_info.service.map((item, index) => {
                                    return (
                                        <span key={index}> {item} </span>
                                    )
                                })
                            }
                        </p>
                    </div>


                    {/*试听弹窗*/}
                    <Audition auditionBox={this.state.auditionBox} boxHide={this.boxHide}/>

                    {/*单集购买弹窗*/}
                    {
                        singleBox &&
                        <Single
                            singleType={this.state.singleType}
                            singleBox={this.state.singleBox}
                            boxHide={this.boxHide}
                            data={this.state.singMess}
                            vcourseId={course_info.v_course_id}
                            videoId={this.state.singMess.video_id}
                            title={course_info.course_title}
                            check={this.check}
                            courseId={course_info.course_id}
                        />
                    }

                    {/* 单集购买成功弹窗 */}
                    {
                        singleType !== 1 &&
                        <SingleSuccess
                            boxHide={this.boxHide}
                            data={this.state.singMess}
                            singleType={singleType}
                            vcourseId={course_info.v_course_id}
                            videoId={this.state.singMess.video_id}
                            nowPrice={this.state.nowPrice}
                            isPdd={this.state.isPdd}
                            laterPrice={this.state.laterPrice}
                            courseId={course_info.course_id}
                        />
                    }
                    {/*payCallback={this.payCallback}*/}
                    {/*weixinPay = {this.weixinPay}*/}

                    {/* 红包 */}
                    {
                        isRedPacket &&
                        <RedPacket
                            history={this.props.history}
                            country={this.props.country}
                            delCountryNum={this.props.delCountryNum}
                            userInfo={this.props.user.data}
                        />
                    }

                    {/*分享赚钱*/}
                    {
                        course_info.is_dist &&
                        <ShareRank courseInfo={course_info}/>
                    }

                    {/**
                     * 拼团
                     * is_aist: 是否AI特训营
                     * group_status: 团状态,3:课程有小团 用户没参加小团;4:用户参加了小团
                     * 拼团价格为1分钱时,不允许参团
                     */
                    }
                    {/*双十一期间不需要显示 不要删除*/}
                    {
                        isCent && !course_info.is_aist && (course_info.group_status === 3 || course_info.group_status === 4) &&
                        <Group
                            courseInfo={course_info}
                            history={this.props.history}
                            countdown={countdown}
                            invitedFriends={this.invitedFriends}
                        />
                    }

                    {/*
FE committed
837 838 839 840 841
                      * 砍价
                      * is_baoming 否报名 0-未购买弹出报名 1-已购买弹出开始学习
                      * is_dist 是否分销课程
                      * is_bargain 是否砍价课程
                      */}
xuzhenghua committed
842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889
                    {
                        course_info.is_baoming === 0 && (!course_info.is_aist) && course_info.is_bargain &&
                        <Bargain
                            country={this.props.country}
                            delCountryNum={this.props.delCountryNum}
                        />
                    }

                    {/*课程介绍、大纲*/}
                    <OutLine
                        data={course_info}
                        toAudition={this.toAudition}
                        toSingleset={this.toSingleset}
                    />

                    {/*课程按钮*/}
                    {
                        course_info &&
                        <BtnStatus
                            country={this.props.country}
                            countdown={countdown}
                            data={course_info}
                            user={this.props.user}
                            invitedFriends={this.invitedFriends}
                            getCourse={this.getCourse}
                            // addCourseToCart={this.props.addCourseToCart}
                            toCart={this.toCart}
                            history={this.props.history}
                        />
                    }

                    {
                        share ? (
                            <div
                                className='groupSuccessMbc'
                                onClick={() => {
                                    this.setState({share: false})
                                }}
                            >
                                <div className='tipContent'>
                                    {`还差${number}人,分享到3个群,成团率高达98%`}
                                </div>
                                <div className='tipArrow'>
                                    <i className='iconfont iconyindao'/>
                                </div>
                            </div>
                        ) : null
                    }
zhanghaozhe committed
890
                </div>
xuzhenghua committed
891

xuzhenghua committed
892 893
                {
                    this.state.isShowUserGift &&
xuzhenghua committed
894
                    <UserGift close={this.close} get_newerModal={this.get_newerModal}/>
xuzhenghua committed
895 896 897 898
                }
            </div>
        )
    }
xuzhenghua committed
899 900 901

}

902
const mapStateToProps = (state) => {
xuzhenghua committed
903 904 905 906 907 908 909
    return {
        // courseInfo: state.courseInfo,
        user: {
            ...state.user
        },
        country: state.country
    }
910
}
xuzhenghua committed
911

912 913 914 915
// const mapDispatchToProps = {
//     fetchCoursesListIfNeeded
// }
const mapDispatchToProps = (dispatch) => {
xuzhenghua committed
916 917 918 919 920 921 922 923
    return bindActionCreators(
        {
            getCourses,
            addCourseToCart,
            delCountryNum
        },
        dispatch
    )
xuzhenghua committed
924
}
xuzhenghua committed
925

926

xuzhenghua committed
927
export default connect(mapStateToProps, mapDispatchToProps)(Detail)