|
@@ -431,7 +431,6 @@ export default {
|
|
|
photoNum: 0,
|
|
|
photoList: [], //拍照的时间点
|
|
|
photoConfig: false, //是否配置好拍照次数
|
|
|
- photoIndex: 0, //当前位于拍照的区间下标 从0开始
|
|
|
photoHistoryList: [], //已拍照历史的下标点
|
|
|
sectionItem: {},
|
|
|
showNotes: true,
|
|
@@ -826,7 +825,6 @@ export default {
|
|
|
this.clearPauseTimer();
|
|
|
this.hasStart = false;
|
|
|
this.photoConfig = false;
|
|
|
- this.photoIndex = 0;
|
|
|
//清除直播
|
|
|
this.$store.commit("setPlayChannelId", { playChannelId: 0 });
|
|
|
// 防止原先初始化错误
|
|
@@ -841,7 +839,6 @@ export default {
|
|
|
this.hasStart = false;
|
|
|
this.isPlayRebuild = item.rebuild;
|
|
|
this.photoConfig = false;
|
|
|
- this.photoIndex = 0;
|
|
|
this.sectionItem = item;
|
|
|
this.moduleId = item.moduleId || null;
|
|
|
this.chapterId = item.chapterId || null;
|
|
@@ -1399,8 +1396,8 @@ export default {
|
|
|
return {};
|
|
|
},
|
|
|
loadedmetadata(event) {
|
|
|
- this.$refs["camera"].openCamera();
|
|
|
this.refPlv = this.$refs.player;
|
|
|
+ this.$refs["camera"].openCamera();
|
|
|
},
|
|
|
getPhotoLastRecord() {
|
|
|
// if (this.erJianErZao || !this.playSecIsLearn || this.photoNum <= 0) {
|
|
@@ -1418,27 +1415,25 @@ export default {
|
|
|
orderGoodsId: this.orderGoodsId,
|
|
|
};
|
|
|
this.$api.getPhotoLastRecord(data).then((res) => {
|
|
|
- console.log(res.data.data, 99999999999);
|
|
|
if (res.data.code == 200) {
|
|
|
//清空历史数据
|
|
|
- self.photoHistoryList = [];
|
|
|
- this.photoIndex = 0;
|
|
|
- self.photoList = [];
|
|
|
+ this.photoHistoryList = [];
|
|
|
+ this.photoList = [];
|
|
|
for (let i = 0; i < res.data.data.length; i++) {
|
|
|
//-2存储随机拍照数组
|
|
|
if (res.data.data[i].photoIndex == -2) {
|
|
|
- self.photoList =
|
|
|
+ this.photoList =
|
|
|
res.data.data[i].timeInterval &&
|
|
|
res.data.data[i].timeInterval.split(",");
|
|
|
} else {
|
|
|
- self.photoHistoryList.push(res.data.data[i].photoIndex);
|
|
|
+ this.photoHistoryList.push(res.data.data[i].photoIndex);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
//postTime 只提交随机时间
|
|
|
- postCoursePhotoRecord(postTime = false) {
|
|
|
+ postCoursePhotoRecord() {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
let currentTime = 0;
|
|
|
// var polyvPlayerContext = this.selectComponent("#playerVideo");
|
|
@@ -1450,20 +1445,18 @@ export default {
|
|
|
currentTime = polyvPlayerContext.j2s_getCurrentTime();
|
|
|
// #endif
|
|
|
}
|
|
|
- let self = this;
|
|
|
- let photoIndex = self.photoIndex;
|
|
|
let data = {
|
|
|
- photo: self.ossAvatarUrl,
|
|
|
- sectionId: parseInt(self.playSectionId),
|
|
|
- goodsId: parseInt(self.goodsId),
|
|
|
- courseId: parseInt(self.courseId),
|
|
|
+ photo: this.ossAvatarUrl,
|
|
|
+ sectionId: this.playSectionId,
|
|
|
+ goodsId: this.goodsId,
|
|
|
+ courseId: this.courseId,
|
|
|
photoTime: parseInt(currentTime > 0 ? currentTime : 0),
|
|
|
- gradeId: parseInt(self.gradeId),
|
|
|
- photoIndex: postTime ? -2 : parseInt(photoIndex), //从0算起,-2只提交随机时间
|
|
|
- photoNum: parseInt(self.photoNum),
|
|
|
- chapterId: parseInt(self.chapterId),
|
|
|
- moduleId: parseInt(self.moduleId),
|
|
|
- timeInterval: postTime ? self.photoList.join(",") : "",
|
|
|
+ gradeId: this.gradeId,
|
|
|
+ photoIndex: -2, //从0算起,-2只提交随机时间
|
|
|
+ photoNum: this.photoNum,
|
|
|
+ chapterId: this.chapterId,
|
|
|
+ moduleId: this.moduleId,
|
|
|
+ timeInterval: this.photoList.join(","),
|
|
|
orderGoodsId: this.orderGoodsId,
|
|
|
};
|
|
|
// console.log("提交接口", data);
|
|
@@ -1495,46 +1488,23 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
//配置随机拍照时间
|
|
|
- configPhoto() {
|
|
|
- // var polyvPlayerContext = this.selectComponent("#playerVideo");
|
|
|
- let totalVideoTime = 0;
|
|
|
- let duration = 0;
|
|
|
- // #ifdef MP-WEIXIN
|
|
|
- totalVideoTime = polyvPlayerContext.getDuration();
|
|
|
- duration = polyvPlayerContext.getCurrentTime();
|
|
|
- // #endif
|
|
|
- // #ifdef H5
|
|
|
- totalVideoTime = polyvPlayerContext.j2s_getDuration();
|
|
|
- duration = polyvPlayerContext.j2s_getCurrentTime();
|
|
|
- // #endif
|
|
|
- if (!this.photoConfig) {
|
|
|
- this.photoConfig = true;
|
|
|
- if (this.erJianErZao) {
|
|
|
- this.photoList = this.randomConfig(totalVideoTime, duration);
|
|
|
- return;
|
|
|
- }
|
|
|
- //没有历史拍照间隔数据
|
|
|
- if (!this.photoList || this.photoList.length == 0) {
|
|
|
- this.photoList = this.commonConfig(
|
|
|
- totalVideoTime,
|
|
|
- this.jjShiGongYuan ? 46 * 60 : undefined
|
|
|
- );
|
|
|
- this.postCoursePhotoRecord(true); //提交随机拍照时间数组
|
|
|
- }
|
|
|
- //兼容已有观看历史
|
|
|
- for (let i = 0; i < this.photoList.length - 1; i++) {
|
|
|
- if (
|
|
|
- this.photoList[i] < duration &&
|
|
|
- this.photoList[i + 1] > duration
|
|
|
- ) {
|
|
|
- this.photoIndex = i + 1;
|
|
|
- break;
|
|
|
- }
|
|
|
- if (duration > this.photoList[this.photoList.length - 1]) {
|
|
|
- this.photoIndex = this.photoList.length - 1; //取最后一个下标
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
+ configPhoto(duration) {
|
|
|
+ if (this.photoConfig) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ let totalVideoTime = this.refPlv.getDuration()
|
|
|
+ this.photoConfig = true;
|
|
|
+ if (this.erJianErZao) {
|
|
|
+ this.photoList = this.randomConfig(totalVideoTime, duration);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //没有历史拍照间隔数据
|
|
|
+ if (!this.photoList || this.photoList.length == 0) {
|
|
|
+ this.photoList = this.commonConfig(
|
|
|
+ totalVideoTime,
|
|
|
+ this.jjShiGongYuan ? 46 * 60 : undefined
|
|
|
+ );
|
|
|
+ this.postCoursePhotoRecord(); //提交随机拍照时间数组
|
|
|
}
|
|
|
},
|
|
|
// 二建随机拍摄时间
|
|
@@ -1902,25 +1872,17 @@ export default {
|
|
|
resolve(waitUpload);
|
|
|
});
|
|
|
},
|
|
|
- timeEvent(playTime) {
|
|
|
- this.configPhoto();
|
|
|
- let photoTime = 0; //获取拍照秒数
|
|
|
- for (let i = 0; i < this.photoList.length; i++) {
|
|
|
- photoTime = Number(this.photoList[i]); //获取拍照秒数
|
|
|
- if (
|
|
|
- (this.erJianErZao && !this.photoHistoryList.length) ||
|
|
|
- (photoTime < playTime && photoTime > playTime - 8)
|
|
|
- ) {
|
|
|
- //3秒区间内才触发拍照,避免拉动滚动条
|
|
|
- if (this.photoHistoryList.indexOf(i) < 0) {
|
|
|
- //不存在拍照历史,没有重修过,没有学过,则拍照
|
|
|
- //启动拍照
|
|
|
- //暂停
|
|
|
- console.log("去拍照");
|
|
|
- this.refPlv.playPause();
|
|
|
- this.refPlv.exitFullScreen();
|
|
|
- this.photoIndex = i;
|
|
|
- }
|
|
|
+ timeEvent(time) {
|
|
|
+ this.clearPauseTimer();
|
|
|
+ if (this.playSecIsLearn && (this.erJianErZao || this.photoNum > 0)) {
|
|
|
+ this.configPhoto(time);
|
|
|
+ this.isReach = false;
|
|
|
+ const index = this.photoList.findIndex(
|
|
|
+ (e) => e.photoTime < time && e.photoTime > time - 8
|
|
|
+ );
|
|
|
+ if (index != -1 && !this.photoHistoryList[index]) {
|
|
|
+ // 拍照
|
|
|
+ this.openCamera();
|
|
|
}
|
|
|
}
|
|
|
},
|
|
@@ -1948,10 +1910,7 @@ export default {
|
|
|
timeupdate(time) {
|
|
|
// console.log("播放中", time);
|
|
|
this.clearPauseTimer();
|
|
|
- if (this.playSecIsLearn && (this.erJianErZao || this.photoNum > 0)) {
|
|
|
- this.isReach = false;
|
|
|
- this.timeEvent();
|
|
|
- }
|
|
|
+ this.timeEvent(time);
|
|
|
},
|
|
|
playing() {
|
|
|
console.log("playing");
|
|
@@ -1959,8 +1918,7 @@ export default {
|
|
|
this.refPlv.playPause();
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
- this.$refs["camera"].openCamera();
|
|
|
+ // this.$refs["camera"].openCamera();
|
|
|
this.studyLog();
|
|
|
if (!this.recordObj.videoCurrentTime) {
|
|
|
this.postStudyRecord(0);
|
|
@@ -2064,7 +2022,6 @@ export default {
|
|
|
|
|
|
this.hasStart = false;
|
|
|
this.photoConfig = false;
|
|
|
- this.photoIndex = 0;
|
|
|
this.sectionItem = data;
|
|
|
this.playVideo(data);
|
|
|
} else if (data.sectionType == 2) {
|
|
@@ -2089,156 +2046,6 @@ export default {
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
- //拍照
|
|
|
- openPhoto() {
|
|
|
- if (polyvPlayerContext) {
|
|
|
- // #ifdef MP-WEIXIN
|
|
|
- polyvPlayerContext.exitFullScreen();
|
|
|
- // #endif
|
|
|
- // #ifdef H5
|
|
|
- if (this.isFullScreen()) {
|
|
|
- this.exitFullscreen();
|
|
|
- }
|
|
|
- // #endif
|
|
|
- }
|
|
|
-
|
|
|
- // #ifdef MP-WEIXIN
|
|
|
- this.enableAutoRotation = false;
|
|
|
- this.photoPopup = true;
|
|
|
- this.isTaking = true;
|
|
|
- uni.setKeepScreenOn({
|
|
|
- keepScreenOn: true,
|
|
|
- });
|
|
|
- uni.authorize({
|
|
|
- scope: "scope.camera",
|
|
|
- success() {},
|
|
|
- });
|
|
|
- // #endif
|
|
|
- // #ifdef H5
|
|
|
- if (
|
|
|
- (window.navigator.mediaDevices &&
|
|
|
- window.navigator.mediaDevices.getUserMedia) ||
|
|
|
- window.navigator.getUserMedia ||
|
|
|
- window.navigator.webkitGetUserMedia ||
|
|
|
- window.navigator.mozGetUserMedia
|
|
|
- ) {
|
|
|
- console.log("getUserMedia----");
|
|
|
- // 调用用户媒体设备, 访问摄像头
|
|
|
- this.getUserMedia(
|
|
|
- {
|
|
|
- video: {
|
|
|
- width: 400,
|
|
|
- height: 300,
|
|
|
- facingMode: "user",
|
|
|
- },
|
|
|
- },
|
|
|
- this.photographSuccess,
|
|
|
- this.photographError
|
|
|
- );
|
|
|
- } else {
|
|
|
- console.log("1111没有摄像");
|
|
|
- this.photographError();
|
|
|
- }
|
|
|
- // #endif
|
|
|
- },
|
|
|
- /**
|
|
|
- * 人脸匹配
|
|
|
- */
|
|
|
- faceRecognition() {
|
|
|
- return new Promise((resolve) => {
|
|
|
- // #ifdef MP-WEIXIN
|
|
|
- let fileSystem = uni.getFileSystemManager();
|
|
|
- fileSystem.readFile({
|
|
|
- filePath: `${this.avatarUrl}`,
|
|
|
- encoding: "base64",
|
|
|
- position: 0,
|
|
|
- success: (res) => {
|
|
|
- let base64 = "data:image/jpg;base64," + res.data;
|
|
|
- // console.log('base64Data人脸识别参数:', {
|
|
|
- // imageA: base64,
|
|
|
- // orderGoodsId: this.orderGoodsId,
|
|
|
- // gradeId: this.gradeId,
|
|
|
- // })
|
|
|
-
|
|
|
- this.CompareFace(base64, resolve);
|
|
|
- },
|
|
|
- fail(err) {
|
|
|
- // this.$u.toast('人脸识别错误!')
|
|
|
- console.error(err, "err-----人脸识别错误");
|
|
|
- },
|
|
|
- });
|
|
|
- // #endif
|
|
|
- // #ifdef H5
|
|
|
- this.CompareFace(this.faceUrl, resolve);
|
|
|
- // #endif
|
|
|
- });
|
|
|
- },
|
|
|
- CompareFace(url, resolve) {
|
|
|
- let timer = setTimeout(() => {
|
|
|
- uni.showToast({
|
|
|
- icon: "none",
|
|
|
- title: "拍照超时,请重新拍照",
|
|
|
- duration: 2000,
|
|
|
- success: () => {
|
|
|
- setTimeout(() => {
|
|
|
- uni.navigateBack();
|
|
|
- }, 1000);
|
|
|
- },
|
|
|
- });
|
|
|
- }, 10 * 1000);
|
|
|
-
|
|
|
- this.$api
|
|
|
- .faceCertificationCompareFace({
|
|
|
- imageA: url,
|
|
|
- orderGoodsId: this.orderGoodsId,
|
|
|
- gradeId: this.gradeId,
|
|
|
- })
|
|
|
- .then((res) => {
|
|
|
- clearTimeout(timer);
|
|
|
- console.log(res, "人脸识别成功res");
|
|
|
- resolve(res.data.data);
|
|
|
- })
|
|
|
- .catch((err) => {
|
|
|
- clearTimeout(timer);
|
|
|
- // 当前网络延迟,
|
|
|
- console.log("人脸识别错误:", err);
|
|
|
- uni.showModal({
|
|
|
- content: "当前网络延迟",
|
|
|
- showCancel: false,
|
|
|
- success: (resultst) => {
|
|
|
- if (resultst.confirm) {
|
|
|
- uni.navigateBack();
|
|
|
- }
|
|
|
- },
|
|
|
- });
|
|
|
- });
|
|
|
- },
|
|
|
- //确认拍照
|
|
|
- takePhoto() {
|
|
|
- // #ifdef MP-WEIXIN
|
|
|
- const ctx = uni.createCameraContext();
|
|
|
- ctx.takePhoto({
|
|
|
- quality: "high",
|
|
|
- success: (res) => {
|
|
|
- this.avatarUrl = res.tempImagePath;
|
|
|
- console.log("开始拍照this.avatarUrl:", this.avatarUrl);
|
|
|
- this.isTaking = false;
|
|
|
- },
|
|
|
- fail: (err) => {},
|
|
|
- });
|
|
|
- // #endif
|
|
|
- // #ifdef H5
|
|
|
- const canvas = document.createElement("canvas");
|
|
|
- canvas.width = 400;
|
|
|
- canvas.height = 400;
|
|
|
- const context = canvas.getContext("2d");
|
|
|
- const box = document.querySelector(".photo_v");
|
|
|
- const video = box.querySelector("video");
|
|
|
- context.drawImage(video, 0, 0, 400, 400);
|
|
|
- this.faceUrl = canvas.toDataURL("image/png");
|
|
|
- this.isTaking = false;
|
|
|
- // #endif
|
|
|
- },
|
|
|
playError(e) {
|
|
|
console.log(e);
|
|
|
},
|
|
@@ -2290,10 +2097,6 @@ export default {
|
|
|
},
|
|
|
async getGoodsDetail() {
|
|
|
let { data } = await this.$api.goodsDetail(this.goodsId);
|
|
|
- console.log(
|
|
|
- "🚀 ~ file: detail.vue:2342 ~ getGoodsDetail ~ data:",
|
|
|
- data.data
|
|
|
- );
|
|
|
this.goodsData = data.data;
|
|
|
this.erJianErZao = this.goodsData.erJianErZao;
|
|
|
this.erJianErZao && (await this.userConfirmInfoDetail());
|
|
@@ -2406,58 +2209,6 @@ export default {
|
|
|
null
|
|
|
);
|
|
|
},
|
|
|
-
|
|
|
- //判断是否全屏
|
|
|
- isFullScreen() {
|
|
|
- return !!(document.webkitIsFullScreen || this.fullele());
|
|
|
- },
|
|
|
- getUserMedia(constraints, success, error) {
|
|
|
- console.log("getUserMedia===", constraints, "success:", success);
|
|
|
- if (window.navigator.mediaDevices.getUserMedia) {
|
|
|
- // 最新的标准API
|
|
|
- window.navigator.mediaDevices
|
|
|
- .getUserMedia(constraints)
|
|
|
- .then(success)
|
|
|
- .catch(error);
|
|
|
- } else if (window.navigator.webkitGetUserMedia) {
|
|
|
- // webkit核心浏览器
|
|
|
- window.navigator.webkitGetUserMedia(constraints, success, error);
|
|
|
- } else if (window.navigator.mozGetUserMedia) {
|
|
|
- // firfox浏览器
|
|
|
- window.navigator.mozGetUserMedia(constraints, success, error);
|
|
|
- } else if (window.navigator.getUserMedia) {
|
|
|
- // 旧版API
|
|
|
- window.navigator.getUserMedia(constraints, success, error);
|
|
|
- }
|
|
|
- },
|
|
|
- photographSuccess(stream) {
|
|
|
- console.log("有摄像头---", stream);
|
|
|
- this.photoPopup = true;
|
|
|
- this.isTaking = true;
|
|
|
- this.enableAutoRotation = false;
|
|
|
- this.$nextTick(() => {
|
|
|
- const box = document.querySelector(".photo_v");
|
|
|
- const video = box.querySelector("video");
|
|
|
- video.srcObject = stream;
|
|
|
- video.play();
|
|
|
- });
|
|
|
- },
|
|
|
- photographError(err) {
|
|
|
- console.log("没有摄像头:", err);
|
|
|
- uni.showModal({
|
|
|
- title: "提示",
|
|
|
- content:
|
|
|
- "课程学习需要开启摄像头进行拍照,经检测您的设备无摄像头可使用,请检测环境是否支持。",
|
|
|
- cancelText: "取消",
|
|
|
- confirmText: "确定",
|
|
|
- success: (res) => {
|
|
|
- if (res.confirm) {
|
|
|
- uni.navigateBack();
|
|
|
- } else if (res.cancel) {
|
|
|
- }
|
|
|
- },
|
|
|
- });
|
|
|
- },
|
|
|
},
|
|
|
};
|
|
|
</script>
|