detail.vue 54 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. avatarUrl: "",
  332. ossAvatarUrl: "",
  333. gradeId: 0,
  334. chapterId: 0,
  335. moduleId: 0,
  336. videoCurrentTime: 0,
  337. photoIndex: 0,
  338. photoNum: 0,
  339. photoList: [], //拍照的时间点
  340. photoConfig: false, //是否配置好拍照次数
  341. photoHistoryList: [], //已拍照历史的下标点
  342. sectionItem: {},
  343. isRebuild: false, //视频是否从重修目录点击
  344. livingItem: "",
  345. option: null,
  346. toggleCourseShow: false, // 切换课程弹窗
  347. courseList: [], // 课程列表
  348. subList: [],
  349. subIndex: 0,
  350. goodsTeacher: [],
  351. teacherList: [],
  352. teacherIndex: 0,
  353. newActiveSubjectId: "", //当前选中ID
  354. compareFaceData: 0, // 拍照匹配相似度
  355. prendreAutoCarme: false, // 是否发起授权相机
  356. CountTo: 0, // 倒计时
  357. CountTo1: 0,
  358. menuAllList: [],
  359. curPlayIndex: 0, // 正在播放的节的下标
  360. faceUrl: "",
  361. erJianErZao: false,
  362. jjShiGongYuan: false,
  363. pauseTime: 0,
  364. pauseTimer: null,
  365. isReach: false,
  366. noticeShow1: false,
  367. refPlv: null,
  368. isCache: false,
  369. isHaverebuild: false,
  370. isPlaying: false,
  371. beforeHideIsPlaying: false,
  372. isLeave: false,
  373. text: "",
  374. throttleFn: throttle(this.postStudyRecord, 15000),
  375. };
  376. },
  377. computed: {
  378. ...mapGetters(["userInfo", "config"]),
  379. playSecIsLearn() {
  380. if (!this.playVid) {
  381. return false;
  382. }
  383. return this.sectionItem.learning != 1;
  384. },
  385. orderNum() {
  386. return this.goodsData.goodsLearningOrder;
  387. },
  388. list() {
  389. let list = [
  390. {
  391. name: "目录",
  392. },
  393. {
  394. name: "讲义",
  395. },
  396. {
  397. name: "笔记",
  398. },
  399. {
  400. name: "答疑",
  401. },
  402. ];
  403. if (this.isHaverebuild) {
  404. list.push({ name: "重修目录" });
  405. }
  406. return list;
  407. },
  408. params: function () {
  409. return (keys = ["orderGoodsId", "goodsId", "courseId"]) => {
  410. let params = {};
  411. for (const key of keys) {
  412. params[key] = this[key];
  413. }
  414. return params;
  415. };
  416. },
  417. detail() {
  418. if (!this.courseId || !this.courseList.length) {
  419. return {};
  420. }
  421. return this.courseList.find((e) => e.courseId == this.courseId);
  422. },
  423. sectionId() {
  424. return this.sectionItem.sectionId || this.sectionItem.id;
  425. },
  426. playVid() {
  427. return this.sectionItem.recordingUrl;
  428. },
  429. isPlayRebuild() {
  430. return this.sectionItem.rebuild != 1;
  431. },
  432. },
  433. async onLoad(option) {
  434. if (option.isOther) {
  435. this.showMark = true;
  436. return;
  437. }
  438. this.option = option;
  439. let { skipPort, id, goodsId, orderGoodsId, gradeId, informId } = option;
  440. this.orderGoodsId = Number(orderGoodsId) || "";
  441. this.courseId = Number(id) || "";
  442. this.goodsId = Number(goodsId);
  443. this.gradeId = Number(gradeId);
  444. this.isLeave = false;
  445. uni.addInterceptor("navigateTo", {
  446. success: (e) => {
  447. this.isLeave = true;
  448. this.isCache = true;
  449. },
  450. });
  451. if (skipPort) {
  452. await this.$method.skipLogin(skipPort);
  453. }
  454. if (this.$method.isGoLogin()) {
  455. return;
  456. }
  457. if (!this.lockTimer) {
  458. lockAction();
  459. this.lockTimer = setInterval(lockAction, 10000);
  460. }
  461. // 公众号模板消息的数据埋点
  462. informId && this.clickOfficial(informId);
  463. this.init();
  464. },
  465. async onShow() {
  466. if (!this.$method.isLogin()) {
  467. return;
  468. }
  469. if (this.isCache) {
  470. console.log("返回刷新数据");
  471. this.isCache = false;
  472. this.sectionItem = {};
  473. this.beforeHideIsPlaying = false;
  474. reload(this.option);
  475. return;
  476. }
  477. if (this.beforeHideIsPlaying) {
  478. console.log("显示重新播放");
  479. if (this.text) {
  480. this.refPlv.playPause();
  481. return;
  482. }
  483. this.refPlv.resumeVideo();
  484. }
  485. },
  486. onUnload() {
  487. console.log("onUnload");
  488. if (this.isPlaying) {
  489. this.postStudyRecord();
  490. }
  491. this.refPlv = null;
  492. uni.$off();
  493. this.clearPauseTimer();
  494. uni.removeInterceptor("navigateTo");
  495. if (this.lockTimer) {
  496. clearInterval(this.lockTimer);
  497. this.$api.lockDelLock({
  498. action: "jxjy",
  499. uuid: this.$method.getUuid(),
  500. });
  501. }
  502. },
  503. onHide() {
  504. this.beforeHideIsPlaying = this.isPlaying;
  505. if (this.isPlaying) {
  506. this.refPlv.playPause();
  507. }
  508. },
  509. mounted() {},
  510. methods: {
  511. ...mapMutations(["updateChapterOpen", "updateLiveLast"]),
  512. async init() {
  513. // #ifdef MP-WEIXIN
  514. this.isAllowSeek = "no";
  515. // #endif
  516. // #ifdef H5
  517. this.isAllowSeek = "on";
  518. // #endif
  519. this.photoList = [];
  520. this.courseList = [];
  521. this.photoConfig = false;
  522. await this.isCanLearn();
  523. this.courseCourseList();
  524. },
  525. // 七大员是否能进入学习
  526. async qCheckIsCanLearn() {
  527. let res = await this.$api.qCheckIsCanLearn(this.orderGoodsId);
  528. if (res.data.code !== 200) {
  529. uni.showModal({
  530. showCancel: false,
  531. title: "提示",
  532. content: res.data.msg,
  533. success: (resultst) => {
  534. uni.navigateBack();
  535. },
  536. });
  537. return Promise.reject();
  538. }
  539. let res1 = await this.$api.syncSevenPublicClass({
  540. orderGoodsId: this.orderGoodsId,
  541. });
  542. if (res1.data.code !== 200) {
  543. uni.showModal({
  544. showCancel: false,
  545. title: "提示",
  546. content: "无法进入学习!",
  547. success: (resultst) => {
  548. uni.navigateBack();
  549. },
  550. });
  551. return Promise.reject();
  552. }
  553. },
  554. // 新增微信公众号模板消息点击数据
  555. clickOfficial(informId) {
  556. this.$http({
  557. url: "/data/click",
  558. method: "post",
  559. data: { informId },
  560. });
  561. },
  562. // 点击课程目录
  563. cMenu(item, index) {
  564. this.subIndex = index;
  565. this.newActiveSubjectId = item.subjectId;
  566. },
  567. courseCourseList() {
  568. this.$api
  569. .courseCourseList({
  570. pageNum: 1,
  571. pageSize: 200,
  572. ...this.params(["goodsId", "orderGoodsId", "gradeId"]),
  573. })
  574. .then((res) => {
  575. if (res.data.code == 200) {
  576. this.courseList = res.data.rows;
  577. if (res.data.total > 1) {
  578. // 科目
  579. this.subList = [{ subjectId: 0, subjectName: "所有" }];
  580. this.courseList.forEach((item) => {
  581. if (!this.subList.find((e) => e.subjectId == item.subjectId)) {
  582. this.subList.push(item);
  583. }
  584. });
  585. this.getUserWatchLast();
  586. } else {
  587. this.originOnShow();
  588. this.originMounted();
  589. }
  590. }
  591. });
  592. },
  593. // 查询用户最后一次看的录播的信息
  594. getUserWatchLast() {
  595. this.$http({
  596. url: "/study/record/getUserWatchLast",
  597. method: "get",
  598. data: {
  599. orderGoodsId: this.orderGoodsId,
  600. },
  601. }).then((res) => {
  602. if (res.data.code == 200 && res.data.data) {
  603. this.courseId = res.data.data.courseId;
  604. }
  605. if (!this.courseId) {
  606. this.courseId = this.courseList[0].courseId;
  607. }
  608. this.originOnShow();
  609. this.originMounted();
  610. //获取商品双师资模板
  611. this.getCourseTeacher(this.courseList);
  612. });
  613. },
  614. getCourseTeacher(rows) {
  615. this.goodsTeacher = [];
  616. //获取商品双师资模板
  617. this.$api
  618. .courseTeacherList({
  619. goodsId: this.goodsId,
  620. })
  621. .then((res1) => {
  622. if (res1.data.data && res1.data.data.length > 0) {
  623. //课程老师模板
  624. let teacherTel = res1.data.data;
  625. //商品课程
  626. let courses = rows;
  627. teacherTel.forEach((tea) => {
  628. let dataList = [];
  629. let teacherList = [];
  630. courses.forEach((item) => {
  631. let data = tea.courseList.filter(
  632. (x) => x.courseId == item.courseId
  633. );
  634. if (data && data.length > 0) {
  635. dataList.push(item);
  636. teacherList = tea.courseList;
  637. }
  638. });
  639. let result = {
  640. teaList: teacherList,
  641. courseList: dataList,
  642. };
  643. this.goodsTeacher.push(result);
  644. });
  645. if (this.goodsTeacher && this.goodsTeacher.length > 0) {
  646. let courseIds = [];
  647. this.goodsTeacher.forEach((item) => {
  648. item.courseList.forEach((course) => {
  649. courseIds.push(course.courseId);
  650. });
  651. });
  652. if (courseIds.length > 0) {
  653. courses.forEach((item) => {
  654. if (!courseIds.includes(item.courseId)) {
  655. let data = {
  656. teaList: [],
  657. courseList: [],
  658. };
  659. data.courseList.push(item);
  660. this.goodsTeacher.push(data);
  661. }
  662. });
  663. }
  664. this.goodsTeacher.forEach((item) => {
  665. if (item.courseList && item.courseList.length > 0) {
  666. item.courseList[0].show = 1;
  667. }
  668. });
  669. }
  670. } else {
  671. //没有双师资模板
  672. rows.forEach((item) => {
  673. item.show = 1;
  674. let data = {
  675. teaList: [],
  676. courseList: [],
  677. };
  678. data.courseList.push(item);
  679. this.goodsTeacher.push(data);
  680. });
  681. }
  682. this.goodsTeacher.forEach((item) => {
  683. if (item.courseList.some((x) => x.courseId == this.courseId)) {
  684. this.teacherList = item.teaList;
  685. }
  686. });
  687. });
  688. },
  689. erJianErZaoPauseTip() {
  690. if (this.playSecIsLearn && this.erJianErZao && !this.isLeave) {
  691. if (this.pauseTimer) {
  692. return;
  693. }
  694. this.pauseTime = Date.now();
  695. this.pauseTimer = setInterval(() => {
  696. console.log("暂停时间", Date.now() - this.pauseTime, this.pauseTime);
  697. if (Date.now() - this.pauseTime > 20 * 1000) {
  698. // 5 * 60 * 1000
  699. this.refPlv.exitFullScreen();
  700. this.text = "暂停";
  701. if (this.showCamera) {
  702. this.text = "拍照停留";
  703. this.closeCamera();
  704. }
  705. uni.showModal({
  706. title: "提示",
  707. showCancel: false,
  708. content: `检测${this.text}时间过长,刷新当前页面`,
  709. cancelText: "取消",
  710. confirmText: "确定",
  711. success: (res) => {
  712. this.text = "";
  713. reload(this.option);
  714. // #ifdef MP-WEIXIN
  715. this.sectionItem = {};
  716. // #endif
  717. },
  718. });
  719. this.clearPauseTimer();
  720. }
  721. }, 5000);
  722. }
  723. },
  724. // 原来onshow里面的内容
  725. async originOnShow() {
  726. await this.studyRecordMenuAllList();
  727. // 消息过来 定位某个节
  728. if (this.option.noteSecond) {
  729. this.jumpNote({
  730. sectionType: 1,
  731. ...this.option,
  732. });
  733. return;
  734. }
  735. this.studyRecordQueryLiveLast();
  736. },
  737. // 原来的mouted内容
  738. originMounted() {
  739. uni.$on(
  740. "getSection",
  741. debounce((item) => {
  742. if (!this.refPlv && this.playVid) {
  743. this.refPlv = this.$refs.player;
  744. }
  745. if (this.isPlaying) {
  746. this.refPlv.playPause();
  747. }
  748. this.postStudyRecord(0);
  749. this.photoConfig = false;
  750. this.photoList = [];
  751. this.moduleId = item.moduleId || null;
  752. this.chapterId = item.chapterId || null;
  753. this.playVideo(item);
  754. })
  755. );
  756. uni.$on("isRebuild", (item) => {
  757. this.isRebuild = item;
  758. });
  759. this.updateChapterOpen(true);
  760. },
  761. clearPauseTimer() {
  762. if (this.pauseTimer) {
  763. this.pauseTime = 0;
  764. clearInterval(this.pauseTimer);
  765. this.pauseTimer = null;
  766. }
  767. },
  768. changeCourses() {
  769. this.toggleCourseShow = true;
  770. },
  771. closePop() {
  772. this.toggleCourseShow = false;
  773. },
  774. async activeFunc(item, index) {
  775. this.teacherIndex = index;
  776. let findResult = "";
  777. this.goodsTeacher.forEach((citem, index) => {
  778. citem.courseList.forEach((e, e_index) => {
  779. if (e.courseId == item.courseId) {
  780. findResult = e;
  781. }
  782. });
  783. });
  784. this.jump(findResult, 1);
  785. },
  786. // 进入学习
  787. async jump(item, index, type) {
  788. if (this.courseId === item.courseId) {
  789. this.toggleCourseShow = false;
  790. return;
  791. }
  792. if (this.orderNum == 2 && index != 0) {
  793. let prevItem = this.courseList[index - 1];
  794. if (
  795. prevItem.stuAllNum + prevItem.recordNum <
  796. prevItem.secAllNum + prevItem.examNum
  797. ) {
  798. uni.showToast({
  799. icon: "none",
  800. title: "请按顺序学完上一课再学习这一课",
  801. });
  802. return;
  803. }
  804. }
  805. // 打回 需重修
  806. if (item.rebuild === 0) {
  807. this.$navTo.togo("/pages2/learn/details", {
  808. id: item.courseId,
  809. ...this.params(["goodsId", "orderGoodsId", "gradeId"]),
  810. });
  811. return;
  812. }
  813. if (type) {
  814. this.teacherIndex = 0;
  815. this.goodsTeacher.forEach((citem) => {
  816. if (citem.courseList.some((x) => x.courseId == item.courseId)) {
  817. this.teacherList = citem.teaList;
  818. }
  819. });
  820. }
  821. this.sectionItem = {};
  822. this.toggleCourseShow = false;
  823. this.courseId = item.courseId;
  824. this.originOnShow();
  825. },
  826. clickLeft() {
  827. uni.switchTab({
  828. url: "/pages/learn/index",
  829. });
  830. },
  831. toBack(delta = 1) {
  832. uni.navigateBack({
  833. delta,
  834. });
  835. },
  836. markConfirm() {
  837. uni.setClipboardData({
  838. data: this.markContent,
  839. success: () => {
  840. setTimeout(this.toBack, 1000);
  841. },
  842. });
  843. },
  844. noticeConfirm() {
  845. if (this.CountTo <= 0) {
  846. this.noticeShow = false;
  847. if (this.autoplay) {
  848. this.refPlv && this.refPlv.resumeVideo();
  849. }
  850. this.$api.baseHandoutTip({
  851. orderGoodsId: this.orderGoodsId,
  852. });
  853. }
  854. },
  855. baseHandoutTipList() {
  856. this.$api
  857. .baseHandoutTipList({
  858. orderGoodsId: this.orderGoodsId,
  859. })
  860. .then((res) => {
  861. if (res.data.rows.length == 0) {
  862. this.noticeShow = true;
  863. this.CountTo = 30;
  864. var timer = setInterval(() => {
  865. this.CountTo--;
  866. if (this.CountTo < 0) {
  867. clearInterval(timer);
  868. }
  869. }, 1000);
  870. }
  871. });
  872. },
  873. /**
  874. * 获取上次观看的直播
  875. */
  876. studyRecordGetLastLive() {
  877. this.$api
  878. .studyRecordGetLastLive({
  879. orderGoodsId: this.orderGoodsId,
  880. courseId: this.courseId,
  881. })
  882. .then((res) => {
  883. this.updateLiveLast(res.data.data);
  884. });
  885. },
  886. async initPlayVideo(sectionItem) {
  887. this.moduleId = sectionItem.moduleId;
  888. this.chapterId = sectionItem.chapterId;
  889. this.sectionItem = sectionItem;
  890. if (sectionItem.sectionType == 1) {
  891. //录播
  892. this.playVideo(sectionItem);
  893. } else if (sectionItem.sectionType == 2) {
  894. //直播
  895. this.studyRecordGetLastLive();
  896. } else if (sectionItem.sectionType == 3) {
  897. //回放
  898. this.playVideo(sectionItem);
  899. } else if (sectionItem.doType == 2) {
  900. uni.showModal({
  901. title: "温馨提示",
  902. content: "当前节视频已学完,是否进入考试?",
  903. success: (res) => {
  904. if (res.confirm) {
  905. this.toQuestionBank(sectionItem);
  906. }
  907. },
  908. });
  909. return;
  910. }
  911. },
  912. async submitPhoto(url, compareFaceData) {
  913. this.ossAvatarUrl = url;
  914. this.compareFaceData = compareFaceData;
  915. this.postCoursePhotoRecord()
  916. .then(async (res) => {
  917. this.photoHistoryList[this.photoIndex] = true;
  918. await this.postStudyRecord();
  919. if (this.erJianErZao && this.isReach) {
  920. await this.postStudyRecord(1);
  921. this.closeCamera();
  922. this.nextSection();
  923. return;
  924. }
  925. this.closeCamera();
  926. this.refPlv.resumeVideo();
  927. })
  928. .catch((err) => {
  929. uni.showToast({
  930. title: "上传接口报错,请重新拍照上传" + err,
  931. icon: "none",
  932. });
  933. this.$refs["camera"].reTake();
  934. });
  935. },
  936. toQuestionBank(sectionItem) {
  937. // type 1模块 2章 3节 4章卷 5模块卷
  938. uni.navigateTo({
  939. url:
  940. "/pages2/class/questionBank?courseId=" +
  941. this.courseId +
  942. "&gradeId=" +
  943. this.gradeId +
  944. "&isFromVideo=1&id=" +
  945. sectionItem.id +
  946. "&goodsid=" +
  947. this.goodsId +
  948. "&moduleId=" +
  949. (sectionItem.moduleId || 0) +
  950. "&chapterId=" +
  951. (sectionItem.chapterId || 0) +
  952. "&orderGoodsId=" +
  953. this.orderGoodsId +
  954. "&type=" +
  955. (sectionItem.type == 4 ? 1 : 3) +
  956. "&learning=" +
  957. sectionItem.studyStatus +
  958. "&isBackVideo=" +
  959. 1,
  960. });
  961. },
  962. studyRecordQueryLiveLast() {
  963. this.$api
  964. .studyRecordQueryLiveLast({
  965. gradeId: this.gradeId,
  966. orderGoodsId: this.orderGoodsId,
  967. courseId: this.courseId,
  968. })
  969. .then((res) => {
  970. let { data } = res.data;
  971. if (!data.sectionId) {
  972. data = this.menuAllList[0];
  973. }
  974. if (data.learning == 1 && this.orderNum == 2) {
  975. let next = this.menuAllList.find((e) => e.studyStatus != 1);
  976. next && (data = next);
  977. }
  978. this.initPlayVideo(data);
  979. });
  980. },
  981. goLive(item) {
  982. let moduleId = item.moduleId || 0;
  983. let chapterId = item.chapterId || 0;
  984. let sectionId = item.sectionId || item.menuId;
  985. let uuid = new Date().valueOf() + "";
  986. // buyCourse 是否购买课程:1是 0否
  987. let encode = encodeURIComponent(
  988. this.config.hostLive +
  989. "/pages/live/index?token=" +
  990. uni.getStorageSync("token") +
  991. "&userInfo=" +
  992. JSON.stringify(this.userInfo) +
  993. "&channelId=" +
  994. item.liveUrl +
  995. "&gradeId=" +
  996. this.gradeId +
  997. "&courseId=" +
  998. this.courseId +
  999. "&goodsId=" +
  1000. this.goodsId +
  1001. "&orderGoodsId=" +
  1002. this.orderGoodsId +
  1003. "&sectionId=" +
  1004. sectionId +
  1005. "&chapterId=" +
  1006. chapterId +
  1007. "&moduleId=" +
  1008. moduleId +
  1009. "&buyCourse=1" +
  1010. "&ident=" +
  1011. uuid
  1012. );
  1013. uni.navigateTo({
  1014. url: `../../pages/webview/index?url=` + encode,
  1015. });
  1016. },
  1017. studyRecordMenuAllList() {
  1018. // study/record/menuAllList
  1019. return this.$api
  1020. .studMenuAllList({
  1021. courseId: this.courseId,
  1022. ...this.params(["goodsId", "orderGoodsId", "gradeId"]),
  1023. })
  1024. .then((res) => {
  1025. let nowTime = Number(new Date().getTime() / 1000).toFixed(0);
  1026. if (res.data.data) {
  1027. this.menuAllList = res.data.data.filter(
  1028. (e) => e.doType != 1 || (e.doType == 2 && e.studyStatus == 1)
  1029. );
  1030. this.livingItem = res.data.data.find(
  1031. (item) =>
  1032. item.liveStartTime <= nowTime && item.liveEndTime > nowTime
  1033. );
  1034. }
  1035. return Promise.resolve();
  1036. });
  1037. },
  1038. async getbaseprofiletplists() {
  1039. let {
  1040. data: { code, rows },
  1041. } = await this.$api.getbaseprofiletplists({
  1042. goodsId: this.goodsId,
  1043. orderGoodsId: this.orderGoodsId,
  1044. });
  1045. if (code === 200 && rows.length && rows[0].keyValue) {
  1046. let baseRes = await this.$api.getbaseprofiletpId(this.goodsId);
  1047. if (baseRes.data.code === 200 && baseRes.data.data) {
  1048. let {
  1049. data: { code, data },
  1050. } = await this.$api.getbaseprofiletpgetInfo({
  1051. goodsId: this.goodsId,
  1052. orderGoodsId: this.orderGoodsId,
  1053. });
  1054. if (
  1055. code === 200 &&
  1056. (!data || (data.status === 3 && data.changeStatus === 1))
  1057. ) {
  1058. uni.showModal({
  1059. content: !data
  1060. ? "请前往填写资料"
  1061. : "资料审核不通过,请前往重新填写",
  1062. cancelText: "返回",
  1063. success: (resultst) => {
  1064. if (resultst.confirm) {
  1065. this.$navTo.togo("/pages2/verify/input", {
  1066. id: this.goodsId,
  1067. orderGoodsId: this.orderGoodsId,
  1068. });
  1069. }
  1070. if (resultst.cancel) {
  1071. uni.navigateBack();
  1072. }
  1073. },
  1074. });
  1075. return Promise.reject();
  1076. } else if (data.status === 1 && JSON.parse(rows[0].keyValue2)[0]) {
  1077. let {
  1078. data: { code, data },
  1079. } = await this.$api.getbaseprofileStampgetInfo({
  1080. goodsId: this.goodsId,
  1081. orderGoodsId: this.orderGoodsId,
  1082. });
  1083. if (
  1084. code === 200 &&
  1085. (!data || (data.status === 3 && data.changeStatus === 1))
  1086. ) {
  1087. uni.showModal({
  1088. content: !data
  1089. ? "请前往填写盖章资料"
  1090. : "资料盖章审核不通过,请前往重新填写",
  1091. cancelText: "返回",
  1092. success: (resultst) => {
  1093. if (resultst.confirm) {
  1094. this.$navTo.togo("/pages2/verify/input2", {
  1095. id: this.goodsId,
  1096. orderGoodsId: this.orderGoodsId,
  1097. });
  1098. }
  1099. if (resultst.cancel) {
  1100. uni.navigateBack();
  1101. }
  1102. },
  1103. });
  1104. return Promise.reject();
  1105. }
  1106. }
  1107. }
  1108. }
  1109. return Promise.resolve();
  1110. },
  1111. async isCanLearn() {
  1112. this.option.isQ !== "" && (await this.qCheckIsCanLearn());
  1113. await this.getbaseprofiletplists();
  1114. await this.getGradeInfo();
  1115. await this.getGoodsDetail();
  1116. },
  1117. /**
  1118. * 计算tabs宽度
  1119. */
  1120. itemWidth() {
  1121. return 100 / this.list.length + "%";
  1122. },
  1123. loadedmetadata(event) {
  1124. this.refPlv = this.$refs.player;
  1125. },
  1126. getPhotoLastRecord() {
  1127. let { chapterId, sectionId, moduleId } = this.sectionItem;
  1128. let data = {
  1129. ...this.params(),
  1130. sectionId: sectionId || 0,
  1131. gradeId: this.gradeId,
  1132. chapterId: chapterId || 0,
  1133. moduleId: moduleId || 0,
  1134. };
  1135. this.$api.getPhotoLastRecord(data).then((res) => {
  1136. if (res.data.code == 200) {
  1137. //清空历史数据
  1138. this.photoHistoryList = [];
  1139. this.photoList = [];
  1140. for (let i = 0; i < res.data.data.length; i++) {
  1141. //-2存储随机拍照数组
  1142. if (res.data.data[i].photoIndex == -2) {
  1143. this.photoList =
  1144. res.data.data[i].timeInterval &&
  1145. res.data.data[i].timeInterval.split(",");
  1146. } else {
  1147. this.photoHistoryList.push(res.data.data[i].photoIndex);
  1148. }
  1149. }
  1150. }
  1151. });
  1152. },
  1153. //postTime 只提交随机时间
  1154. postCoursePhotoRecord(postTime = false) {
  1155. return new Promise((resolve, reject) => {
  1156. let data = {
  1157. ...this.params(["orderGoodsId", "goodsId", "courseId", "gradeId"]),
  1158. photo: this.ossAvatarUrl,
  1159. sectionId: this.sectionId,
  1160. photoTime: this.playTime || 0,
  1161. photoIndex: postTime ? -2 : this.photoIndex, //从0算起,-2只提交随机时间
  1162. photoNum: this.photoNum,
  1163. chapterId: this.chapterId,
  1164. moduleId: this.moduleId,
  1165. timeInterval: postTime ? this.photoList.join(",") : "",
  1166. };
  1167. this.$api
  1168. .coursePhotoRecord(data)
  1169. .then((res) => {
  1170. if (res.data.code == 200) {
  1171. resolve();
  1172. } else {
  1173. reject();
  1174. }
  1175. })
  1176. .catch((err) => {
  1177. reject();
  1178. });
  1179. });
  1180. },
  1181. randomNum(minNum, maxNum) {
  1182. switch (arguments.length) {
  1183. case 1:
  1184. return parseInt(Math.random() * minNum + 1, 10);
  1185. break;
  1186. case 2:
  1187. return parseInt(Math.random() * (maxNum - minNum + 1) + minNum, 10);
  1188. break;
  1189. default:
  1190. return 0;
  1191. break;
  1192. }
  1193. },
  1194. //配置随机拍照时间
  1195. configPhoto(duration) {
  1196. if ((this.photoConfig && this.photoList.length) || !this.isPlaying) {
  1197. return;
  1198. }
  1199. let totalVideoTime = this.refPlv.getDuration();
  1200. this.photoConfig = true;
  1201. if (this.erJianErZao) {
  1202. this.photoList = this.randomConfig(totalVideoTime, duration);
  1203. console.log(this.photoList, "this.photoList");
  1204. return;
  1205. }
  1206. //没有历史拍照间隔数据
  1207. if (!this.photoList || this.photoList.length == 0) {
  1208. // 46 * 60
  1209. this.photoList = this.commonConfig(
  1210. totalVideoTime,
  1211. this.jjShiGongYuan ? 10 : undefined
  1212. );
  1213. this.postCoursePhotoRecord(true); //提交随机拍照时间数组
  1214. }
  1215. console.log(this.photoList, "this.photoList");
  1216. },
  1217. // 二建随机拍摄时间
  1218. randomConfig(totalVideoTime, duration) {
  1219. this.photoHistoryList = [];
  1220. let photoList = [duration];
  1221. let pre = duration;
  1222. if (totalVideoTime > 300) {
  1223. while (pre <= totalVideoTime) {
  1224. pre += this.randomNum(780, 900);
  1225. pre <= totalVideoTime && photoList.push(pre);
  1226. }
  1227. if (totalVideoTime - 300 > photoList.slice(-1)[0]) {
  1228. photoList.push(this.randomNum(totalVideoTime - 180, totalVideoTime));
  1229. }
  1230. }
  1231. return photoList;
  1232. },
  1233. // 随机前后五分钟
  1234. commonConfig(totalVideoTime, fixS) {
  1235. let photoList = [0];
  1236. // 固定间隔时间取
  1237. if (fixS) {
  1238. let num = Math.ceil(totalVideoTime / fixS);
  1239. for (let i = 1; i < num; i++) {
  1240. photoList.push(i * fixS);
  1241. }
  1242. this.photoNum = num;
  1243. } else {
  1244. if (this.photoNum == 3) {
  1245. if (totalVideoTime >= 900) {
  1246. //大于15分钟
  1247. let centerTime = Math.floor(totalVideoTime / 2); //获取中间时间
  1248. let centerMinTime = centerTime - 300; //前后5分钟
  1249. let centerMaxTime = centerTime + 300;
  1250. let centerTakeTime = this.randomNum(centerMinTime, centerMaxTime);
  1251. photoList.push(centerTakeTime); //中间拍一张
  1252. let endMaxTime = totalVideoTime - 60;
  1253. let endMinTime = totalVideoTime - 300;
  1254. let endTakeTime = this.randomNum(endMinTime, endMaxTime);
  1255. photoList.push(endTakeTime); //最后拍一张
  1256. } else {
  1257. //小于15分钟
  1258. let centerTime = this.randomNum(
  1259. (1 / 3) * totalVideoTime,
  1260. (2 / 3) * totalVideoTime
  1261. );
  1262. photoList.push(centerTime);
  1263. let endTakeTime = this.randomNum(
  1264. (2 / 3) * totalVideoTime,
  1265. totalVideoTime
  1266. );
  1267. photoList.push(endTakeTime);
  1268. }
  1269. }
  1270. }
  1271. return photoList;
  1272. },
  1273. studyNotice() {
  1274. this.noticeShow = true;
  1275. },
  1276. //正常播放视频
  1277. async playVideo(item) {
  1278. this.sectionItem = item;
  1279. let { learning, videoCurrentTime, recordingUrl } = item;
  1280. this.videoCurrentTime =
  1281. videoCurrentTime || (await this.getRecordLast(item));
  1282. // 往前播3秒
  1283. if (this.videoCurrentTime > 3) {
  1284. this.videoCurrentTime -= 3;
  1285. }
  1286. // 查找拍照历史
  1287. if ((this.photoNum > 0 || this.jjShiGongYuan) && learning != 1) {
  1288. await this.getPhotoLastRecord();
  1289. }
  1290. if (this.refPlv) {
  1291. this.refPlv.changeVid({
  1292. vid: recordingUrl,
  1293. videoCurrentTime: this.videoCurrentTime,
  1294. });
  1295. }
  1296. },
  1297. getRecordLast(sectionItem) {
  1298. let { chapterId, sectionId, courseId, moduleId } = sectionItem;
  1299. return new Promise((resolve) => {
  1300. let data = {
  1301. ...this.params(),
  1302. gradeId:
  1303. this.gradeId || this.gradeId == 0 ? Number(this.gradeId) : null,
  1304. sectionId: sectionId || 0,
  1305. chapterId: chapterId || 0,
  1306. moduleId: moduleId || 0,
  1307. };
  1308. this.$api.recordLast(data).then((res) => {
  1309. resolve(res.data.data.videoCurrentTime);
  1310. });
  1311. });
  1312. },
  1313. jumpNote(item) {
  1314. this.$u.toast("即将跳到笔记位置");
  1315. if (this.sectionId != item.sectionId) {
  1316. this.initPlayVideo({
  1317. sectionType: 1,
  1318. ...item,
  1319. videoCurrentTime: Number(item.noteSecond),
  1320. });
  1321. } else {
  1322. this.refPlv.seekVideo(item.noteSecond);
  1323. }
  1324. },
  1325. getGradeInfo() {
  1326. // 即刻 1 待定2 日期3
  1327. return this.$api.goodsGradeInfo(this.gradeId).then((res) => {
  1328. if (res.data.code == 200) {
  1329. let { data } = res.data;
  1330. if (
  1331. data.learningStatus == 2 ||
  1332. (data.learningStatus == 3 &&
  1333. Number(data.learningTimeStart) > Number(new Date() / 1000))
  1334. ) {
  1335. uni.showModal({
  1336. showCancel: false,
  1337. confirmText: "确定",
  1338. content:
  1339. "当前课程正在申请中,正式开班后方可进行学习,请耐心等候!",
  1340. success: function (resultst) {
  1341. uni.navigateBack();
  1342. },
  1343. });
  1344. return Promise.reject();
  1345. }
  1346. }
  1347. });
  1348. },
  1349. postStudyRecord(status = 0, sectionId = this.sectionId) {
  1350. if (!this.refPlv && this.playVid) {
  1351. return;
  1352. }
  1353. let currentTime = this.refPlv.playCurrentTime();
  1354. let PlayDuration = this.refPlv.playVideoTime();
  1355. if (currentTime < 10 && !this.ossAvatarUrl) {
  1356. console.log("不提交", currentTime);
  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>