detail.vue 54 KB

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