detail.vue 50 KB

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