detail.vue 49 KB

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