Commit bbade3c8 by FE

Merge branch 'pre' of gitlab.julyedu.com:baiguangyao/mr-julyedu into pre

parents 96e4a556 e1002955
......@@ -88,7 +88,7 @@ class Video extends Component {
currentVideoSrc: '',
activeIndex: 0,
isAuth: true,
course: {},
course: {}, // course.course_id 为 0 或 '' 时 为免费课程
salePrice: null,
vCourseId: null,
isLoading: true,
......@@ -369,9 +369,6 @@ class Video extends Component {
this.ws = new WebSocket(API["process-api"]);
this.ws.addEventListener('error', () => {
this.ws = null
/*setTimeout(() => {
this.setupWS();
}, 1000)*/
})
this.ws.addEventListener('close', () => {
if (this.reconnect) {
......@@ -403,21 +400,53 @@ class Video extends Component {
})
}
//告诉服务端切换视频
//告诉服务端计算进度 普通课程不发送
countSchedule = () => {
const {videoList, activeIndex, vCourseId, course={}} = this.state
if(!this.state.course.course_id) {
console.log('免费课程 拦截');
return;
}
if(course.is_aist) {
// 返现课程
this.sendMessage({
mtype: 'count_schedule',
uid: this.props.user.data.uid,
token: this.token,
platform: 5
})
}else{
// 普通课程
this.sendMessage({
mtype: 'c_count_schedule',
uid: this.props.user.data.uid,
token: this.token,
platform: 5,
video_id: videoList[activeIndex]['id'],
course_id: this.courseID,
v_course_id: vCourseId,
})
}
}
// 发送时间消息
sendWatchTime = (sec, rate) => {
const {videoList, activeIndex, vCourseId} = this.state
const {videoList, activeIndex, vCourseId, course = {}} = this.state
// 免费课程不发送
if(!course.course_id) {
console.log('免费课程 拦截');
return;
}
// 时间为0 不发送消息
if(Number(sec) === 0) {
return;
}
let info_type = 'c_watch_time';
if(course.is_aist) {
info_type = 'watch_time';
}
this.sendMessage({
mtype: 'watch_time',
mtype: info_type,
rate,
time: sec,
video_id: videoList[activeIndex]['id'],
......@@ -464,6 +493,7 @@ class Video extends Component {
this.player.addChild('CustomPlayButtonCover')
this.player.on('ready', () => {
this.recordSocket.emit('load', this.recordUserInfo())
this.countSchedule();
})
this.player.on('ratechange', () => {
this.currentPlaybackRate = this.player.playbackRate()
......@@ -505,7 +535,7 @@ class Video extends Component {
return
}
this.countSchedule()
this.countSchedule(); // 计算进度
this.setState(
{
......
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