index.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692
  1. <template>
  2. <div
  3. id="videoCy"
  4. :style="{
  5. backgroundImage: `url(${$tools.splitImgHost(goodsData.coverUrl, false)})`
  6. }"
  7. >
  8. <div id="player"></div>
  9. <div class="recordStyle" v-if="showRecordStatus">
  10. 您上次看{{
  11. $tools.secondToTime(this.activeSection.videoCurrentTime)
  12. }},正在自动续播
  13. <span class="videoCurrentTime_style">|</span>
  14. <span class="btn_sty" @click="seekVideo0">从头播放</span>
  15. </div>
  16. <takePicture
  17. ref="takePicture"
  18. @returnParameter="returnParameter"
  19. ></takePicture>
  20. </div>
  21. </template>
  22. <script>
  23. import takePicture from "@/components/takePicture/index.vue";
  24. export default {
  25. components: { takePicture },
  26. inject: ["getGoodsData"],
  27. data() {
  28. return {
  29. vodPlayerJs: "https://player.polyv.net/script/player.js",
  30. activeSection: {},
  31. player: null,
  32. photoList: [], //抓拍时间拍照数组
  33. photoHistoryList: [], //历史和已拍照数据
  34. photoIndex: 0, //当前拍照对应索引
  35. showRecordStatus: false, //是否显示从头播放提示
  36. showRecordSetTimeOut: null, //从头播放提示计时器函数
  37. openPhotoStatus: 0, //暂存学习状态
  38. commitTime: null //暂存时间-节流
  39. };
  40. },
  41. computed: {
  42. goodsData() {
  43. return this.getGoodsData();
  44. }
  45. },
  46. watch: {
  47. //因为刚开始获取不到goodsData的数据 所以需要监听
  48. goodsData: function(newVal, oldVal) {
  49. if (newVal) {
  50. this.getBeforeWork(); //处理前置任务
  51. }
  52. }
  53. },
  54. created() {
  55. if (!window.polyvPlayer) {
  56. const myScript = document.createElement("script");
  57. myScript.setAttribute("src", this.vodPlayerJs);
  58. myScript.onload = () => {
  59. console.log("加载成功");
  60. };
  61. document.body.appendChild(myScript);
  62. }
  63. },
  64. mounted() {
  65. this.$bus.$on("toPlay", async item => {
  66. this.activeSection = Object.assign({}, item);
  67. if (this.player) {
  68. this.player.destroy(); //初始化播放器
  69. }
  70. this.initData(); //初始化参数
  71. await this.getRecordLast(); //获取播放记录
  72. await this.getRecordHistoryPhoto(); //获取拍照历史记录
  73. await this.loadPlayer(); //加载播放内容
  74. this.player.on("s2j_onPlayerInitOver", () => {
  75. this.player.HTML5.video.addEventListener("timeupdate", this.timeEvent); //监听器
  76. this.player.on("s2j_onPlayStart", this.onPlayStatus); //视频初次播放时触发
  77. this.player.on("s2j_onVideoPause", this.onVideoPause); //视频暂停时触发
  78. this.player.on("s2j_onPlayOver", this.onPlayOver); //当前视频播放完毕时触发
  79. this.player.on("s2j_onPlayerError", this.onPlayerError); //播放出现错误时触发
  80. this.player.on("serverError", this.serverError); //发生业务逻辑错误时触发,比如授权验证失败、域名黑白名单验证不通过等错误。参数返回事件名称和错误代码。
  81. }); //播放器初始化完毕时触发。播放器提供的方法需要在此事件发生后才可以调用。
  82. });
  83. },
  84. methods: {
  85. getBeforeWork() {},
  86. //初始化参数
  87. initData() {
  88. this.commitTime = null;
  89. this.openPhotoStatus = 0;
  90. },
  91. //获取播放记录
  92. getRecordLast() {
  93. return new Promise(resolve => {
  94. clearTimeout(this.showRecordSetTimeOut);
  95. let data = {
  96. // orderGoodsId: this.goodsData.orderGoodsId,
  97. gradeId: this.goodsData.gradeId,
  98. goodsId: this.goodsData.goodsId,
  99. courseId: this.activeSection.courseId,
  100. moduleId: this.activeSection.moduleId,
  101. chapterId: this.activeSection.chapterId,
  102. sectionId: this.activeSection.sectionId
  103. };
  104. this.$request.recordLast(data).then(res => {
  105. if (res.data && res.data.videoCurrentTime) {
  106. this.activeSection.videoCurrentTime = res.data.videoCurrentTime;
  107. }
  108. resolve();
  109. });
  110. });
  111. },
  112. //从头播放
  113. seekVideo0() {
  114. this.player.j2s_seekVideo(0);
  115. this.showRecordStatus = false;
  116. },
  117. //获取拍照历史记录
  118. getRecordHistoryPhoto() {
  119. return new Promise(resolve => {
  120. var data = {
  121. sectionId: this.activeSection.sectionId,
  122. goodsId: this.goodsData.goodsId,
  123. courseId: this.activeSection.sectionId,
  124. gradeId: this.goodsData.gradeId,
  125. chapterId: this.activeSection.chapterId,
  126. moduleId: this.activeSection.moduleId
  127. };
  128. this.$request.getPhotoLastRecord(data).then(res => {
  129. //清空历史数据
  130. this.photoList = [];
  131. this.photoHistoryList = [];
  132. this.photoIndex = 0;
  133. for (let i = 0; i < res.data.length; i++) {
  134. //-2存储随机拍照数组
  135. if (res.data[i].photoIndex == -2 && res.data[i].timeInterval) {
  136. this.photoList = res.data[i].timeInterval.split(",");
  137. } else {
  138. this.photoHistoryList.push(res.data[i].photoIndex);
  139. }
  140. }
  141. resolve();
  142. });
  143. });
  144. },
  145. //计算拍照逻辑
  146. photoLogic() {
  147. if (this.photoList.length > 0 || this.activeSection.learning == 1) return; //已从历史拍照数据获得
  148. var polyvPlayerContext = this.player;
  149. let totalVideoTime = polyvPlayerContext.j2s_getDuration();
  150. let duration = polyvPlayerContext.j2s_getCurrentTime();
  151. if (this.goodsData.erJianErZao) {
  152. this.photoList = this.randomConfig(totalVideoTime, duration);
  153. } else if (this.goodsData.jjShiGongYuan) {
  154. this.photoList = this.ShiPhotoList(totalVideoTime, duration);
  155. } else if (this.goodsData.goodsPhotographConfig.photoNum > 0) {
  156. this.photoList = this.getPhotoList(
  157. totalVideoTime,
  158. this.goodsData.goodsPhotographConfig.photoNum
  159. );
  160. }
  161. //兼容已有观看历史
  162. for (let i = 0; i < this.photoList.length - 1; i++) {
  163. if (this.photoList[i] < duration && this.photoList[i + 1] > duration) {
  164. this.photoIndex = i + 1;
  165. break;
  166. }
  167. if (duration > this.photoList[this.photoList.length - 1]) {
  168. this.photoIndex = this.photoList.length - 1; //取最后一个下标
  169. break;
  170. }
  171. }
  172. },
  173. //普通拍照
  174. getPhotoList(totalVideoTime, photoNum) {
  175. let photoList = [];
  176. if (totalVideoTime >= 900) {
  177. //大于15分钟
  178. if (photoNum == 1) {
  179. //开头拍1张
  180. photoList.push(1);
  181. } else if (photoNum == 3) {
  182. //拍3张
  183. photoList.push(0); //开头拍一张
  184. let centerTime = Math.floor(totalVideoTime / 2); //获取中间时间
  185. let centerMinTime = centerTime - 300; //前后5分钟
  186. let centerMaxTime = centerTime + 300;
  187. let centerTakeTime = this.randomNum(centerMinTime, centerMaxTime);
  188. photoList.push(centerTakeTime); //中间拍一张
  189. let endMaxTime = totalVideoTime - 60;
  190. let endMinTime = totalVideoTime - 300;
  191. let endTakeTime = this.randomNum(endMinTime, endMaxTime);
  192. photoList.push(endTakeTime); //最后拍一张
  193. }
  194. } else {
  195. //小于15分钟,只拍前后各一张
  196. if (photoNum == 1) {
  197. //开头拍1张
  198. photoList.push(1);
  199. } else if (photoNum == 3) {
  200. photoList.push(1);
  201. let centerTime = this.randomNum(
  202. (1 / 3) * totalVideoTime,
  203. (2 / 3) * totalVideoTime
  204. );
  205. photoList.push(centerTime);
  206. let endTakeTime = this.randomNum(
  207. (2 / 3) * totalVideoTime,
  208. totalVideoTime
  209. );
  210. photoList.push(endTakeTime);
  211. }
  212. }
  213. this.postCoursePhotoRecord(true); //提交随机拍照时间数组
  214. return photoList;
  215. },
  216. //施工继教
  217. ShiPhotoList(totalVideoTime) {
  218. //施工继教带年份的订单拍照设置
  219. let time1 = 2761; //拍照间隔多久一张 46分钟
  220. let num = Math.trunc(totalVideoTime / time1) + 1; //拍照数量
  221. let photoList = [];
  222. for (let i = 0; i < num; i++) {
  223. photoList.push(i * time1);
  224. }
  225. return photoList;
  226. },
  227. // 随机拍摄时间(二建)
  228. randomConfig(totalVideoTime, duration) {
  229. this.photoHistoryList = [];
  230. let photoList = [duration];
  231. let pre = duration;
  232. if (totalVideoTime > 300) {
  233. while (pre <= totalVideoTime) {
  234. pre += this.randomNum(780, 900);
  235. pre <= totalVideoTime && photoList.push(pre);
  236. }
  237. if (totalVideoTime - 300 > photoList.slice(-1)[0]) {
  238. photoList.push(this.randomNum(totalVideoTime - 180, totalVideoTime));
  239. }
  240. }
  241. return photoList;
  242. },
  243. //postTime = true 只提交随机时间 false 提交拍照
  244. postCoursePhotoRecord(postTime = false, photoUrl) {
  245. return new Promise((resolve, reject) => {
  246. let currentTime = this.player.j2s_getCurrentTime();
  247. let data = {
  248. goodsId: this.goodsData.goodsId,
  249. gradeId: this.goodsData.gradeId,
  250. courseId: this.activeSection.courseId,
  251. moduleId: this.activeSection.moduleId,
  252. chapterId: this.activeSection.chapterId,
  253. sectionId: this.activeSection.sectionId,
  254. photo: postTime ? "" : photoUrl,
  255. photoTime: parseInt(currentTime > 0 ? currentTime : 0),
  256. photoIndex: postTime ? -2 : parseInt(this.photoIndex), //从0算起,-2只提交随机时间
  257. photoNum: parseInt(this.goodsData.goodsPhotographConfig.photoNum),
  258. timeInterval: postTime ? this.photoList.join(",") : ""
  259. };
  260. this.$request
  261. .coursePhotoRecord(data)
  262. .then(res => {
  263. resolve(res);
  264. })
  265. .catch(err => {
  266. reject();
  267. });
  268. });
  269. },
  270. //随机拍摄时间
  271. randomNum(minNum, maxNum) {
  272. switch (arguments.length) {
  273. case 1:
  274. return parseInt(Math.random() * minNum + 1, 10);
  275. break;
  276. case 2:
  277. return parseInt(Math.random() * (maxNum - minNum + 1) + minNum, 10);
  278. break;
  279. default:
  280. return 0;
  281. break;
  282. }
  283. },
  284. // 播放视频
  285. loadPlayer() {
  286. return new Promise(resolve => {
  287. var self = this;
  288. const polyvPlayer = window.polyvPlayer;
  289. self.$request
  290. .obtainpolyvvideosign(self.activeSection.recordingUrl)
  291. .then(res => {
  292. self.player = polyvPlayer({
  293. wrap: "#player",
  294. width: 810,
  295. height: 455,
  296. showLine: true, //是否显示线路选择按钮
  297. ban_history_time: "on", //是否禁用续播功能,取值:{on,off}。
  298. vid: self.activeSection.recordingUrl,
  299. autoplay: this.goodsData.goodsPhotographConfig.autoplay, // 是否自动播放。
  300. ban_seek: this.goodsData.goodsPhotographConfig.isAllowSeek, //是否禁止拖拽进度条,取值:{on,off}。
  301. speed: this.goodsData.goodsPhotographConfig.playbackRate, //当speed参数值为boolean类型时,代表是否显示倍速切换的按钮。
  302. teaser_show: 1, //是否播放片头:0 不播放,1 播放。片头可在管理后台进行设置。
  303. tail_show: 1, //是否播放片尾:0 不播放,1 播放。片尾可在管理后台进行设置。
  304. hideSwitchPlayer: true, //是否隐藏H5和Flash播放器的切换按钮。
  305. watchStartTime: this.activeSection.videoCurrentTime || 0, // 播放开始时间,表示视频从第几秒开始播放,参数值需小于视频时长。
  306. ts: res.data.ts, //移动播放加密视频需传入的时间戳。
  307. sign: res.data.sign, //移动端播放加密视频所需的签名。
  308. playsafe: function(vid, next) {
  309. self.$request.obtainpolyvvideopcsign(vid).then(res => {
  310. next(res.data);
  311. });
  312. } //PC端播放加密视频所需的授权凭证。
  313. });
  314. resolve();
  315. return;
  316. this.player.HTML5.video.addEventListener(
  317. "timeupdate",
  318. self.timeEvent
  319. );
  320. this.player.on("s2j_onPlayStart", () => {
  321. //开始播放每5秒提交一次观看时间
  322. this.hasStart = true;
  323. clearInterval(this.postTimer);
  324. this.postTimer = setInterval(() => {
  325. this.postStudyRecord(0, this.playSectionId, 5);
  326. }, 30000);
  327. if (this.recordObj.videoCurrentTime) {
  328. this.showRecordStatus = true;
  329. setTimeout(() => {
  330. this.showRecordStatus = false;
  331. }, 5000);
  332. } else {
  333. //新视频直接提交一条观看记录
  334. // this.postStudyRecord(0);
  335. this.showRecordStatus = false;
  336. }
  337. });
  338. this.player.on("s2j_onVideoPause", () => {
  339. clearInterval(this.postTimer);
  340. if (
  341. this.sectionItem.learning != 1 &&
  342. this.goodsData.erJianErZao
  343. ) {
  344. console.log(123);
  345. this.videoPause = setTimeout(() => {
  346. if (!this.takePhotoModal) {
  347. if (this.isFullScreen()) {
  348. this.exitFullscreen();
  349. }
  350. this.confirmStatus = true;
  351. this.$confirm("检测暂停时间过长,刷新当前页面", "提示", {
  352. confirmButtonText: "确定",
  353. cancelButtonText: "取消",
  354. showCancelButton: false,
  355. closeOnClickModal: false,
  356. closeOnPressEscape: false,
  357. showClose: false,
  358. type: "warning"
  359. })
  360. .then(() => {
  361. this.$router.go(0);
  362. this.confirmStatus = false;
  363. })
  364. .catch(() => {
  365. this.confirmStatus = false;
  366. });
  367. }
  368. }, 300000);
  369. }
  370. });
  371. this.player.on("s2j_onVideoPlay", () => {
  372. if (this.postTimer) {
  373. this.postTimer = setInterval(() => {
  374. this.postStudyRecord(0, this.playSectionId, 5);
  375. }, 30000);
  376. }
  377. if (this.sectionItem.learning != 1 && this.videoPause) {
  378. clearTimeout(this.videoPause);
  379. }
  380. });
  381. this.player.on("s2j_onPlayOver", () => {
  382. this.hasStart = false;
  383. clearInterval(this.postTimer);
  384. this.$message({
  385. type: "success",
  386. message: "播放完毕"
  387. });
  388. if (this.isFullScreen()) {
  389. this.exitFullscreen();
  390. }
  391. this.postStudyRecord(1);
  392. });
  393. });
  394. });
  395. },
  396. //监听器
  397. timeEvent() {
  398. // 定时提交学习记录
  399. this.submitStudyRecords();
  400. //拍照监听执行
  401. this.watchPhoto();
  402. },
  403. //拍照监听执行
  404. watchPhoto() {
  405. if (this.photoList.length == 0 || this.activeSection.learning == 1)
  406. return;
  407. let videoTime = this.player.j2s_getCurrentTime();
  408. let photoTime = 0; //获取拍照秒数
  409. for (let i = 0; i < this.photoList.length; i++) {
  410. photoTime = Number(this.photoList[i]); //获取拍照秒数
  411. if (photoTime < videoTime && photoTime > videoTime - 8) {
  412. //3秒区间内才触发拍照,避免拉动滚动条
  413. if (
  414. this.photoHistoryList.indexOf(i) < 0 &&
  415. this.activeSection.learning != 1
  416. ) {
  417. //不存在拍照历史,没有重修过,没有学过,则拍照
  418. this.player.j2s_pauseVideo(); //暂停
  419. this.photoIndex = i;
  420. this.openPhoto(); //启动拍照
  421. }
  422. }
  423. }
  424. },
  425. // 定时提交学习记录
  426. submitStudyRecords() {
  427. let time = new Date().getTime();
  428. if (time >= this.commitTime) {
  429. this.postStudyRecord(0);
  430. this.commitTime = time + 15000;
  431. }
  432. },
  433. //视频初次播放时触发
  434. onPlayStatus() {
  435. //计算拍照逻辑
  436. this.photoLogic();
  437. //开启上次播放位置提示
  438. if (this.activeSection.videoCurrentTime) {
  439. this.showRecordStatus = true;
  440. this.showRecordSetTimeOut = setTimeout(() => {
  441. this.showRecordStatus = false;
  442. }, 5000);
  443. }
  444. console.log("视频初次播放时触发", this.player.j2s_getCurrentTime());
  445. },
  446. //视频暂停时触发
  447. onVideoPause() {
  448. console.log("视频暂停时触发");
  449. },
  450. //当前视频播放完毕时触发
  451. onPlayOver() {
  452. this.$message({
  453. type: "success",
  454. message: "播放完毕"
  455. });
  456. this.isFullScreen();
  457. this.postStudyRecord(1);
  458. console.log("当前视频播放完毕时触发");
  459. },
  460. //判断是全屏则退出全屏
  461. isFullScreen() {
  462. if (!!(document.webkitIsFullScreen || this.fullele())) {
  463. try {
  464. var de = document;
  465. if (de.exitFullscreen) {
  466. de.exitFullscreen();
  467. } else if (de.mozCancelFullScreen) {
  468. de.mozCancelFullScreen();
  469. } else if (de.webkitCancelFullScreen) {
  470. de.webkitCancelFullScreen();
  471. }
  472. } catch (err) {}
  473. }
  474. },
  475. fullele() {
  476. return (
  477. document.fullscreenElement ||
  478. document.webkitFullscreenElement ||
  479. document.msFullscreenElement ||
  480. document.mozFullScreenElement ||
  481. null
  482. );
  483. },
  484. //播放出现错误时触发
  485. onPlayerError() {
  486. this.$message.error("播放出现错误时触发");
  487. },
  488. //发生业务逻辑错误
  489. serverError() {
  490. this.$message.error("发生业务逻辑错误");
  491. },
  492. //启动拍照
  493. openPhoto() {
  494. this.$refs.takePicture.openPhoto();
  495. },
  496. //拍照成功回显 url
  497. async returnParameter(url) {
  498. let compareFaceData = await this.faceRecognition(url);
  499. if (compareFaceData >= 80) {
  500. let file = this.$tools.convertBase64UrlToBlob(url);
  501. const photoUrl = await this.$upload.upload(file, 0, {
  502. gradeId: this.goodsData.gradeId,
  503. orderGoodsId: this.goodsData.orderGoodsId
  504. });
  505. this.postCoursePhotoRecord(false, photoUrl)
  506. .then(async res => {
  507. this.photoHistoryList.push(this.photoIndex);
  508. const STATUS = await this.postStudyRecord(
  509. 0,
  510. photoUrl,
  511. compareFaceData
  512. ); //提交记录
  513. //恢复播放
  514. if (STATUS) {
  515. var polyvPlayerContext = this.player;
  516. if (polyvPlayerContext && this.openPhotoStatus !== 1) {
  517. polyvPlayerContext.j2s_resumeVideo();
  518. }
  519. }
  520. })
  521. .catch(err => {
  522. this.$message({
  523. type: "warning",
  524. message: "上传接口报错,请重新拍照上传"
  525. });
  526. setTimeout(() => {
  527. this.openPhoto();
  528. }, 1500);
  529. });
  530. } else {
  531. this.$message({
  532. type: "warning",
  533. message: "人脸匹配不通过,请重新拍照上传"
  534. });
  535. setTimeout(() => {
  536. this.openPhoto();
  537. }, 1500);
  538. }
  539. },
  540. /**
  541. * 提交观看记录
  542. * status 1 学完 0未学完
  543. */
  544. postStudyRecord(status = 0, imgUrl, compareFaceData) {
  545. return new Promise((resolve, reject) => {
  546. let currentTime = 0;
  547. let PlayDuration = 0;
  548. var polyvPlayerContext = this.player;
  549. if (polyvPlayerContext) {
  550. currentTime = polyvPlayerContext.j2s_getCurrentTime(); //当前视频播放时刻
  551. PlayDuration = polyvPlayerContext.j2s_realPlayVideoTime(); //本次看的时长
  552. }
  553. let data = {
  554. orderGoodsId: parseInt(this.goodsData.orderGoodsId),
  555. goodsId: parseInt(this.goodsData.goodsId),
  556. gradeId: parseInt(this.goodsData.gradeId),
  557. courseId: this.activeSection.courseId,
  558. moduleId: this.activeSection.moduleId,
  559. chapterId: this.activeSection.chapterId,
  560. sectionId: this.activeSection.sectionId,
  561. fromPlat: 2, //来源平台 1小程序 2网站
  562. photo: imgUrl || "",
  563. studyDuration: parseInt(PlayDuration > 0 ? PlayDuration : 0),
  564. videoCurrentTime: parseInt(currentTime > 0 ? currentTime : 0),
  565. erJianErZao: this.goodsData.erJianErZao
  566. };
  567. if (imgUrl) {
  568. data.similarity = compareFaceData; // 相似度
  569. }
  570. if (status > 0) {
  571. data.status = status;
  572. }
  573. // /study/record 学习记录
  574. this.$request
  575. .studyRecord(data)
  576. .then(res => {
  577. if (status > 0) {
  578. this.openPhotoStatus = 0;
  579. this.$message.success("学习完成");
  580. resolve(false);
  581. }
  582. if (this.openPhotoStatus === 1) {
  583. this.postStudyRecord(1);
  584. }
  585. if (status == 0 && this.openPhotoStatus !== 1) {
  586. resolve(true);
  587. }
  588. })
  589. .catch(err => {
  590. if (err.code === 600) {
  591. polyvPlayerContext.j2s_pauseVideo();
  592. this.$confirm(`开通信息推送不成功,无法学习!`, "提示", {
  593. confirmButtonText: "确定",
  594. closeOnClickModal: false,
  595. closeOnPressEscape: false,
  596. distinguishCancelAndClose: false,
  597. showCancelButton: false,
  598. showClose: false
  599. })
  600. .then(_ => {
  601. //停止执行-退出页面
  602. this.$router.back(-1);
  603. })
  604. .catch(_ => {
  605. //停止执行-退出页面
  606. this.$router.back(-1);
  607. });
  608. }
  609. if (err.code === 559) {
  610. console.log("拍照不够触发");
  611. this.$message.error(err.msg);
  612. this.openPhotoStatus = 1;
  613. setTimeout(() => {
  614. this.openPhoto();
  615. }, 1500);
  616. }
  617. if (err.code === 558) {
  618. this.$message.error(err.msg);
  619. }
  620. });
  621. });
  622. },
  623. //人脸校验
  624. faceRecognition(url) {
  625. return new Promise(resolve => {
  626. this.$request
  627. .faceCertificationCompareFace({
  628. imageA: url,
  629. orderGoodsId: this.goodsData.orderGoodsId,
  630. gradeId: this.goodsData.gradeId
  631. })
  632. .then(res => {
  633. resolve(res.data);
  634. })
  635. .catch(err => {
  636. if (err.toString().indexOf("timeout") != -1) {
  637. err = {
  638. msg: "拍照超时,请重新拍照"
  639. };
  640. }
  641. this.$message({
  642. type: "warning",
  643. message: err.msg
  644. });
  645. setTimeout(() => {
  646. this.openPhoto();
  647. }, 1500);
  648. });
  649. });
  650. }
  651. }
  652. };
  653. </script>
  654. <style lang="scss" scoped>
  655. #videoCy {
  656. width: 100%;
  657. height: 100%;
  658. background: url() no-repeat center center;
  659. background-size: contain;
  660. position: relative;
  661. }
  662. .recordStyle {
  663. position: absolute;
  664. bottom: 60px;
  665. padding: 6px 12px;
  666. left: 8px;
  667. background-color: rgba(0, 0, 0, 0.4);
  668. color: #fff;
  669. border-radius: 24px;
  670. user-select: none;
  671. .videoCurrentTime_style {
  672. display: inline-block;
  673. width: 50px;
  674. text-align: center;
  675. }
  676. .btn_sty {
  677. cursor: pointer;
  678. }
  679. }
  680. </style>