Commit 43fadb18 by wangshuo

计算进度

parent 30fab16e
...@@ -88,7 +88,7 @@ class Video extends Component { ...@@ -88,7 +88,7 @@ class Video extends Component {
currentVideoSrc: '', currentVideoSrc: '',
activeIndex: 0, activeIndex: 0,
isAuth: true, isAuth: true,
course: {}, course: {}, // course.course_id 为 0 或 '' 时 为免费课程
salePrice: null, salePrice: null,
vCourseId: null, vCourseId: null,
isLoading: true, isLoading: true,
...@@ -369,9 +369,6 @@ class Video extends Component { ...@@ -369,9 +369,6 @@ class Video extends Component {
this.ws = new WebSocket(API["process-api"]); this.ws = new WebSocket(API["process-api"]);
this.ws.addEventListener('error', () => { this.ws.addEventListener('error', () => {
this.ws = null this.ws = null
/*setTimeout(() => {
this.setupWS();
}, 1000)*/
}) })
this.ws.addEventListener('close', () => { this.ws.addEventListener('close', () => {
if (this.reconnect) { if (this.reconnect) {
...@@ -403,21 +400,53 @@ class Video extends Component { ...@@ -403,21 +400,53 @@ class Video extends Component {
}) })
} }
//告诉服务端切换视频 //告诉服务端计算进度 普通课程不发送
countSchedule = () => { countSchedule = () => {
this.sendMessage({ const {videoList, activeIndex, vCourseId, course={}} = this.state
mtype: 'count_schedule', if(!this.state.course.course_id) {
uid: this.props.user.data.uid, console.log('免费课程 拦截');
token: this.token, return;
platform: 5 }
}) 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) => { 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({ this.sendMessage({
mtype: 'watch_time', mtype: info_type,
rate, rate,
time: sec, time: sec,
video_id: videoList[activeIndex]['id'], video_id: videoList[activeIndex]['id'],
...@@ -505,7 +534,7 @@ class Video extends Component { ...@@ -505,7 +534,7 @@ class Video extends Component {
return return
} }
this.countSchedule() this.countSchedule(); // 计算进度
this.setState( 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