detail.vue 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909
  1. <template>
  2. <view class="polyv_detail">
  3. <uni-nav-bar left-icon="back" :statusBar="true" fixed="true" :title="detail.courseName || '课程详情'"
  4. @clickLeft="clickLeft"></uni-nav-bar>
  5. <view id="top">
  6. <view class="video_box" v-if="!playVid">
  7. <image :src="$method.splitImgHost(goodsData.coverUrl)" mode="widthFix"
  8. style="width: 100%; height: 421rpx">
  9. </image>
  10. </view>
  11. <view v-else>
  12. <my-player ref="player" :playVid="playVid" :autoplay="autoplay" :allowSeek="isAllowSeek"
  13. :playbackRate="playbackRate" :videoCurrentTime="videoCurrentTime || 0" @playing="playing"
  14. @pause="pause" @ended="ended" @loadedmetadata="loadedmetadata" @timeupdate="timeupdate"
  15. @playerError="playerError" @studyLog="studyLog"></my-player>
  16. </view>
  17. <view class="course_name">
  18. <view class="course_titles">
  19. <view class="video_t1" :class="{ one: !goodsData.buyNote }">{{
  20. detail.courseName
  21. }}</view>
  22. <view class="notice_wrap" v-if="goodsData.buyNote">
  23. <view class="video_t1_t" @click="studyNotice"> 学员须知 </view>
  24. </view>
  25. <view class="toggle_course" v-if="goodsTeacher.length > 1" @click="changeCourses()">
  26. <image class="img" src="/pages3/static/imgs/toggle.png" mode="widthFix"></image>
  27. <view class="toggle_name">切换课程</view>
  28. <view class="numbers">共{{ goodsTeacher.length }}门</view>
  29. </view>
  30. </view>
  31. </view>
  32. <u-line color="#D6D6DB" />
  33. <view>
  34. <view>
  35. <u-tabs :item-width="itemWidth()" :list="list" font-size="32" bar-width="24" :current="current"
  36. @change="change" active-color="#007AFF"></u-tabs>
  37. </view>
  38. </view>
  39. <u-line color="#D6D6DB" />
  40. </view>
  41. <view class="box" :class="{ first_ml: current == 0 }">
  42. <scroll-view class="box_in" scroll-y="true">
  43. <!--目录 -->
  44. <view v-show="current == 0">
  45. <view class="top__header" v-if="livingItem" @click="goLive(livingItem)">
  46. <image class="img" src="/pages3/static/imgs/live.png" mode="widthFix"></image>
  47. <view class="note">正在直播中</view>
  48. <view class="title">{{ livingItem.sectionName }}</view>
  49. </view>
  50. <course-tree v-if="sectionItem.id || sectionItem.sectionId" :sectionMaxNum="goodsData.sectionMaxNum"
  51. :isRebuild="false" :isBuy="true" @isHaverebuild="isHaverebuild = true"></course-tree>
  52. </view>
  53. <!--讲义 -->
  54. <view v-if="current == 1">
  55. <handouts-box :handoutsId="goodsData.handoutsId"></handouts-box>
  56. </view>
  57. <!--笔记 -->
  58. <view v-if="current == 2">
  59. <note-Box @jumpNote="jumpNote"></note-Box>
  60. </view>
  61. <!--答疑 -->
  62. <view v-if="current == 3">
  63. <answer-box :userId="userInfo ? userInfo.userId : 0"></answer-box>
  64. </view>
  65. <!--重修目录 -->
  66. <view v-if="current == 4">
  67. <course-tree v-if="sectionItem.id || sectionItem.sectionId" :sectionMaxNum="goodsData.sectionMaxNum"
  68. :isRebuild="true" :isBuy="true"></course-tree>
  69. </view>
  70. </scroll-view>
  71. </view>
  72. <u-popup v-model="noticeShow" class="notice_modal" mode="center" border-radius="28" width="650rpx"
  73. height="622rpx" :mask-close-able="false">
  74. <view class="content">
  75. <view class="title">学员须知</view>
  76. <scroll-view scroll-y="true">
  77. <view class="text" v-html="
  78. goodsData.buyNote && goodsData.buyNote.replace(/\n|\r\n/g, '<br>')
  79. ">
  80. </view>
  81. </scroll-view>
  82. <view class="had_read" :class="{ gray: CountTo > 0 }" @click="noticeConfirm()">
  83. <text v-if="CountTo > 0">请阅读学员须知,{{ " " + CountTo + "s" }}后可关闭</text>
  84. <text v-else>我已阅读学员须知</text>
  85. </view>
  86. </view>
  87. </u-popup>
  88. <!-- 倒计时提交 -->
  89. <u-popup v-model="noticeShow1" class="notice_modal" mode="center" border-radius="28" width="650rpx"
  90. height="262rpx" :mask-close-able="false">
  91. <view class="content">
  92. <view class="title">提示</view>
  93. <view class="had_read">
  94. <text v-if="CountTo1 >= 0">视频学习时长不达标,请等待</text>
  95. <text v-if="CountTo1 >= 0">{{ " " + CountTo1 + "s" }}</text>
  96. </view>
  97. </view>
  98. </u-popup>
  99. <u-modal v-model="showMark" title="提示" @confirm="markConfirm" @cancel="toBack" confirm-text="复制学习网址"
  100. :show-cancel-button="true" cancel-text="关闭">
  101. <view class="slot-content">
  102. <view>您的学习账号已经开通,请按照步骤操作,进行学习。</view>
  103. <view>1.复制学习地址:{{ markContent }}</view>
  104. <view>2.在【浏览器中】打开复制的学习网址</view>
  105. <view>3.打开学习网址后,选择【个人用户】进行登录</view>
  106. <view>(1)账号:您个人的身份证号码</view>
  107. <view>(2)密码:身份证号码,再加111111</view>
  108. </view>
  109. </u-modal>
  110. <!-- 切换课程弹窗 -->
  111. <u-popup v-model="toggleCourseShow" mode="bottom" border-radius="40" :mask-close-able="false">
  112. <view class="popup_box">
  113. <view class="check_head">
  114. <view class="headers">
  115. <view class="grade">切换课程</view>
  116. <u-icon name="close" color="#9C9C9C" size="40" @click="closePop()"></u-icon>
  117. </view>
  118. <view class="coruse_num">共{{ goodsTeacher.length }}门</view>
  119. <view class="menuSel">
  120. <scroll-view class="sub_sliper" scroll-x="true">
  121. <view v-for="(item, index) in subList" :key="index"
  122. style="margin-right: 50rpx; display: inline-block">
  123. <view class="r_t1" :class="{ nactive: subIndex == index }" @click="cMenu(item, index)">
  124. {{ item.subjectName }}
  125. </view>
  126. </view>
  127. </scroll-view>
  128. </view>
  129. </view>
  130. <view class="check_con">
  131. <scroll-view scroll-y="true" style="height: 700rpx">
  132. <view v-for="(courseItem, gTindex) in goodsTeacher" :key="gTindex">
  133. <view v-for="(item, index) in courseItem.courseList" :key="index" v-show="
  134. item.subjectId === newActiveSubjectId || !newActiveSubjectId
  135. ">
  136. <view class="course_items" v-if="item.show && item.show == 1">
  137. <view class="course_lefts">
  138. <view class="course_title">
  139. {{ item.courseName }}
  140. </view>
  141. <view v-if="courseItem.teaList && courseItem.teaList.length > 0"
  142. class="teacher_names">
  143. <view v-for="(tea, tindex) in courseItem.teaList" :key="tindex"
  144. class="names">{{ tea.aliasName }}
  145. </view>
  146. </view>
  147. <view class="course_pros">
  148. 学习进度
  149. <text>
  150. {{ item.stuAllNum + item.recordNum }}/{{
  151. item.secAllNum + item.examNum
  152. }}</text>
  153. </view>
  154. </view>
  155. <view class="course_rights" @click="jump(item, gTindex, 'jump')">
  156. <view class="cicles">
  157. <u-icon name="arrow-right" color="#498AFE" size="20"></u-icon>
  158. </view>
  159. <view class="intoStudy">进入学习</view>
  160. </view>
  161. </view>
  162. </view>
  163. </view>
  164. </scroll-view>
  165. </view>
  166. </view>
  167. </u-popup>
  168. <!-- 摄像头 -->
  169. <Popup-camera @submitPhoto="submitPhoto" :visible.sync="showCamera" ref="camera" />
  170. </view>
  171. </template>
  172. <script>
  173. import handoutsBox from "@/components/course/handoutsBox.vue";
  174. import courseTree from "@/components/course/courseTree.vue";
  175. import PopupCamera from "../../components/popup/camera.vue";
  176. import myPlayer from "@/components/myPlayer/polyvPlayer.vue";
  177. import noteBox from "@/components/course/noteBox.vue";
  178. import answerBox from "@/components/course/answerBox.vue";
  179. import {
  180. mapGetters,
  181. mapMutations
  182. } from "vuex";
  183. import {
  184. lockAction
  185. } from "../../utils/lock";
  186. import {
  187. debounce,
  188. throttle,
  189. reload
  190. } from "../../utils/common";
  191. export default {
  192. components: {
  193. handoutsBox,
  194. myPlayer,
  195. noteBox,
  196. answerBox,
  197. courseTree,
  198. PopupCamera,
  199. },
  200. data() {
  201. return {
  202. markContent: "http://admin.zhujianpeixun.com/",
  203. showMark: false,
  204. lockTimer: null,
  205. orderGoodsId: 0,
  206. noticeShow: false,
  207. showSet: false,
  208. courseId: 0,
  209. current: 0,
  210. vid: "",
  211. goodsId: 0,
  212. goodsData: {},
  213. showCamera: false,
  214. goodsPlayConfig: null,
  215. autoplay: false,
  216. isAllowSeek: "no",
  217. playbackRate: [1.0],
  218. timer: null,
  219. goodsPhotographConfig: null,
  220. playTime: 0, // 播放时刻
  221. avatarUrl: "",
  222. ossAvatarUrl: "",
  223. gradeId: 0,
  224. chapterId: 0,
  225. moduleId: 0,
  226. videoCurrentTime: 0,
  227. photoIndex: 0,
  228. photoNum: 0,
  229. photoList: [], //拍照的时间点
  230. photoConfig: false, //是否配置好拍照次数
  231. photoHistoryList: [], //已拍照历史的下标点
  232. sectionItem: {},
  233. isRebuild: false, //视频是否从重修目录点击
  234. livingItem: "",
  235. option: null,
  236. toggleCourseShow: false, // 切换课程弹窗
  237. courseList: [], // 课程列表
  238. subList: [],
  239. subIndex: 0,
  240. goodsTeacher: [],
  241. teacherList: [],
  242. teacherIndex: 0,
  243. newActiveSubjectId: "", //当前选中ID
  244. compareFaceData: 0, // 拍照匹配相似度
  245. prendreAutoCarme: false, // 是否发起授权相机
  246. CountTo: 0, // 倒计时
  247. CountTo1: 0,
  248. menuAllList: [],
  249. curPlayIndex: 0, // 正在播放的节的下标
  250. faceUrl: "",
  251. erJianErZao: false,
  252. jjShiGongYuan: false,
  253. pauseTime: 0,
  254. pauseTimer: null,
  255. isReach: false,
  256. noticeShow1: false,
  257. refPlv: null,
  258. isCache: false,
  259. isHaverebuild: false,
  260. isPlaying: false,
  261. beforeHideIsPlaying: false,
  262. isLeave: false,
  263. text: "",
  264. throttleFn: throttle(this.postStudyRecord, 15000),
  265. };
  266. },
  267. computed: {
  268. ...mapGetters(["userInfo", "config"]),
  269. playSecIsLearn() {
  270. if (!this.playVid) {
  271. return false;
  272. }
  273. return this.sectionItem.learning != 1;
  274. },
  275. orderNum() {
  276. return this.goodsData.goodsLearningOrder;
  277. },
  278. list() {
  279. let list = [{
  280. name: "目录",
  281. },
  282. {
  283. name: "讲义",
  284. },
  285. {
  286. name: "笔记",
  287. },
  288. {
  289. name: "答疑",
  290. },
  291. ];
  292. if (this.isHaverebuild) {
  293. list.push({
  294. name: "重修目录"
  295. });
  296. }
  297. return list;
  298. },
  299. params: function() {
  300. return (keys = ["orderGoodsId", "goodsId", "courseId"]) => {
  301. let params = {};
  302. for (const key of keys) {
  303. params[key] = this[key];
  304. }
  305. return params;
  306. };
  307. },
  308. detail() {
  309. if (!this.courseId || !this.courseList.length) {
  310. return {};
  311. }
  312. return this.courseList.find((e) => e.courseId == this.courseId);
  313. },
  314. sectionId() {
  315. return this.sectionItem.sectionId || this.sectionItem.id;
  316. },
  317. playVid() {
  318. return this.sectionItem.recordingUrl;
  319. },
  320. isPlayRebuild() {
  321. return this.sectionItem.rebuild != 1;
  322. },
  323. },
  324. async onLoad(option) {
  325. if (option.isOther) {
  326. this.showMark = true;
  327. return;
  328. }
  329. this.option = option;
  330. let {
  331. skipPort,
  332. id,
  333. goodsId,
  334. orderGoodsId,
  335. gradeId,
  336. informId
  337. } = option;
  338. this.orderGoodsId = Number(orderGoodsId) || "";
  339. this.courseId = Number(id) || "";
  340. this.goodsId = Number(goodsId);
  341. this.gradeId = Number(gradeId);
  342. this.isLeave = false;
  343. uni.addInterceptor("navigateTo", {
  344. success: (e) => {
  345. this.isLeave = true;
  346. this.isCache = true;
  347. },
  348. });
  349. if (skipPort) {
  350. await this.$method.skipLogin(skipPort);
  351. }
  352. if (this.$method.isGoLogin()) {
  353. return;
  354. }
  355. if (!this.lockTimer) {
  356. lockAction();
  357. this.lockTimer = setInterval(lockAction, 10000);
  358. }
  359. // 公众号模板消息的数据埋点
  360. informId && this.clickOfficial(informId);
  361. this.init();
  362. },
  363. async onShow() {
  364. if (!this.$method.isLogin()) {
  365. return;
  366. }
  367. if (this.isCache) {
  368. console.log("返回刷新数据");
  369. this.isCache = false;
  370. this.sectionItem = {};
  371. this.beforeHideIsPlaying = false;
  372. reload(this.option);
  373. return;
  374. }
  375. if (this.beforeHideIsPlaying) {
  376. console.log("显示重新播放");
  377. if (this.text) {
  378. this.refPlv.playPause();
  379. return;
  380. }
  381. this.refPlv.resumeVideo();
  382. }
  383. },
  384. onUnload() {
  385. console.log("onUnload");
  386. if (this.isPlaying) {
  387. this.postStudyRecord();
  388. }
  389. this.refPlv = null;
  390. uni.$off();
  391. this.clearPauseTimer();
  392. uni.removeInterceptor("navigateTo");
  393. if (this.lockTimer) {
  394. clearInterval(this.lockTimer);
  395. this.$api.lockDelLock({
  396. action: "jxjy",
  397. uuid: this.$method.getUuid(),
  398. });
  399. }
  400. },
  401. onHide() {
  402. this.beforeHideIsPlaying = this.isPlaying;
  403. if (this.isPlaying) {
  404. this.refPlv.playPause();
  405. }
  406. },
  407. mounted() {},
  408. methods: {
  409. ...mapMutations(["updateChapterOpen", "updateLiveLast"]),
  410. async init() {
  411. // #ifdef MP-WEIXIN
  412. this.isAllowSeek = "no";
  413. // #endif
  414. // #ifdef H5
  415. this.isAllowSeek = "on";
  416. // #endif
  417. this.photoList = [];
  418. this.courseList = [];
  419. this.photoConfig = false;
  420. await this.isCanLearn();
  421. this.courseCourseList();
  422. },
  423. // 七大员是否能进入学习
  424. async qCheckIsCanLearn() {
  425. let res = await this.$api.qCheckIsCanLearn(this.orderGoodsId);
  426. if (res.data.code !== 200) {
  427. uni.showModal({
  428. showCancel: false,
  429. title: "提示",
  430. content: res.data.msg,
  431. success: (resultst) => {
  432. uni.navigateBack();
  433. },
  434. });
  435. return Promise.reject();
  436. }
  437. let res1 = await this.$api.syncSevenPublicClass({
  438. orderGoodsId: this.orderGoodsId,
  439. });
  440. if (res1.data.code !== 200) {
  441. uni.showModal({
  442. showCancel: false,
  443. title: "提示",
  444. content: "无法进入学习!",
  445. success: (resultst) => {
  446. uni.navigateBack();
  447. },
  448. });
  449. return Promise.reject();
  450. }
  451. },
  452. // 新增微信公众号模板消息点击数据
  453. clickOfficial(informId) {
  454. this.$http({
  455. url: "/data/click",
  456. method: "post",
  457. data: {
  458. informId
  459. },
  460. });
  461. },
  462. // 点击课程目录
  463. cMenu(item, index) {
  464. this.subIndex = index;
  465. this.newActiveSubjectId = item.subjectId;
  466. },
  467. courseCourseList() {
  468. this.$api
  469. .courseCourseList({
  470. pageNum: 1,
  471. pageSize: 200,
  472. ...this.params(["goodsId", "orderGoodsId", "gradeId"]),
  473. })
  474. .then((res) => {
  475. if (res.data.code == 200) {
  476. this.courseList = res.data.rows;
  477. if (res.data.total > 1) {
  478. // 科目
  479. this.subList = [{
  480. subjectId: 0,
  481. subjectName: "所有"
  482. }];
  483. this.courseList.forEach((item) => {
  484. if (!this.subList.find((e) => e.subjectId == item.subjectId)) {
  485. this.subList.push(item);
  486. }
  487. });
  488. this.getUserWatchLast();
  489. } else {
  490. this.originOnShow();
  491. this.originMounted();
  492. }
  493. }
  494. });
  495. },
  496. // 查询用户最后一次看的录播的信息
  497. getUserWatchLast() {
  498. this.$http({
  499. url: "/study/record/getUserWatchLast",
  500. method: "get",
  501. data: {
  502. orderGoodsId: this.orderGoodsId,
  503. },
  504. }).then((res) => {
  505. if (res.data.code == 200 && res.data.data) {
  506. this.courseId = res.data.data.courseId;
  507. }
  508. if (!this.courseId) {
  509. this.courseId = this.courseList[0].courseId;
  510. }
  511. this.originOnShow();
  512. this.originMounted();
  513. //获取商品双师资模板
  514. this.getCourseTeacher(this.courseList);
  515. });
  516. },
  517. getCourseTeacher(rows) {
  518. this.goodsTeacher = [];
  519. //获取商品双师资模板
  520. this.$api
  521. .courseTeacherList({
  522. goodsId: this.goodsId,
  523. })
  524. .then((res1) => {
  525. if (res1.data.data && res1.data.data.length > 0) {
  526. //课程老师模板
  527. let teacherTel = res1.data.data;
  528. //商品课程
  529. let courses = rows;
  530. teacherTel.forEach((tea) => {
  531. let dataList = [];
  532. let teacherList = [];
  533. courses.forEach((item) => {
  534. let data = tea.courseList.filter(
  535. (x) => x.courseId == item.courseId
  536. );
  537. if (data && data.length > 0) {
  538. dataList.push(item);
  539. teacherList = tea.courseList;
  540. }
  541. });
  542. let result = {
  543. teaList: teacherList,
  544. courseList: dataList,
  545. };
  546. this.goodsTeacher.push(result);
  547. });
  548. if (this.goodsTeacher && this.goodsTeacher.length > 0) {
  549. let courseIds = [];
  550. this.goodsTeacher.forEach((item) => {
  551. item.courseList.forEach((course) => {
  552. courseIds.push(course.courseId);
  553. });
  554. });
  555. if (courseIds.length > 0) {
  556. courses.forEach((item) => {
  557. if (!courseIds.includes(item.courseId)) {
  558. let data = {
  559. teaList: [],
  560. courseList: [],
  561. };
  562. data.courseList.push(item);
  563. this.goodsTeacher.push(data);
  564. }
  565. });
  566. }
  567. this.goodsTeacher.forEach((item) => {
  568. if (item.courseList && item.courseList.length > 0) {
  569. item.courseList[0].show = 1;
  570. }
  571. });
  572. }
  573. } else {
  574. //没有双师资模板
  575. rows.forEach((item) => {
  576. item.show = 1;
  577. let data = {
  578. teaList: [],
  579. courseList: [],
  580. };
  581. data.courseList.push(item);
  582. this.goodsTeacher.push(data);
  583. });
  584. }
  585. this.goodsTeacher.forEach((item) => {
  586. if (item.courseList.some((x) => x.courseId == this.courseId)) {
  587. this.teacherList = item.teaList;
  588. }
  589. });
  590. });
  591. },
  592. erJianErZaoPauseTip() {
  593. if (this.playSecIsLearn && this.erJianErZao && !this.isLeave) {
  594. if (this.pauseTimer) {
  595. return;
  596. }
  597. this.pauseTime = Date.now();
  598. this.pauseTimer = setInterval(() => {
  599. console.log("暂停时间", Date.now() - this.pauseTime, this.pauseTime);
  600. if (Date.now() - this.pauseTime > 5 * 60 * 1000) {
  601. // 5 * 60 * 1000
  602. this.refPlv.exitFullScreen();
  603. this.text = "暂停";
  604. if (this.showCamera) {
  605. this.text = "拍照停留";
  606. this.closeCamera();
  607. }
  608. uni.showModal({
  609. title: "提示",
  610. showCancel: false,
  611. content: `检测${this.text}时间过长,刷新当前页面`,
  612. cancelText: "取消",
  613. confirmText: "确定",
  614. success: (res) => {
  615. this.text = "";
  616. reload(this.option);
  617. // #ifdef MP-WEIXIN
  618. this.sectionItem = {};
  619. // #endif
  620. },
  621. });
  622. this.clearPauseTimer();
  623. }
  624. }, 5000);
  625. }
  626. },
  627. // 原来onshow里面的内容
  628. async originOnShow() {
  629. await this.studyRecordMenuAllList();
  630. // 消息过来 定位某个节
  631. if (this.option.noteSecond) {
  632. this.jumpNote({
  633. sectionType: 1,
  634. ...this.option,
  635. });
  636. return;
  637. }
  638. this.studyRecordQueryLiveLast();
  639. },
  640. // 原来的mouted内容
  641. originMounted() {
  642. uni.$on(
  643. "getSection",
  644. debounce((item) => {
  645. if (!this.refPlv && this.playVid) {
  646. this.refPlv = this.$refs.player;
  647. }
  648. if (this.isPlaying) {
  649. this.refPlv.playPause();
  650. }
  651. this.photoConfig = false;
  652. this.photoList = [];
  653. this.moduleId = item.moduleId || 0;
  654. this.chapterId = item.chapterId || 0;
  655. this.sectionItem = item;
  656. this.playVideo(item);
  657. this.postStudyRecord(0);
  658. })
  659. );
  660. uni.$on("isRebuild", (item) => {
  661. this.isRebuild = item;
  662. });
  663. this.updateChapterOpen(true);
  664. },
  665. clearPauseTimer() {
  666. if (this.pauseTimer) {
  667. this.pauseTime = 0;
  668. clearInterval(this.pauseTimer);
  669. this.pauseTimer = null;
  670. }
  671. },
  672. changeCourses() {
  673. this.toggleCourseShow = true;
  674. },
  675. closePop() {
  676. this.toggleCourseShow = false;
  677. },
  678. async activeFunc(item, index) {
  679. this.teacherIndex = index;
  680. let findResult = "";
  681. this.goodsTeacher.forEach((citem, index) => {
  682. citem.courseList.forEach((e, e_index) => {
  683. if (e.courseId == item.courseId) {
  684. findResult = e;
  685. }
  686. });
  687. });
  688. this.jump(findResult, 1);
  689. },
  690. // 进入学习
  691. async jump(item, index, type) {
  692. if (this.courseId === item.courseId) {
  693. this.toggleCourseShow = false;
  694. return;
  695. }
  696. if (this.orderNum == 2 && index != 0) {
  697. let prevItem = this.courseList[index - 1];
  698. if (
  699. prevItem.stuAllNum + prevItem.recordNum <
  700. prevItem.secAllNum + prevItem.examNum
  701. ) {
  702. uni.showToast({
  703. icon: "none",
  704. title: "请按顺序学完上一课再学习这一课",
  705. });
  706. return;
  707. }
  708. }
  709. // 打回 需重修
  710. if (item.rebuild === 0) {
  711. this.$navTo.togo("/pages2/learn/details", {
  712. id: item.courseId,
  713. ...this.params(["goodsId", "orderGoodsId", "gradeId"]),
  714. });
  715. return;
  716. }
  717. if (type) {
  718. this.teacherIndex = 0;
  719. this.goodsTeacher.forEach((citem) => {
  720. if (citem.courseList.some((x) => x.courseId == item.courseId)) {
  721. this.teacherList = citem.teaList;
  722. }
  723. });
  724. }
  725. this.sectionItem = {};
  726. this.toggleCourseShow = false;
  727. this.courseId = item.courseId;
  728. this.originOnShow();
  729. },
  730. clickLeft() {
  731. uni.switchTab({
  732. url: "/pages/learn/index",
  733. });
  734. },
  735. toBack(delta = 1) {
  736. uni.navigateBack({
  737. delta,
  738. });
  739. },
  740. markConfirm() {
  741. uni.setClipboardData({
  742. data: this.markContent,
  743. success: () => {
  744. setTimeout(this.toBack, 1000);
  745. },
  746. });
  747. },
  748. noticeConfirm() {
  749. if (this.CountTo <= 0) {
  750. this.noticeShow = false;
  751. if (this.autoplay) {
  752. this.refPlv && this.refPlv.resumeVideo();
  753. }
  754. this.$api.baseHandoutTip({
  755. orderGoodsId: this.orderGoodsId,
  756. });
  757. }
  758. },
  759. baseHandoutTipList() {
  760. this.$api
  761. .baseHandoutTipList({
  762. orderGoodsId: this.orderGoodsId,
  763. })
  764. .then((res) => {
  765. if (res.data.rows.length == 0) {
  766. this.noticeShow = true;
  767. this.CountTo = 30;
  768. var timer = setInterval(() => {
  769. this.CountTo--;
  770. if (this.CountTo < 0) {
  771. clearInterval(timer);
  772. }
  773. }, 1000);
  774. }
  775. });
  776. },
  777. /**
  778. * 获取上次观看的直播
  779. */
  780. studyRecordGetLastLive() {
  781. this.$api
  782. .studyRecordGetLastLive({
  783. orderGoodsId: this.orderGoodsId,
  784. courseId: this.courseId,
  785. })
  786. .then((res) => {
  787. this.updateLiveLast(res.data.data);
  788. });
  789. },
  790. async initPlayVideo(sectionItem) {
  791. this.moduleId = sectionItem.moduleId || 0;
  792. this.chapterId = sectionItem.chapterId || 0;
  793. this.sectionItem = sectionItem;
  794. if (sectionItem.sectionType == 1) {
  795. //录播
  796. this.playVideo(sectionItem);
  797. } else if (sectionItem.sectionType == 2) {
  798. //直播
  799. this.studyRecordGetLastLive();
  800. } else if (sectionItem.sectionType == 3) {
  801. //回放
  802. this.playVideo(sectionItem);
  803. } else if (sectionItem.doType == 2) {
  804. uni.showModal({
  805. title: "温馨提示",
  806. content: "当前节视频已学完,是否进入考试?",
  807. success: (res) => {
  808. if (res.confirm) {
  809. this.toQuestionBank(sectionItem);
  810. }
  811. },
  812. });
  813. return;
  814. }
  815. },
  816. async submitPhoto(url, compareFaceData) {
  817. this.ossAvatarUrl = url;
  818. this.compareFaceData = compareFaceData;
  819. this.postCoursePhotoRecord()
  820. .then(async (res) => {
  821. console.log("showCamera1", this.showCamera)
  822. this.photoHistoryList[this.photoIndex] = true;
  823. await this.postStudyRecord();
  824. this.closeCamera();
  825. if (this.isReach) {
  826. console.log("showCamera2", this.showCamera)
  827. await this.postStudyRecord(1);
  828. this.nextSection();
  829. console.log("showCamera3", this.showCamera)
  830. return;
  831. }
  832. console.log("showCamera4", this.showCamera)
  833. this.refPlv.resumeVideo();
  834. })
  835. .catch((err) => {
  836. uni.showToast({
  837. title: "上传接口报错,请重新拍照上传" + err,
  838. icon: "none",
  839. });
  840. this.$refs["camera"].reTake();
  841. });
  842. },
  843. toQuestionBank(sectionItem) {
  844. // type 1模块 2章 3节 4章卷 5模块卷
  845. uni.navigateTo({
  846. url: "/pages2/class/questionBank?courseId=" +
  847. this.courseId +
  848. "&gradeId=" +
  849. this.gradeId +
  850. "&isFromVideo=1&id=" +
  851. sectionItem.id +
  852. "&goodsid=" +
  853. this.goodsId +
  854. "&moduleId=" +
  855. (sectionItem.moduleId || 0) +
  856. "&chapterId=" +
  857. (sectionItem.chapterId || 0) +
  858. "&orderGoodsId=" +
  859. this.orderGoodsId +
  860. "&type=" +
  861. (sectionItem.type == 4 ? 1 : 3) +
  862. "&learning=" +
  863. sectionItem.studyStatus +
  864. "&isBackVideo=" +
  865. 1,
  866. });
  867. },
  868. studyRecordQueryLiveLast() {
  869. this.$api
  870. .studyRecordQueryLiveLast({
  871. gradeId: this.gradeId,
  872. orderGoodsId: this.orderGoodsId,
  873. courseId: this.courseId,
  874. })
  875. .then((res) => {
  876. let {
  877. data
  878. } = res.data;
  879. if (!data.sectionId) {
  880. data = this.menuAllList[0];
  881. }
  882. if (data.learning == 1 && this.orderNum == 2) {
  883. let next = this.menuAllList.find((e) => e.studyStatus != 1);
  884. next && (data = next);
  885. }
  886. this.initPlayVideo(data);
  887. });
  888. },
  889. goLive(item) {
  890. let moduleId = item.moduleId || 0;
  891. let chapterId = item.chapterId || 0;
  892. let sectionId = item.sectionId || item.menuId;
  893. let uuid = new Date().valueOf() + "";
  894. // buyCourse 是否购买课程:1是 0否
  895. let encode = encodeURIComponent(
  896. this.config.hostLive +
  897. "/pages/live/index?token=" +
  898. uni.getStorageSync("token") +
  899. "&userInfo=" +
  900. JSON.stringify(this.userInfo) +
  901. "&channelId=" +
  902. item.liveUrl +
  903. "&gradeId=" +
  904. this.gradeId +
  905. "&courseId=" +
  906. this.courseId +
  907. "&goodsId=" +
  908. this.goodsId +
  909. "&orderGoodsId=" +
  910. this.orderGoodsId +
  911. "&sectionId=" +
  912. sectionId +
  913. "&chapterId=" +
  914. chapterId +
  915. "&moduleId=" +
  916. moduleId +
  917. "&buyCourse=1" +
  918. "&ident=" +
  919. uuid
  920. );
  921. uni.navigateTo({
  922. url: `/pages5/webview/index?url=` + encode,
  923. });
  924. },
  925. studyRecordMenuAllList() {
  926. // study/record/menuAllList
  927. return this.$api
  928. .studMenuAllList({
  929. courseId: this.courseId,
  930. ...this.params(["goodsId", "orderGoodsId", "gradeId"]),
  931. })
  932. .then((res) => {
  933. let nowTime = Number(new Date().getTime() / 1000).toFixed(0);
  934. if (res.data.data) {
  935. this.menuAllList = res.data.data.filter(
  936. (e) => e.doType != 1 || (e.doType == 2 && e.studyStatus == 1)
  937. );
  938. this.livingItem = res.data.data.find(
  939. (item) =>
  940. item.liveStartTime <= nowTime && item.liveEndTime > nowTime
  941. );
  942. }
  943. return Promise.resolve();
  944. });
  945. },
  946. async getbaseprofiletplists() {
  947. let {
  948. data: {
  949. code,
  950. rows
  951. },
  952. } = await this.$api.getbaseprofiletplists({
  953. goodsId: this.goodsId,
  954. orderGoodsId: this.orderGoodsId,
  955. });
  956. if (code === 200 && rows.length && rows[0].keyValue) {
  957. let baseRes = await this.$api.getbaseprofiletpId(this.goodsId);
  958. if (baseRes.data.code === 200 && baseRes.data.data) {
  959. let {
  960. data: {
  961. code,
  962. data
  963. },
  964. } = await this.$api.getbaseprofiletpgetInfo({
  965. goodsId: this.goodsId,
  966. orderGoodsId: this.orderGoodsId,
  967. });
  968. if (
  969. code === 200 &&
  970. (!data || (data.status === 3 && data.changeStatus === 1))
  971. ) {
  972. uni.showModal({
  973. content: !data ?
  974. "请前往填写资料" : "资料审核不通过,请前往重新填写",
  975. cancelText: "返回",
  976. success: (resultst) => {
  977. if (resultst.confirm) {
  978. this.$navTo.togo("/pages2/verify/input", {
  979. id: this.goodsId,
  980. orderGoodsId: this.orderGoodsId,
  981. });
  982. }
  983. if (resultst.cancel) {
  984. uni.navigateBack();
  985. }
  986. },
  987. });
  988. return Promise.reject();
  989. } else if (data.status === 1 && JSON.parse(rows[0].keyValue2)[0]) {
  990. let {
  991. data: {
  992. code,
  993. data
  994. },
  995. } = await this.$api.getbaseprofileStampgetInfo({
  996. goodsId: this.goodsId,
  997. orderGoodsId: this.orderGoodsId,
  998. });
  999. if (
  1000. code === 200 &&
  1001. (!data || (data.status === 3 && data.changeStatus === 1))
  1002. ) {
  1003. uni.showModal({
  1004. content: !data ?
  1005. "请前往填写盖章资料" : "资料盖章审核不通过,请前往重新填写",
  1006. cancelText: "返回",
  1007. success: (resultst) => {
  1008. if (resultst.confirm) {
  1009. this.$navTo.togo("/pages2/verify/input2", {
  1010. id: this.goodsId,
  1011. orderGoodsId: this.orderGoodsId,
  1012. });
  1013. }
  1014. if (resultst.cancel) {
  1015. uni.navigateBack();
  1016. }
  1017. },
  1018. });
  1019. return Promise.reject();
  1020. }
  1021. } else if (data.status !== 1 && baseRes.data.data.checkStatus == 1) {
  1022. uni.showModal({
  1023. content: "资料正在审核中,暂无法学习,请耐心等待!如需加急审核,请联系客服人员",
  1024. cancelText: "返回",
  1025. success: (resultst) => {
  1026. if (resultst.confirm) {
  1027. uni.switchTab({
  1028. url: '/pages/learn/index'
  1029. });
  1030. }
  1031. if (resultst.cancel) {
  1032. uni.switchTab({
  1033. url: '/pages/learn/index'
  1034. });
  1035. }
  1036. },
  1037. });
  1038. return Promise.reject();
  1039. }
  1040. }
  1041. }
  1042. return Promise.resolve();
  1043. },
  1044. async isCanLearn() {
  1045. this.option.isQ !== "" && (await this.qCheckIsCanLearn());
  1046. await this.getGradeInfo();
  1047. await this.getGoodsDetail();
  1048. },
  1049. /**
  1050. * 计算tabs宽度
  1051. */
  1052. itemWidth() {
  1053. return 100 / this.list.length + "%";
  1054. },
  1055. loadedmetadata(event) {
  1056. this.refPlv = this.$refs.player;
  1057. },
  1058. getPhotoLastRecord() {
  1059. let {
  1060. chapterId,
  1061. sectionId,
  1062. moduleId
  1063. } = this.sectionItem;
  1064. let data = {
  1065. ...this.params(),
  1066. sectionId: sectionId || 0,
  1067. gradeId: this.gradeId,
  1068. chapterId: chapterId || 0,
  1069. moduleId: moduleId || 0,
  1070. };
  1071. this.$api.getPhotoLastRecord(data).then((res) => {
  1072. if (res.data.code == 200) {
  1073. //清空历史数据
  1074. this.photoHistoryList = [];
  1075. this.photoList = [];
  1076. for (let i = 0; i < res.data.data.length; i++) {
  1077. //-2存储随机拍照数组
  1078. if (res.data.data[i].photoIndex == -2) {
  1079. this.photoList =
  1080. res.data.data[i].timeInterval &&
  1081. res.data.data[i].timeInterval.split(",");
  1082. } else {
  1083. this.photoHistoryList.push(res.data.data[i].photoIndex);
  1084. }
  1085. }
  1086. }
  1087. });
  1088. },
  1089. //postTime 只提交随机时间
  1090. postCoursePhotoRecord(postTime = false) {
  1091. return new Promise((resolve, reject) => {
  1092. let data = {
  1093. ...this.params(["orderGoodsId", "goodsId", "courseId", "gradeId"]),
  1094. photo: this.ossAvatarUrl,
  1095. sectionId: this.sectionId,
  1096. photoTime: this.playTime || 0,
  1097. photoIndex: postTime ? -2 : this.photoIndex, //从0算起,-2只提交随机时间
  1098. photoNum: this.photoNum,
  1099. chapterId: this.chapterId,
  1100. moduleId: this.moduleId,
  1101. timeInterval: postTime ? this.photoList.join(",") : "",
  1102. };
  1103. this.$api
  1104. .coursePhotoRecord(data)
  1105. .then((res) => {
  1106. if (res.data.code == 200) {
  1107. resolve();
  1108. } else {
  1109. reject();
  1110. }
  1111. })
  1112. .catch((err) => {
  1113. reject();
  1114. });
  1115. });
  1116. },
  1117. randomNum(minNum, maxNum) {
  1118. switch (arguments.length) {
  1119. case 1:
  1120. return parseInt(Math.random() * minNum + 1, 10);
  1121. break;
  1122. case 2:
  1123. return parseInt(Math.random() * (maxNum - minNum + 1) + minNum, 10);
  1124. break;
  1125. default:
  1126. return 0;
  1127. break;
  1128. }
  1129. },
  1130. //配置随机拍照时间
  1131. configPhoto(duration) {
  1132. if ((this.photoConfig && this.photoList.length) || !this.isPlaying) {
  1133. return;
  1134. }
  1135. let totalVideoTime = this.refPlv.getDuration();
  1136. this.photoConfig = true;
  1137. if (this.erJianErZao) {
  1138. this.photoList = this.randomConfig(totalVideoTime, duration);
  1139. console.log(this.photoList, "this.photoList");
  1140. return;
  1141. }
  1142. //没有历史拍照间隔数据
  1143. if (!this.photoList || this.photoList.length == 0) {
  1144. // 46 * 60
  1145. this.photoList = this.commonConfig(
  1146. totalVideoTime,
  1147. this.jjShiGongYuan ? totalVideoTime < 2760 ? (46 * 60) - 1 : (45 * 60) - 1 : undefined
  1148. );
  1149. this.postCoursePhotoRecord(true); //提交随机拍照时间数组
  1150. }
  1151. console.log(this.photoList, "this.photoList");
  1152. },
  1153. // 二建随机拍摄时间
  1154. randomConfig(totalVideoTime, duration) {
  1155. this.photoHistoryList = [];
  1156. let photoList = [duration];
  1157. let pre = duration;
  1158. if (totalVideoTime > 300) {
  1159. while (pre <= totalVideoTime) {
  1160. pre += this.randomNum(780, 900);
  1161. pre <= totalVideoTime && photoList.push(pre);
  1162. }
  1163. if (totalVideoTime - 300 > photoList.slice(-1)[0]) {
  1164. photoList.push(this.randomNum(totalVideoTime - 180, totalVideoTime));
  1165. }
  1166. }
  1167. return photoList;
  1168. },
  1169. // 随机前后五分钟
  1170. commonConfig(totalVideoTime, fixS) {
  1171. let photoList = [];
  1172. // 固定间隔时间取
  1173. if (fixS) {
  1174. let num = Math.ceil(totalVideoTime / fixS);
  1175. if (num == 1) {
  1176. photoList.push(parseInt(totalVideoTime / 2));
  1177. } else {
  1178. for (let i = 0; i < num; i++) {
  1179. photoList.push(parseInt((totalVideoTime / (num + 1)) * (i + 1)));
  1180. }
  1181. }
  1182. this.photoNum = num;
  1183. } else {
  1184. photoList = [0];
  1185. if (this.photoNum == 3) {
  1186. if (totalVideoTime >= 900) {
  1187. //大于15分钟
  1188. let centerTime = Math.floor(totalVideoTime / 2); //获取中间时间
  1189. let centerMinTime = centerTime - 300; //前后5分钟
  1190. let centerMaxTime = centerTime + 300;
  1191. let centerTakeTime = this.randomNum(centerMinTime, centerMaxTime);
  1192. photoList.push(centerTakeTime); //中间拍一张
  1193. let endMaxTime = totalVideoTime - 60;
  1194. let endMinTime = totalVideoTime - 300;
  1195. let endTakeTime = this.randomNum(endMinTime, endMaxTime);
  1196. photoList.push(endTakeTime); //最后拍一张
  1197. } else {
  1198. //小于15分钟
  1199. let centerTime = this.randomNum(
  1200. (1 / 3) * totalVideoTime,
  1201. (2 / 3) * totalVideoTime
  1202. );
  1203. photoList.push(centerTime);
  1204. let endTakeTime = this.randomNum(
  1205. (2 / 3) * totalVideoTime,
  1206. totalVideoTime
  1207. );
  1208. photoList.push(endTakeTime);
  1209. }
  1210. }
  1211. }
  1212. return photoList;
  1213. },
  1214. studyNotice() {
  1215. this.noticeShow = true;
  1216. },
  1217. //正常播放视频
  1218. async playVideo(item) {
  1219. let {
  1220. learning,
  1221. videoCurrentTime,
  1222. recordingUrl
  1223. } = item;
  1224. this.videoCurrentTime =
  1225. videoCurrentTime || (await this.getRecordLast(item));
  1226. // 往前播3秒
  1227. if (this.videoCurrentTime > 3) {
  1228. this.videoCurrentTime -= 3;
  1229. }
  1230. this.sectionItem = item;
  1231. // 查找拍照历史
  1232. if ((this.photoNum > 0 || this.jjShiGongYuan || this.erJianErZao) && learning != 1) {
  1233. await this.getPhotoLastRecord();
  1234. }
  1235. if (this.refPlv) {
  1236. this.refPlv.changeVid({
  1237. vid: recordingUrl,
  1238. videoCurrentTime: this.videoCurrentTime,
  1239. });
  1240. }
  1241. },
  1242. getRecordLast(sectionItem) {
  1243. let {
  1244. chapterId,
  1245. sectionId,
  1246. courseId,
  1247. moduleId
  1248. } = sectionItem;
  1249. return new Promise((resolve) => {
  1250. let data = {
  1251. ...this.params(),
  1252. gradeId: this.gradeId || this.gradeId == 0 ? Number(this.gradeId) : null,
  1253. sectionId: sectionId || 0,
  1254. chapterId: chapterId || 0,
  1255. moduleId: moduleId || 0,
  1256. };
  1257. this.$api.recordLast(data).then((res) => {
  1258. resolve(res.data.data.videoCurrentTime);
  1259. });
  1260. });
  1261. },
  1262. jumpNote(item) {
  1263. this.$u.toast("即将跳到笔记位置");
  1264. if (this.sectionId != item.sectionId) {
  1265. this.initPlayVideo({
  1266. sectionType: 1,
  1267. ...item,
  1268. videoCurrentTime: Number(item.noteSecond),
  1269. });
  1270. } else {
  1271. this.refPlv.seekVideo(item.noteSecond);
  1272. }
  1273. },
  1274. getGradeInfo() {
  1275. // 即刻 1 待定2 日期3
  1276. return this.$api.goodsGradeInfo(this.gradeId).then((res) => {
  1277. if (res.data.code == 200) {
  1278. let {
  1279. data
  1280. } = res.data;
  1281. if (
  1282. data.learningStatus == 2 ||
  1283. (data.learningStatus == 3 &&
  1284. Number(data.learningTimeStart) > Number(new Date() / 1000))
  1285. ) {
  1286. uni.showModal({
  1287. showCancel: false,
  1288. confirmText: "确定",
  1289. content: "当前课程正在申请中,正式开班后方可进行学习,请耐心等候!",
  1290. success: function(resultst) {
  1291. uni.navigateBack();
  1292. },
  1293. });
  1294. return Promise.reject();
  1295. }
  1296. }
  1297. });
  1298. },
  1299. postStudyRecord(status = 0, sectionId = this.sectionId) {
  1300. if (!this.refPlv && this.playVid) {
  1301. return;
  1302. }
  1303. let currentTime = this.refPlv.playCurrentTime();
  1304. let PlayDuration = this.refPlv.playVideoTime();
  1305. if (currentTime < 10 && !this.ossAvatarUrl) {
  1306. if (status == 0) return;
  1307. currentTime = this.playTime;
  1308. }
  1309. let self = this;
  1310. let fromPlat = 1;
  1311. // #ifdef H5
  1312. fromPlat = 3;
  1313. // #endif
  1314. let data = {
  1315. ...this.params([
  1316. "orderGoodsId",
  1317. "goodsId",
  1318. "courseId",
  1319. "erJianErZao",
  1320. "gradeId",
  1321. ]),
  1322. fromPlat, //来源平台 1小程序 2网站
  1323. photo: self.ossAvatarUrl,
  1324. sectionId: sectionId || 0,
  1325. studyDuration: parseInt(PlayDuration),
  1326. chapterId: this.chapterId || 0,
  1327. moduleId: this.moduleId || 0,
  1328. videoCurrentTime: parseInt(currentTime),
  1329. };
  1330. if (this.ossAvatarUrl) {
  1331. data.similarity = this.compareFaceData; // 相似度
  1332. }
  1333. if (status > 0) {
  1334. data.status = status;
  1335. }
  1336. console.log(data, "记录参数");
  1337. return new Promise((resolve, reject) => {
  1338. this.$api
  1339. .studyRecord(data)
  1340. .then((res) => {
  1341. console.log(res, "记录返回");
  1342. let {
  1343. code,
  1344. msg
  1345. } = res.data;
  1346. if (code == 200) {
  1347. if (status > 0) {
  1348. // 刷新数据
  1349. uni.$emit("playEnd");
  1350. this.studyRecordMenuAllList();
  1351. }
  1352. self.ossAvatarUrl = "";
  1353. } else if (code == 600) {
  1354. uni.showModal({
  1355. showCancel: false,
  1356. title: "提示",
  1357. content: msg,
  1358. success: (resultst) => {
  1359. uni.navigateBack();
  1360. },
  1361. });
  1362. this.closeCamera();
  1363. return
  1364. } else if (code == 558) {
  1365. this.CountTo1 = msg.split(",")[1];
  1366. this.noticeShow1 = true;
  1367. var timer = setInterval(() => {
  1368. this.CountTo1--;
  1369. if (this.CountTo1 < 0) {
  1370. this.noticeShow1 = false;
  1371. clearInterval(timer);
  1372. this.postStudyRecord(1).then(this.nextSection);
  1373. }
  1374. }, 1000);
  1375. this.closeCamera();
  1376. return
  1377. } else {
  1378. uni.showToast({
  1379. icon: "none",
  1380. title: res.data.msg,
  1381. duration: 2000,
  1382. });
  1383. if (code == 559) {
  1384. this.isReach = true;
  1385. this.openCamera()
  1386. }
  1387. return
  1388. }
  1389. resolve();
  1390. })
  1391. .catch((err) => {
  1392. this.studyRecordMenuAllList();
  1393. });
  1394. });
  1395. },
  1396. timeEvent(time) {
  1397. console.log(this.refPlv.getDuration(), 'getDurationgetDuration')
  1398. this.clearPauseTimer();
  1399. if (this.playSecIsLearn && (this.erJianErZao || this.jjShiGongYuan || this.photoNum > 0)) {
  1400. this.configPhoto(time);
  1401. this.isReach = false;
  1402. const index = this.photoList.findIndex((e) => e < time && e > time - 8);
  1403. if (index != -1 && !this.photoHistoryList[index] && this.photoHistoryList[index] != 0) {
  1404. this.photoIndex = index;
  1405. // 拍照
  1406. this.openCamera();
  1407. }
  1408. }
  1409. },
  1410. // 新增用户视频学习日志
  1411. studyLog() {
  1412. this.$http({
  1413. url: "/user/study/log",
  1414. method: "post",
  1415. data: {
  1416. ...this.params(),
  1417. moduleId: this.moduleId || 0,
  1418. chapterId: this.chapterId || 0,
  1419. sectionId: this.sectionId || 0,
  1420. fromPlat: 1, //来源平台 1小程序 2PC网站
  1421. goodsType: 1, // 商品类型 1视频2题库 3补考 4前培 5虚拟赠送题库 6直播
  1422. },
  1423. }).then((res) => {});
  1424. },
  1425. timeupdate(time) {
  1426. console.log("🚀 ~ file: detail.vue:1498 ~ timeupdate ~ time:");
  1427. if (this.noticeShow) {
  1428. this.refPlv.playPause();
  1429. return;
  1430. }
  1431. this.playTime = time;
  1432. this.throttleFn();
  1433. this.timeEvent(time);
  1434. },
  1435. playing() {
  1436. //特殊设备跳过拍照停止学习
  1437. if (this.showCamera) {
  1438. this.refPlv.playPause();
  1439. this.refPlv.exitFullScreen();
  1440. return
  1441. }
  1442. console.log("播放");
  1443. this.isPlaying = true;
  1444. this.clearPauseTimer();
  1445. },
  1446. openCamera() {
  1447. if (this.showCamera) return;
  1448. this.showCamera = true;
  1449. this.refPlv.playPause();
  1450. this.refPlv.exitFullScreen();
  1451. },
  1452. closeCamera() {
  1453. console.log("关闭")
  1454. this.showCamera = false;
  1455. },
  1456. pause() {
  1457. console.log("暂停");
  1458. this.isPlaying = false;
  1459. this.erJianErZaoPauseTip();
  1460. },
  1461. async ended() {
  1462. console.log("结束");
  1463. this.isPlaying = false;
  1464. uni.showToast({
  1465. icon: "none",
  1466. title: "播放完毕",
  1467. });
  1468. this.clearPauseTimer();
  1469. await this.postStudyRecord(1);
  1470. this.nextSection();
  1471. },
  1472. playerError() {
  1473. console.log("播放错误");
  1474. },
  1475. //播放下一节
  1476. nextSection() {
  1477. console.log("播放下一节");
  1478. if (!this.menuAllList.length) {
  1479. return;
  1480. }
  1481. this.curPlayIndex = this.menuAllList.findIndex((item) => {
  1482. let i_sectionId = item.sectionId || 0;
  1483. let i_chapterId = item.chapterId || 0;
  1484. let i_moduleId = item.moduleId || 0;
  1485. return (
  1486. i_sectionId == this.sectionId &&
  1487. i_chapterId == this.chapterId &&
  1488. i_moduleId == this.moduleId
  1489. );
  1490. });
  1491. let data = this.menuAllList[this.curPlayIndex + 1];
  1492. data.learning = data.learning || data.studyStatus
  1493. if (!data) {
  1494. //第二个弹窗
  1495. uni.showModal({
  1496. title: "温馨提示",
  1497. content: "恭喜您课程学习全部完成,教务会在1-3个工作日内完成学习初审,请耐心等待。",
  1498. showCancel: !this.erJianErZao,
  1499. success: (res) => {
  1500. if (res.confirm) {
  1501. uni.switchTab({
  1502. url: "/pages/learn/index",
  1503. });
  1504. }
  1505. },
  1506. });
  1507. } else {
  1508. if (data.doType == 2) {
  1509. if (data.studyStatus == 1) {
  1510. uni.showToast({
  1511. title: "试卷已合格!",
  1512. duration: 2000,
  1513. icon: "none",
  1514. });
  1515. return;
  1516. }
  1517. uni.showModal({
  1518. title: "温馨提示",
  1519. content: "当前节视频已学完,是否进入考试?",
  1520. success: (res) => {
  1521. if (res.confirm) {
  1522. this.toQuestionBank(data);
  1523. }
  1524. },
  1525. });
  1526. return;
  1527. }
  1528. uni.showModal({
  1529. title: "温馨提示",
  1530. content: "当前节视频已学完,继续学习下一节?",
  1531. success: async (res) => {
  1532. if (res.confirm) {
  1533. this.moduleId = data.moduleId;
  1534. this.chapterId = data.chapterId;
  1535. this.sectionId = data.sectionId;
  1536. if (data.sectionType == 1) {
  1537. //录播
  1538. this.photoConfig = false;
  1539. this.sectionItem = data;
  1540. this.playVideo(data);
  1541. } else if (data.sectionType == 2) {
  1542. //直播
  1543. this.studyRecordGetLastLive();
  1544. } else if (data.sectionType == 3) {
  1545. //回放
  1546. this.sectionItem = data;
  1547. this.playVideo(data);
  1548. }
  1549. this.updateChapterOpen(true);
  1550. }
  1551. },
  1552. });
  1553. }
  1554. },
  1555. async userConfirmInfoDetail() {
  1556. let info = await this.$api.userConfirmInfoDetail({
  1557. orderGoodsId: this.orderGoodsId,
  1558. });
  1559. if (!info.data.data || info.data.data.pushInfo !== 1) {
  1560. uni.showModal({
  1561. showCancel: false,
  1562. title: "提示",
  1563. content: "开通信息推送不成功,无法进入学习!",
  1564. success: (resultst) => {
  1565. uni.navigateBack();
  1566. },
  1567. });
  1568. return Promise.reject();
  1569. }
  1570. },
  1571. checkFinishRequiredCourse() {
  1572. return this.$api
  1573. .checkFinishRequiredCourse({
  1574. businessId: this.goodsData.businessId,
  1575. goodsId: this.goodsId,
  1576. })
  1577. .then((res) => {
  1578. if (res.data.data > 0) {
  1579. uni.showModal({
  1580. showCancel: false,
  1581. confirmText: "确定",
  1582. content: "该业务层次下有未学完的商品,无法学习新商品!",
  1583. success: function(resultst) {
  1584. uni.navigateBack();
  1585. },
  1586. });
  1587. return Promise.reject();
  1588. }
  1589. return Promise.resolve();
  1590. });
  1591. },
  1592. async getGoodsDetail() {
  1593. let {
  1594. data
  1595. } = await this.$api.goodsDetail(this.goodsId);
  1596. this.goodsData = data.data;
  1597. if (data.data.firstChoiceStatus) {
  1598. uni.redirectTo({
  1599. url: `/pages3/polyv/preference?courseId=${this.courseId}&goodsId=${data.data.goodsId}&orderGoodsId=${this.orderGoodsId}&gradeId=${data.data.gradeId}&periodWaitTime=${this.option.periodWaitTime ? 1 : ""}&isQ=${this.option.isQ}&minClassHour=${data.data.minClassHour || 0}`,
  1600. });
  1601. return
  1602. }
  1603. await this.getbaseprofiletplists();
  1604. this.erJianErZao = this.goodsData.erJianErZao;
  1605. this.jjShiGongYuan = this.goodsData.jjShiGongYuan;
  1606. if (this.erJianErZao || this.jjShiGongYuan) {
  1607. await this.userConfirmInfoDetail();
  1608. }
  1609. if (this.erJianErZao) {
  1610. this.option.periodWaitTime && (await this.checkFinishRequiredCourse());
  1611. }
  1612. this.goodsData.buyNote && this.baseHandoutTipList();
  1613. !this.gradeId && (this.gradeId = this.goodsData.gradeId);
  1614. if (this.goodsData.goodsPlayConfig) {
  1615. this.goodsPlayConfig = JSON.parse(this.goodsData.goodsPlayConfig);
  1616. if (this.goodsPlayConfig.autoPlay > 0) {
  1617. this.autoplay = true;
  1618. }
  1619. if (this.goodsPlayConfig.drag > 0 && !this.erJianErZao) {
  1620. // #ifdef MP-WEIXIN
  1621. this.isAllowSeek = "yes";
  1622. // #endif
  1623. // #ifdef H5
  1624. this.isAllowSeek = "off";
  1625. // #endif
  1626. }
  1627. if (this.goodsPlayConfig.speed > 0) {
  1628. this.playbackRate = [0.5, 0.8, 1.0, 1.25, 1.5, 2.0];
  1629. }
  1630. }
  1631. if (this.goodsData.goodsPhotographConfig) {
  1632. this.goodsPhotographConfig = JSON.parse(
  1633. this.goodsData.goodsPhotographConfig
  1634. );
  1635. if (this.goodsPhotographConfig.photoNum > 0) {
  1636. this.photoNum = this.goodsPhotographConfig.photoNum;
  1637. }
  1638. }
  1639. },
  1640. change(index) {
  1641. this.current = index;
  1642. },
  1643. paramsFn(
  1644. keys = ["orderGoodsId", "goodsId", "courseId", "gradeId", "sectionItem"]
  1645. ) {
  1646. return this.params(keys);
  1647. },
  1648. },
  1649. provide() {
  1650. return {
  1651. paramsFn: this.paramsFn,
  1652. };
  1653. },
  1654. };
  1655. </script>
  1656. <style lang="scss" scope>
  1657. @import "./css/detail.scss";
  1658. .top {
  1659. &__header {
  1660. position: relative;
  1661. width: 100%;
  1662. height: 150rpx;
  1663. padding: 24rpx 150rpx 24rpx 24rpx;
  1664. .img {
  1665. position: absolute;
  1666. left: 0;
  1667. top: 0;
  1668. width: 100%;
  1669. }
  1670. .note {
  1671. position: relative;
  1672. z-index: 10;
  1673. font-size: 24rpx;
  1674. font-family: PingFang SC;
  1675. font-weight: bold;
  1676. color: #efdbff;
  1677. }
  1678. .title {
  1679. position: relative;
  1680. z-index: 10;
  1681. font-size: 26rpx;
  1682. font-family: PingFang SC;
  1683. font-weight: bold;
  1684. color: #ffffff;
  1685. }
  1686. }
  1687. }
  1688. #top {
  1689. position: relative;
  1690. z-index: 99;
  1691. }
  1692. .polyv_detail {
  1693. display: flex;
  1694. flex-direction: column;
  1695. height: 100vh;
  1696. position: relative;
  1697. top: 0;
  1698. left: 0;
  1699. .pops {
  1700. position: absolute;
  1701. top: 0;
  1702. left: 0;
  1703. background: #ccc;
  1704. opacity: 0.5;
  1705. width: 100%;
  1706. height: 300rpx;
  1707. z-index: 9999;
  1708. }
  1709. .box {
  1710. flex: 1;
  1711. overflow: hidden;
  1712. margin: 16rpx 16rpx 100rpx 16rpx;
  1713. .box_in {
  1714. height: 100%;
  1715. }
  1716. }
  1717. .first_ml {
  1718. margin: 16rpx 16rpx 16rpx 16rpx;
  1719. }
  1720. }
  1721. .title {
  1722. font-size: 24rpx;
  1723. color: #999999;
  1724. }
  1725. page {
  1726. background: #eaeef1;
  1727. }
  1728. .ts {
  1729. font-size: 24rpx;
  1730. color: #999;
  1731. margin: 14rpx 0rpx;
  1732. padding-right: 29rpx;
  1733. padding-left: 34rpx;
  1734. }
  1735. .content {
  1736. padding: 24rpx;
  1737. text-align: left;
  1738. }
  1739. .sc_t {
  1740. font-size: 22rpx;
  1741. color: #000000;
  1742. }
  1743. .sc {
  1744. width: 29rpx;
  1745. height: 29rpx;
  1746. }
  1747. .buy {
  1748. width: 138rpx;
  1749. height: 48rpx;
  1750. line-height: 48rpx;
  1751. background: #32467b;
  1752. border-radius: 10rpx;
  1753. color: #ffffff;
  1754. font-size: 28rpx;
  1755. text-align: center;
  1756. vertical-align: middle;
  1757. position: absolute;
  1758. right: 30rpx;
  1759. }
  1760. .video_body {
  1761. padding-bottom: 96rpx;
  1762. }
  1763. .tj_box {
  1764. width: 50%;
  1765. display: inline-block;
  1766. text-align: center;
  1767. margin: 10rpx 0;
  1768. }
  1769. .t2 {
  1770. font-size: 24rpx;
  1771. font-family: PingFang SC;
  1772. color: #666666;
  1773. line-height: 36rpx;
  1774. margin: 15rpx;
  1775. }
  1776. .r_t2 {
  1777. width: 201rpx;
  1778. height: 49rpx;
  1779. background: rgba(22, 119, 255, 0.05);
  1780. border: 1rpx solid #32467b;
  1781. border-radius: 16rpx;
  1782. color: #666666;
  1783. font-size: 23rpx;
  1784. text-align: center;
  1785. display: flex;
  1786. align-items: center;
  1787. padding: 5rpx;
  1788. }
  1789. .scroll_box {
  1790. width: 100%;
  1791. height: 60rpx;
  1792. background: #ffffff;
  1793. box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(145, 156, 178, 0.1);
  1794. white-space: nowrap;
  1795. overflow: hidden;
  1796. margin: 15rpx 0;
  1797. }
  1798. .r_sliper {
  1799. padding: 0 20rpx;
  1800. }
  1801. .top_line {
  1802. width: 6rpx;
  1803. height: 22rpx;
  1804. background: #32467b;
  1805. margin-right: 10rpx;
  1806. }
  1807. .video_t2 {
  1808. font-size: 24rpx;
  1809. font-family: PingFang SC;
  1810. font-weight: 500;
  1811. color: #666666;
  1812. }
  1813. .video_play {
  1814. position: absolute;
  1815. width: 95rpx;
  1816. height: 95rpx;
  1817. top: 0;
  1818. left: 0;
  1819. right: 0;
  1820. bottom: 0;
  1821. margin: auto;
  1822. }
  1823. .video_box {
  1824. position: relative;
  1825. }
  1826. .slot-content {
  1827. padding: 0 20rpx;
  1828. }
  1829. .notice_modal {
  1830. .content {
  1831. width: 100%;
  1832. height: 100%;
  1833. padding: 56rpx 56rpx 56rpx 64rpx;
  1834. .title {
  1835. color: #222;
  1836. line-height: 40rpx;
  1837. font-size: 36rpx;
  1838. text-align: center;
  1839. font-weight: bold;
  1840. margin-bottom: 24rpx;
  1841. }
  1842. .text {
  1843. height: 340rpx;
  1844. line-height: 40rpx;
  1845. text-indent: 2em;
  1846. font-size: 32rpx;
  1847. color: #222;
  1848. }
  1849. .had_read {
  1850. width: 100%;
  1851. height: 88rpx;
  1852. line-height: 88rpx;
  1853. text-align: center;
  1854. background: #3577e8;
  1855. border-radius: 240rpx;
  1856. font-size: 32rpx;
  1857. font-weight: 500;
  1858. color: #fff;
  1859. margin-top: 20rpx;
  1860. &.gray {
  1861. background: #bbbec5;
  1862. }
  1863. }
  1864. }
  1865. }
  1866. </style>