Commit 8ab7e646 by FE

price not show in video

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