detail.vue 55 KB

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