Commit 8ab7e646 by FE

price not show in video

parent d8ef06f0
...@@ -193,24 +193,24 @@ class Detail extends Component { ...@@ -193,24 +193,24 @@ class Detail extends Component {
// 判断支付是否成功 // 判断支付是否成功
check = (oid) => { check = (oid) => {
this.setState({
singMess: JSON.parse(window.localStorage.getItem('singMess'))
})
http.get(`${API['base-api']}/class_order_status/${oid}`).then((res) => { http.get(`${API['base-api']}/class_order_status/${oid}`).then((res) => {
if (Number(res.data.data.errno) === 200) { if (Number(res.data.data.errno) === 200) {
// 正常购买单集成功 // 正常购买单集成功
this.setState({ this.setState({
singleType: 6, singleType: 6
}) })
} else if (Number(res.data.data.errno) === 201) { } else if (Number(res.data.data.errno) === 201) {
// 0元参团 // 0元参团
this.setState({ this.setState({
singleType: 4, singleType: 4
}) })
} else if (Number(res.data.data.errno) === 202) { } else if (Number(res.data.data.errno) === 202) {
// 0元购 // 0元购
this.setState({ this.setState({
singleType: 3, singleType: 3
}) })
} else if (Number(res.data.data.errno) === 203) { } else if (Number(res.data.data.errno) === 203) {
// 三天内特价 // 三天内特价
...@@ -303,6 +303,7 @@ class Detail extends Component { ...@@ -303,6 +303,7 @@ class Detail extends Component {
singleType: 1, singleType: 1,
singMess: item singMess: item
}); });
window.localStorage.setItem('singMess', JSON.stringify(item))
} }
} }
...@@ -538,6 +539,7 @@ class Detail extends Component { ...@@ -538,6 +539,7 @@ class Detail extends Component {
boxHide={this.boxHide} boxHide={this.boxHide}
data={this.state.singMess} data={this.state.singMess}
singleType={singleType} singleType={singleType}
vcourseId={course_info.v_course_id}
videoId={this.state.singMess.video_id} videoId={this.state.singMess.video_id}
nowPrice={this.state.nowPrice} nowPrice={this.state.nowPrice}
laterPrice={this.state.laterPrice} laterPrice={this.state.laterPrice}
......
...@@ -172,7 +172,7 @@ class Single extends Component { ...@@ -172,7 +172,7 @@ class Single extends Component {
}, 1000) }, 1000)
} }
const { singleType } = this.props; const { singleType } = this.props;
console.log(this.state.singleBox); console.log(this.props);
return ( return (
<div className='popup-box'> <div className='popup-box'>
{ {
......
...@@ -145,6 +145,7 @@ class Video extends Component { ...@@ -145,6 +145,7 @@ class Video extends Component {
} }
// 购买单集 // 购买单集
toSingleset = (item) => { toSingleset = (item) => {
console.log(item);
this.setState({ this.setState({
singleBox: true, singleBox: true,
singMess: item singMess: item
...@@ -493,7 +494,8 @@ class Video extends Component { ...@@ -493,7 +494,8 @@ class Video extends Component {
this.countSchedule() this.countSchedule()
this.setState({ this.setState(
{
activeIndex: index activeIndex: index
}, },
() => { () => {
...@@ -501,9 +503,9 @@ class Video extends Component { ...@@ -501,9 +503,9 @@ class Video extends Component {
this.setPlayerSrc(this.state.videoList[index]['play_url']) this.setPlayerSrc(this.state.videoList[index]['play_url'])
this.sendLastRecord() this.sendLastRecord()
this.playVideo() this.playVideo()
}else {
this.getCoursePrice();
} }
} }
) )
} }
...@@ -513,26 +515,23 @@ class Video extends Component { ...@@ -513,26 +515,23 @@ class Video extends Component {
} }
getVideoList = () => { getVideoList = () => {
let url = '' let url = '';
if (getParam('video_id')) { if (getParam('video_id')) {
url = `${API.home}/m/course/play/${this.courseID + '?video_id=' + getParam('video_id')}` url = `${API.home}/m/course/play/${this.courseID + '?video_id=' + getParam('video_id')}`
} else { } else {
url = `${API.home}/m/course/play/${this.courseID}` url = `${API.home}/m/course/play/${this.courseID}`
} }
http.get(url) http.get(url).then(res => {
.then(res => { const { data={}, code } = res.data;
const data = res.data if (code === 200) {
if (data.code === 200) {
this.setState( this.setState(
state => ({ state => ({
videoList: data.data['lessons'], videoList: data['lessons'],
currentVideoSrc: data.data['lessons'][state.activeIndex]['play_url'], currentVideoSrc: data['lessons'][state.activeIndex]['play_url'],
course: data.data.course, course: data.course,
courseId: data.data.course['course_id'], courseId: data.course['course_id'],
vCourseId: data.data.course['v_course_id'], vCourseId: data.course['v_course_id'],
title: data.data.course['course_title'], title: data.course['course_title'],
isLoading: false isLoading: false
}), }),
this.playSetup this.playSetup
...@@ -540,19 +539,24 @@ class Video extends Component { ...@@ -540,19 +539,24 @@ class Video extends Component {
} else { } else {
Toast.info(data.msg) Toast.info(data.msg)
} }
}) }
)
} }
playSetup = () => { playSetup = () => {
if (this.state.course.is_aist) { // is_aist,是否AI特训营
this.setupWS() const { course={} } = this.state;
this.setupTimer() if (course.is_aist) {
this.setupWS();
this.setupTimer();
} }
let index = this.getLastVideoIndex(this.state.course.last_video_id) let index = this.getLastVideoIndex(course.last_video_id);
index = index >= 0 ? index : 0 index = index >= 0 ? index : 0;
this.setState({ this.setState(
{
activeIndex: index activeIndex: index
}, () => { },
() => {
if (this.lessonAvailable(index)) { if (this.lessonAvailable(index)) {
if (this.hasAuth(index)) { if (this.hasAuth(index)) {
Promise.resolve().then(() => { Promise.resolve().then(() => {
...@@ -570,7 +574,8 @@ class Video extends Component { ...@@ -570,7 +574,8 @@ class Video extends Component {
} }
}]) }])
} }
}) }
);
} }
...@@ -610,7 +615,8 @@ class Video extends Component { ...@@ -610,7 +615,8 @@ class Video extends Component {
} }
getCoursePrice = () => { getCoursePrice = () => {
http.get(`${API.home}/sys/course/price/${getParam('id')}`) const { course = {} } = this.state;
http.get(`${API.home}/sys/course/price/${course.course_id}`)
.then(res => { .then(res => {
const {data} = res const {data} = res
if (data.code === 200) { if (data.code === 200) {
...@@ -651,7 +657,8 @@ class Video extends Component { ...@@ -651,7 +657,8 @@ class Video extends Component {
render() { render() {
let {match, location} = this.props let {match, location} = this.props
const {videoList, activeIndex, isAuth, salePrice, course, singleBox, singleType} = this.state const {videoList, activeIndex, isAuth, salePrice, course, singleBox, singleType} = this.state;
console.log(course);
return ( return (
<div className='play'> <div className='play'>
<HeaderBar title={this.state.title} arrow={true}/> <HeaderBar title={this.state.title} arrow={true}/>
...@@ -665,13 +672,19 @@ class Video extends Component { ...@@ -665,13 +672,19 @@ class Video extends Component {
<div className="purchase-box"> <div className="purchase-box">
<div className='hint'>您尚未购买该课时,请购买后学习。</div> <div className='hint'>您尚未购买该课时,请购买后学习。</div>
<div className='btns'> <div className='btns'>
<button type='button' <button
type='button'
onClick={this.tobuy} onClick={this.tobuy}
className='purchase-class'>¥{salePrice} 购买课程 className='purchase-class'
>
¥{salePrice} 购买课程
</button> </button>
<button type='button' <button
type='button'
onClick={this.toSingleset.bind(this, videoList[activeIndex])} onClick={this.toSingleset.bind(this, videoList[activeIndex])}
className='purchase-episode'>¥{videoList.length && videoList[activeIndex]['class_price']} 购买单集 className='purchase-episode'
>
¥{videoList.length && videoList[activeIndex]['class_price']} 购买单集
</button> </button>
</div> </div>
</div> </div>
...@@ -705,7 +718,10 @@ class Video extends Component { ...@@ -705,7 +718,10 @@ class Video extends Component {
{/*单集购买*/} {/*单集购买*/}
{ {
singleBox && singleBox &&
<Single singleBox={this.state.singleBox} boxHide={this.boxHide} data={this.state.singMess} <Single
singleBox={this.state.singleBox}
boxHide={this.boxHide}
data={this.state.singMess}
singleType={this.state.singleType} singleType={this.state.singleType}
vcourseId={course.course_info.v_course_id} vcourseId={course.course_info.v_course_id}
videoId={this.state.singMess.video_id} videoId={this.state.singMess.video_id}
...@@ -731,13 +747,19 @@ class Video extends Component { ...@@ -731,13 +747,19 @@ class Video extends Component {
pathname: '/play/video', pathname: '/play/video',
search: location.search search: location.search
}}/> }}/>
<Route path={`${match.path}/video`} render={props => { <Route
return <VideoCatalog path={`${match.path}/video`}
render={props => {
return (
<VideoCatalog
activeIndex={this.state.activeIndex} activeIndex={this.state.activeIndex}
selectVideo={this.selectVideo} selectVideo={this.selectVideo}
videoCatalog={videoList} videoCatalog={videoList}
{...props}/> {...props}
}}/> />
);
}}
/>
<Route path={`${match.path}/datum`} render={props => { <Route path={`${match.path}/datum`} render={props => {
return <DatumCatalog {...props} datum={this.state.datum}/> return <DatumCatalog {...props} datum={this.state.datum}/>
}}/> }}/>
......
...@@ -17,10 +17,14 @@ class VideoCatalog extends Component { ...@@ -17,10 +17,14 @@ class VideoCatalog extends Component {
{ {
this.props.videoCatalog.map((item, index) => { this.props.videoCatalog.map((item, index) => {
return ( return (
<li key={item.id} <li
key={item.id}
className={classnames({active: this.props.activeIndex === index})} className={classnames({active: this.props.activeIndex === index})}
> >
<div className="video-title" onClick={this.handleClick.bind(this, index)}> <div
className="video-title"
onClick={this.handleClick.bind(this, index)}
>
<span className="title">{item.name}</span> <span className="title">{item.name}</span>
<span className='duration'>{item.duration}</span> <span className='duration'>{item.duration}</span>
<i className={classnames(`iconfont`, <i className={classnames(`iconfont`,
......
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