Commit 354acf13 by zhanghaozhe

视频播放页

parent 24890872
...@@ -4,6 +4,7 @@ import Course from '@/common/course-base' ...@@ -4,6 +4,7 @@ import Course from '@/common/course-base'
import { http, api } from '@/utils' import { http, api } from '@/utils'
import { Toast } from "antd-mobile"; import { Toast } from "antd-mobile";
import classnames from 'classnames' import classnames from 'classnames'
import {isEmpty} from 'lodash'
import './free-courses.scss' import './free-courses.scss'
...@@ -40,7 +41,7 @@ class FreeCourse extends PureComponent { ...@@ -40,7 +41,7 @@ class FreeCourse extends PureComponent {
let data = res.data let data = res.data
if (data.code == 200) { if (data.code == 200) {
this.setState({ this.setState({
live: data.data live: isEmpty(data.data) ? [] : data.data
}) })
} else { } else {
Toast.info(data.msg, 2, null, false) Toast.info(data.msg, 2, null, false)
......
...@@ -22,7 +22,7 @@ class Video extends Component { ...@@ -22,7 +22,7 @@ class Video extends Component {
state = { state = {
title: '视频', title: '',
courseId: null, courseId: null,
video_catalog: [], video_catalog: [],
datum: [], datum: [],
...@@ -30,7 +30,8 @@ class Video extends Component { ...@@ -30,7 +30,8 @@ class Video extends Component {
activeIndex: 0, activeIndex: 0,
isAuth: true, isAuth: true,
course: null, course: null,
salePrice: null salePrice: null,
vCourseId: null
} }
...@@ -87,7 +88,9 @@ class Video extends Component { ...@@ -87,7 +88,9 @@ class Video extends Component {
video_catalog: data.data['lessons'], video_catalog: data.data['lessons'],
currentVideoSrc: data.data['lessons'][state.activeIndex]['play_url'], currentVideoSrc: data.data['lessons'][state.activeIndex]['play_url'],
course: data.data.course, course: data.data.course,
courseId: data.data.course['course_id'] courseId: data.data.course['course_id'],
vCourseId: data.data.course['v_course_id'],
title: data.data.course['course_title']
}), }),
() => { () => {
if (this.lessonAvailable()) { if (this.lessonAvailable()) {
...@@ -201,7 +204,7 @@ class Video extends Component { ...@@ -201,7 +204,7 @@ class Video extends Component {
const {video_catalog, activeIndex, isAuth, salePrice} = this.state const {video_catalog, activeIndex, isAuth, salePrice} = this.state
return ( return (
<div className='play'> <div className='play'>
<HeaderBar title={this.state.title}/> <HeaderBar title={this.state.title} arrow={true}/>
<div className="video"> <div className="video">
<video className={'video-js'} ref={el => this.video = el}> <video className={'video-js'} ref={el => this.video = el}>
<source src={'/'} type='application/x-mpegURL'/> <source src={'/'} type='application/x-mpegURL'/>
...@@ -251,7 +254,7 @@ class Video extends Component { ...@@ -251,7 +254,7 @@ class Video extends Component {
}}/> }}/>
</Switch> </Switch>
<Route render={props => { <Route render={props => {
return this.state.courseId ? <Recommendation {...props} courseId={this.state.courseId}/> return this.state.vCourseId ? <Recommendation {...props} vCourseId={this.state.vCourseId}/>
: null : null
}}/> }}/>
</div> </div>
......
...@@ -2,7 +2,7 @@ import React, { PureComponent } from 'react'; ...@@ -2,7 +2,7 @@ import React, { PureComponent } from 'react';
import './recommendation.scss' import './recommendation.scss'
import { http, api } from '@/utils' import { http, api } from '@/utils'
import { Toast } from "antd-mobile"; import { Toast } from "antd-mobile";
import {VList} from '@/common'; import VList from '@/common/v-list-base';
...@@ -29,12 +29,8 @@ class Recommendation extends PureComponent { ...@@ -29,12 +29,8 @@ class Recommendation extends PureComponent {
this.getRecommendation() this.getRecommendation()
} }
componentDidUpdate(prevProps, prevState) {
console.log(prevProps, this.props);
}
getRecommendation = () => { getRecommendation = () => {
http.get(`${api.home}/m/play/recommend_course/${this.props.courseId}?num=${this.state.num}`) http.get(`${api.home}/m/play/recommend_course/${this.props.vCourseId}?num=${this.state.num}`)
.then(res => { .then(res => {
const data = res.data const data = res.data
if(data.code === 200){ if(data.code === 200){
...@@ -51,7 +47,7 @@ class Recommendation extends PureComponent { ...@@ -51,7 +47,7 @@ class Recommendation extends PureComponent {
handleClick = id => { handleClick = id => {
console.log(id) this.props.history.push(`/detail?id=${id}`)
} }
render() { render() {
......
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