detail.vue 54 KB

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