detail.vue 51 KB

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