|
@@ -1,6 +1,6 @@
|
|
|
const app = require('../../utils/util.js');
|
|
|
const tools = require('../../utils/tools.js');
|
|
|
-var app1 = getApp();
|
|
|
+// var app1 = getApp();
|
|
|
Page({
|
|
|
data: {
|
|
|
url: '', //播放地址
|
|
@@ -10,18 +10,18 @@ Page({
|
|
|
playVideoDuration: 0, // 从这个时间点开始播放
|
|
|
id: 0, //带过来的id
|
|
|
studyLog: {}, //我得到的学习日志
|
|
|
- intervalTime: 0, //隔五分钟清空重新计时 弹出信息确认在不在
|
|
|
+ // intervalTime: 0, //隔五分钟清空重新计时 弹出信息确认在不在
|
|
|
video_real_time: 0, //实时播放进度
|
|
|
intervalCtx: null,
|
|
|
videoContext: null,
|
|
|
classInfo: {},
|
|
|
- showWW: false,
|
|
|
- showChange: false,
|
|
|
- showfullChange:false,
|
|
|
+ showWW: true,
|
|
|
+ showChange: true,
|
|
|
+ showfullChange: false,
|
|
|
networkType: '',
|
|
|
isAgree: false, //表示不同意用4G
|
|
|
- fullScreen:false
|
|
|
-
|
|
|
+ fullScreen: false,
|
|
|
+ spanTime: 0 //间隔时间弹窗小人
|
|
|
},
|
|
|
isClass(sessionKey) {
|
|
|
wx.request({
|
|
@@ -72,29 +72,26 @@ Page({
|
|
|
console.log('视频错误信息:', e.detail.errMsg)
|
|
|
},
|
|
|
// 计时 五分钟弹出一个弹框
|
|
|
- calculateTime() {
|
|
|
- console.log(this.data.intervalTime)
|
|
|
- let _this = this;
|
|
|
- this.setData({
|
|
|
- intervalTime: _this.data.intervalTime + 5
|
|
|
- })
|
|
|
- if (_this.data.intervalTime > 300) {
|
|
|
- _this.data.videoContext.pause()
|
|
|
- this.setData({
|
|
|
- intervalTime: 0,
|
|
|
- showWW: true
|
|
|
- })
|
|
|
- }
|
|
|
- },
|
|
|
+ // calculateTime() {
|
|
|
+ // console.log(this.data.alertTime)
|
|
|
+
|
|
|
+ // console.log(this.data.intervalTime)
|
|
|
+ // let _this = this;
|
|
|
+ // this.setData({
|
|
|
+ // intervalTime: _this.data.intervalTime + 5
|
|
|
+ // })
|
|
|
+ // if (_this.data.intervalTime > 300) {
|
|
|
+ // _this.data.videoContext.pause()
|
|
|
+ // this.setData({
|
|
|
+ // showWW: false,
|
|
|
+ // intervalTime: 0
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ // },
|
|
|
// 点击开始播放视频
|
|
|
async bindplay() {
|
|
|
- // this.setData({
|
|
|
- // clickTime: this.data.clickTime + 1
|
|
|
- // })
|
|
|
this.setData({
|
|
|
- intervalCtx: setInterval(() => {
|
|
|
- this.calculateTime()
|
|
|
- }, 5000)
|
|
|
+ showWW: true
|
|
|
})
|
|
|
const netStatus = await this.getNetStatus();
|
|
|
this.setData({
|
|
@@ -102,63 +99,48 @@ Page({
|
|
|
})
|
|
|
if (netStatus != 'wifi' && !this.data.isAgree) {
|
|
|
this.data.videoContext.pause()
|
|
|
- if(this.data.fullScreen){
|
|
|
- this.setData({
|
|
|
- showfullChange: true
|
|
|
- })
|
|
|
- }else{
|
|
|
this.setData({
|
|
|
- showChange: true
|
|
|
+ showChange: false
|
|
|
})
|
|
|
- }
|
|
|
-
|
|
|
}
|
|
|
wx.onNetworkStatusChange((res) => {
|
|
|
if (this.data.networkType == "wifi" && res.networkType != "wifi" && !this.data.isAgree) {
|
|
|
this.data.videoContext.pause()
|
|
|
- if(this.data.fullScreen){
|
|
|
this.setData({
|
|
|
- showfullChange: true
|
|
|
+ showChange: false
|
|
|
})
|
|
|
- }else{
|
|
|
- this.setData({
|
|
|
- showChange: true
|
|
|
- })
|
|
|
- }
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
goclose() {
|
|
|
this.setData({
|
|
|
- showChange: false,
|
|
|
- showfullChange:false,
|
|
|
+ showChange: true,
|
|
|
isAgree: false
|
|
|
})
|
|
|
},
|
|
|
goon() {
|
|
|
this.setData({
|
|
|
- showChange: false,
|
|
|
- showfullChange:false,
|
|
|
+ showChange: true,
|
|
|
isAgree: true
|
|
|
})
|
|
|
this.data.videoContext.play()
|
|
|
},
|
|
|
fullScreenChange(e) {
|
|
|
- console.log(e.detail.fullScreen,"我是切换全屏的状态")
|
|
|
+ console.log(e.detail.fullScreen, "我是切换全屏的状态")
|
|
|
this.setData({
|
|
|
- fullScreen: e.detail.fullScreen
|
|
|
+ fullScreen: e.detail.fullScreen,
|
|
|
})
|
|
|
},
|
|
|
startbf() {
|
|
|
this.setData({
|
|
|
- showWW: false
|
|
|
+ showWW: true
|
|
|
})
|
|
|
this.data.videoContext.play()
|
|
|
},
|
|
|
// 视频暂停
|
|
|
- bindpause() {
|
|
|
- clearInterval(this.data.intervalCtx)
|
|
|
- },
|
|
|
+ // bindpause() {
|
|
|
+ // clearInterval(this.data.intervalCtx)
|
|
|
+ // },
|
|
|
// 得到录播列表
|
|
|
getdbArr(sessionKey) {
|
|
|
let _this = this;
|
|
@@ -176,7 +158,8 @@ Page({
|
|
|
show: false,
|
|
|
title: e.data.course.courseName,
|
|
|
message: e.data.course.courseInfo,
|
|
|
- playTimes: e.data.course.playTimes
|
|
|
+ playTimes: e.data.course.playTimes,
|
|
|
+ courseTime: e.data.course.courseTime
|
|
|
})
|
|
|
}
|
|
|
})
|
|
@@ -189,12 +172,12 @@ Page({
|
|
|
url: app.globalData.publicUrl + '/wx/course/getStudyLog',
|
|
|
data: {
|
|
|
sessionKey: sessionKey,
|
|
|
- courseId: _this.data.id
|
|
|
+ courseId: _this.data.id,
|
|
|
},
|
|
|
success: (e) => {
|
|
|
if (e.data.studyLog.isDone == 1) {
|
|
|
_this.setData({
|
|
|
- studyLog: e.data.studyLog
|
|
|
+ studyLog: e.data.studyLog,
|
|
|
})
|
|
|
} else {
|
|
|
_this.setData({
|
|
@@ -207,70 +190,92 @@ Page({
|
|
|
},
|
|
|
// 设置不可快进
|
|
|
timeUpdate: function (e) {
|
|
|
- //实时播放进度 秒数
|
|
|
let _this = this;
|
|
|
let currentTime = parseInt(e.detail.currentTime) //当前播放秒数
|
|
|
+ console.log(currentTime)
|
|
|
+ if (currentTime != 0 && currentTime % 300 == 0) {
|
|
|
+ if (currentTime != this.data.spanTime) {
|
|
|
+ this.setData({
|
|
|
+ spanTime: currentTime,
|
|
|
+ showWW: false
|
|
|
+ })
|
|
|
+ _this.data.videoContext.pause()
|
|
|
+ }
|
|
|
+ }
|
|
|
let studyTime = 'studyLog.studyTime'
|
|
|
- this.setData({
|
|
|
- [studyTime]: currentTime
|
|
|
- })
|
|
|
- if (this.data.classInfo.id != -1) {
|
|
|
- let aa = 1;
|
|
|
- let jump_time;
|
|
|
- if (_this.data.video_real_time == 0) {
|
|
|
- jump_time = parseInt(_this.data.playVideoDuration) + parseInt(_this.data.video_real_time)
|
|
|
- } else {
|
|
|
- jump_time = parseInt(_this.data.video_real_time)
|
|
|
+ //实时给页面的学习记录赋值
|
|
|
+ let jump_time = parseInt(_this.data.video_real_time); //定义跳转的时间
|
|
|
+ if (this.data.studyLog.isStudyDone != 1) {
|
|
|
+ if (currentTime > jump_time && currentTime - jump_time > 3 && currentTime > _this.data.playVideoDuration) {
|
|
|
+ _this.data.videoContext.seek(_this.data.playVideoDuration)
|
|
|
+ this.setData({
|
|
|
+ video_real_time: _this.data.playVideoDuration, //实时播放进度
|
|
|
+ })
|
|
|
+ wx.showToast({
|
|
|
+ title: '该视频不可以快进哦!',
|
|
|
+ icon: 'none',
|
|
|
+ duration: 2000,
|
|
|
+ })
|
|
|
}
|
|
|
- if (aa == 1) {
|
|
|
- if (currentTime > jump_time && currentTime - jump_time > 3) {
|
|
|
- _this.data.videoContext.seek(_this.data.video_real_time)
|
|
|
- wx.showToast({
|
|
|
- title: '该视频不可以快进哦!',
|
|
|
- icon: 'none',
|
|
|
- duration: 2000,
|
|
|
- })
|
|
|
- }
|
|
|
+ if (currentTime > jump_time && currentTime - jump_time < 3 && currentTime > _this.data.playVideoDuration) {
|
|
|
+ this.setData({
|
|
|
+ playVideoDuration: currentTime,
|
|
|
+ [studyTime]: currentTime
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if (currentTime > jump_time && currentTime - jump_time < 3) {
|
|
|
+ _this.setData({
|
|
|
+ video_real_time: currentTime, //实时播放进度
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
- _this.setData({
|
|
|
- video_real_time: currentTime, //实时播放进度
|
|
|
- })
|
|
|
},
|
|
|
// 修改学习进度
|
|
|
chechEndStatus: function () {
|
|
|
+ let _this = this;
|
|
|
if (this.data.classInfo.id != -1) {
|
|
|
- let _this = this;
|
|
|
- // let currentTime = parseInt(e.detail.currentTime)
|
|
|
- let isDone = 'studyLog.isDone'
|
|
|
- this.setData({
|
|
|
- [isDone]: 1
|
|
|
- })
|
|
|
- wx.request({
|
|
|
- method: "post",
|
|
|
- url: app.globalData.publicUrl + '/wx/course/updateStudyLog',
|
|
|
- data: {
|
|
|
- studyLog: _this.data.studyLog
|
|
|
- },
|
|
|
- success: (e) => {
|
|
|
- wx.showModal({
|
|
|
- showCancel: false,
|
|
|
- content: "该录播视频已经看完啦,快去完成其他任务吧!",
|
|
|
- success(res) {
|
|
|
- if (res.confirm) {
|
|
|
- wx.navigateBack({
|
|
|
- delta: 1
|
|
|
- })
|
|
|
+ if (this.data.video_real_time > this.data.courseTime / 1000 - 10) {
|
|
|
+ let isDone = 'studyLog.isDone'
|
|
|
+ this.setData({
|
|
|
+ [isDone]: 1
|
|
|
+ })
|
|
|
+ wx.request({
|
|
|
+ method: "post",
|
|
|
+ url: app.globalData.publicUrl + '/wx/course/updateStudyLog',
|
|
|
+ data: {
|
|
|
+ studyLog: _this.data.studyLog
|
|
|
+ },
|
|
|
+ success: (e) => {
|
|
|
+ wx.showModal({
|
|
|
+ showCancel: false,
|
|
|
+ content: "该录播视频已经看完啦,快去参与该节课的考试和评价吧!只有考试和评价都参与了,才可以继续进行下一节哦!",
|
|
|
+ success(res) {
|
|
|
+ if (res.confirm) {
|
|
|
+ wx.navigateBack({
|
|
|
+ delta: 1
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
onUnload() {
|
|
|
let _this = this;
|
|
|
- clearInterval(_this.data.intervalCtx)
|
|
|
+ console.log(_this.data.studyLog.isDone, typeof (_this.data.studyLog.isDone))
|
|
|
+ console.log(_this.data.studyLog.studyTime)
|
|
|
+ console.log(_this.data.playVideoDuration)
|
|
|
+ if (_this.data.studyLog.isDone != '1') {
|
|
|
+ if (this.data.video_real_time > this.data.courseTime / 1000 - 10) {
|
|
|
+ let isDone = 'studyLog.isDone'
|
|
|
+ this.setData({
|
|
|
+ [isDone]: 1
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // clearInterval(_this.data.intervalCtx)
|
|
|
if (_this.data.classInfo.id != -1) {
|
|
|
let stydyrecord = _this.data.playVideoDuration;
|
|
|
if (stydyrecord == null) {
|
|
@@ -292,7 +297,18 @@ Page({
|
|
|
},
|
|
|
onHide() {
|
|
|
let _this = this;
|
|
|
- clearInterval(_this.data.intervalCtx)
|
|
|
+ console.log(_this.data.studyLog.isDone)
|
|
|
+ console.log(_this.data.studyLog.studyTime)
|
|
|
+ console.log(_this.data.playVideoDuration)
|
|
|
+ if (_this.data.studyLog.isDone != '1') {
|
|
|
+ if (this.data.video_real_time > this.data.courseTime / 1000 - 10) {
|
|
|
+ let isDone = 'studyLog.isDone'
|
|
|
+ this.setData({
|
|
|
+ [isDone]: 1
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // clearInterval(_this.data.intervalCtx)
|
|
|
if (_this.data.classInfo.id != -1) {
|
|
|
let stydyrecord = _this.data.playVideoDuration;
|
|
|
if (stydyrecord == null) {
|
|
@@ -324,6 +340,7 @@ Page({
|
|
|
},
|
|
|
async onLoad(options) {
|
|
|
this.setData({
|
|
|
+ options: options,
|
|
|
id: options.id,
|
|
|
videoContext: wx.createVideoContext('myVideo')
|
|
|
})
|
|
@@ -331,5 +348,5 @@ Page({
|
|
|
this.isClass(sessionKey);
|
|
|
this.getStudyLog(sessionKey);
|
|
|
this.getdbArr(sessionKey);
|
|
|
- },
|
|
|
+ }
|
|
|
})
|