detail.vue 55 KB

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