detail.vue 53 KB

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