Commit 43fadb18 by wangshuo

计算进度

parent 30fab16e
......@@ -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'],
......@@ -505,7 +534,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