detail.vue 50 KB

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