detail.vue 51 KB

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