detail.vue 49 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925
  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. 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. // buyCourse 是否购买课程:1是 0否
  911. let encode = encodeURIComponent(
  912. this.other.hostLive +
  913. "/pages/live/index?token=" +
  914. uni.getStorageSync("token") +
  915. "&userInfo=" +
  916. JSON.stringify(this.userInfo) +
  917. "&channelId=" +
  918. item.liveUrl +
  919. "&gradeId=" +
  920. this.gradeId +
  921. "&courseId=" +
  922. this.courseId +
  923. "&goodsId=" +
  924. this.goodsId +
  925. "&orderGoodsId=" +
  926. this.orderGoodsId +
  927. "&sectionId=" +
  928. sectionId +
  929. "&chapterId=" +
  930. chapterId +
  931. "&moduleId=" +
  932. moduleId +
  933. "&buyCourse=1" +
  934. "&ident=" +
  935. uuid
  936. );
  937. uni.navigateTo({
  938. url: `/pages5/webview/index?url=` + encode,
  939. });
  940. },
  941. studyRecordMenuAllList() {
  942. // study/record/menuAllList
  943. return this.$api
  944. .studMenuAllList({
  945. courseId: this.courseId,
  946. ...this.params(["goodsId", "orderGoodsId", "gradeId"]),
  947. })
  948. .then((res) => {
  949. let nowTime = Number(new Date().getTime() / 1000).toFixed(0);
  950. if (res.data.data) {
  951. this.menuAllList = res.data.data.filter(
  952. (e) => e.doType != 1 || (e.doType == 2 && e.studyStatus == 1)
  953. );
  954. this.livingItem = res.data.data.find(
  955. (item) =>
  956. item.liveStartTime <= nowTime && item.liveEndTime > nowTime
  957. );
  958. }
  959. return Promise.resolve();
  960. });
  961. },
  962. async getbaseprofiletplists() {
  963. let {
  964. data: {
  965. code,
  966. rows
  967. },
  968. } = await this.$api.getbaseprofiletplists({
  969. goodsId: this.goodsId,
  970. orderGoodsId: this.orderGoodsId,
  971. });
  972. if (code === 200 && rows.length && rows[0].keyValue) {
  973. let baseRes = await this.$api.getbaseprofiletpId(this.goodsId);
  974. if (baseRes.data.code === 200 && baseRes.data.data) {
  975. let {
  976. data: {
  977. code,
  978. data
  979. },
  980. } = await this.$api.getbaseprofiletpgetInfo({
  981. goodsId: this.goodsId,
  982. orderGoodsId: this.orderGoodsId,
  983. });
  984. if (
  985. code === 200 &&
  986. (!data || (data.status === 3 && data.changeStatus === 1))
  987. ) {
  988. uni.showModal({
  989. content: !data ?
  990. "请前往填写资料" : "资料审核不通过,请前往重新填写",
  991. cancelText: "返回",
  992. success: (resultst) => {
  993. if (resultst.confirm) {
  994. this.$navTo.togo("/pages2/verify/input", {
  995. id: this.goodsId,
  996. orderGoodsId: this.orderGoodsId,
  997. });
  998. }
  999. if (resultst.cancel) {
  1000. uni.navigateBack();
  1001. }
  1002. },
  1003. });
  1004. return Promise.reject();
  1005. } else if (data.status === 1 && JSON.parse(rows[0].keyValue2)[0] && false) {
  1006. let {
  1007. data: {
  1008. code,
  1009. data
  1010. },
  1011. } = await this.$api.getbaseprofileStampgetInfo({
  1012. goodsId: this.goodsId,
  1013. orderGoodsId: this.orderGoodsId,
  1014. });
  1015. if (
  1016. code === 200 &&
  1017. (!data || (data.status === 3 && data.changeStatus === 1))
  1018. ) {
  1019. uni.showModal({
  1020. content: !data ?
  1021. "请前往填写盖章资料" : "资料盖章审核不通过,请前往重新填写",
  1022. cancelText: "返回",
  1023. success: (resultst) => {
  1024. if (resultst.confirm) {
  1025. this.$navTo.togo("/pages2/verify/input2", {
  1026. id: this.goodsId,
  1027. orderGoodsId: this.orderGoodsId,
  1028. });
  1029. }
  1030. if (resultst.cancel) {
  1031. uni.navigateBack();
  1032. }
  1033. },
  1034. });
  1035. return Promise.reject();
  1036. }
  1037. } else if (data.status !== 1 && baseRes.data.data.checkStatus == 1) {
  1038. uni.showModal({
  1039. content: "资料正在审核中,暂无法学习,请耐心等待!如需加急审核,请联系客服人员",
  1040. cancelText: "返回",
  1041. success: (resultst) => {
  1042. if (resultst.confirm) {
  1043. uni.switchTab({
  1044. url: '/pages/learn/index'
  1045. });
  1046. }
  1047. if (resultst.cancel) {
  1048. uni.switchTab({
  1049. url: '/pages/learn/index'
  1050. });
  1051. }
  1052. },
  1053. });
  1054. return Promise.reject();
  1055. }
  1056. }
  1057. }
  1058. return Promise.resolve();
  1059. },
  1060. async isCanLearn() {
  1061. this.option.isQ !== "" && (await this.qCheckIsCanLearn());
  1062. await this.getGradeInfo();
  1063. await this.getGoodsDetail();
  1064. },
  1065. /**
  1066. * 计算tabs宽度
  1067. */
  1068. itemWidth() {
  1069. return 100 / this.list.length + "%";
  1070. },
  1071. loadedmetadata(event) {
  1072. this.refPlv = this.$refs.player;
  1073. },
  1074. getPhotoLastRecord() {
  1075. let {
  1076. chapterId,
  1077. sectionId,
  1078. moduleId
  1079. } = this.sectionItem;
  1080. let data = {
  1081. ...this.params(),
  1082. sectionId: sectionId || 0,
  1083. gradeId: this.gradeId,
  1084. chapterId: chapterId || 0,
  1085. moduleId: moduleId || 0,
  1086. };
  1087. this.$api.getPhotoLastRecord(data).then((res) => {
  1088. if (res.data.code == 200) {
  1089. //清空历史数据
  1090. this.photoHistoryList = [];
  1091. this.photoList = [];
  1092. for (let i = 0; i < res.data.data.length; i++) {
  1093. //-2存储随机拍照数组
  1094. if (res.data.data[i].photoIndex == -2) {
  1095. this.photoList =
  1096. res.data.data[i].timeInterval &&
  1097. res.data.data[i].timeInterval.split(",");
  1098. } else {
  1099. this.photoHistoryList.push(res.data.data[i].photoIndex);
  1100. }
  1101. }
  1102. }
  1103. });
  1104. },
  1105. //postTime 只提交随机时间
  1106. postCoursePhotoRecord(postTime = false) {
  1107. return new Promise((resolve, reject) => {
  1108. let data = {
  1109. ...this.params(["orderGoodsId", "goodsId", "courseId", "gradeId"]),
  1110. photo: this.ossAvatarUrl,
  1111. sectionId: this.sectionId,
  1112. photoTime: this.playTime || 0,
  1113. photoIndex: postTime ? -2 : this.photoIndex, //从0算起,-2只提交随机时间
  1114. photoNum: this.photoNum,
  1115. chapterId: this.chapterId,
  1116. moduleId: this.moduleId,
  1117. timeInterval: postTime ? this.photoList.join(",") : "",
  1118. };
  1119. this.$api
  1120. .coursePhotoRecord(data)
  1121. .then((res) => {
  1122. if (res.data.code == 200) {
  1123. resolve();
  1124. } else {
  1125. reject();
  1126. }
  1127. })
  1128. .catch((err) => {
  1129. reject();
  1130. });
  1131. });
  1132. },
  1133. randomNum(minNum, maxNum) {
  1134. switch (arguments.length) {
  1135. case 1:
  1136. return parseInt(Math.random() * minNum + 1, 10);
  1137. break;
  1138. case 2:
  1139. return parseInt(Math.random() * (maxNum - minNum + 1) + minNum, 10);
  1140. break;
  1141. default:
  1142. return 0;
  1143. break;
  1144. }
  1145. },
  1146. //配置随机拍照时间
  1147. configPhoto(duration) {
  1148. if ((this.photoConfig && this.photoList.length) || !this.isPlaying) {
  1149. return;
  1150. }
  1151. let totalVideoTime = this.refPlv.getDuration();
  1152. this.photoConfig = true;
  1153. if (this.erJianErZao) {
  1154. this.photoList = this.randomConfig(totalVideoTime, duration);
  1155. console.log(this.photoList, "this.photoList");
  1156. return;
  1157. }
  1158. //没有历史拍照间隔数据
  1159. if (!this.photoList || this.photoList.length == 0) {
  1160. // 46 * 60
  1161. this.photoList = this.commonConfig(
  1162. totalVideoTime,
  1163. this.jjShiGongYuan ? totalVideoTime < 2760 ? (46 * 60) - 1 : (45 * 60) - 1 : undefined
  1164. );
  1165. this.postCoursePhotoRecord(true); //提交随机拍照时间数组
  1166. }
  1167. console.log(this.photoList, "this.photoList");
  1168. },
  1169. // 二建随机拍摄时间
  1170. randomConfig(totalVideoTime, duration) {
  1171. this.photoHistoryList = [];
  1172. let photoList = [duration];
  1173. let pre = duration;
  1174. if (totalVideoTime > 300) {
  1175. while (pre <= totalVideoTime) {
  1176. pre += this.randomNum(780, 900);
  1177. pre <= totalVideoTime && photoList.push(pre);
  1178. }
  1179. if (totalVideoTime - 300 > photoList.slice(-1)[0]) {
  1180. photoList.push(this.randomNum(totalVideoTime - 180, totalVideoTime));
  1181. }
  1182. }
  1183. return photoList;
  1184. },
  1185. // 随机前后五分钟
  1186. commonConfig(totalVideoTime, fixS) {
  1187. let photoList = [];
  1188. // 固定间隔时间取
  1189. if (fixS) {
  1190. let num = Math.ceil(totalVideoTime / fixS);
  1191. if (num == 1) {
  1192. photoList.push(parseInt(totalVideoTime / 2));
  1193. } else {
  1194. for (let i = 0; i < num; i++) {
  1195. photoList.push(parseInt((totalVideoTime / (num + 1)) * (i + 1)));
  1196. }
  1197. }
  1198. this.photoNum = num;
  1199. } else {
  1200. photoList = [0];
  1201. if (this.photoNum == 3) {
  1202. if (totalVideoTime >= 900) {
  1203. //大于15分钟
  1204. let centerTime = Math.floor(totalVideoTime / 2); //获取中间时间
  1205. let centerMinTime = centerTime - 300; //前后5分钟
  1206. let centerMaxTime = centerTime + 300;
  1207. let centerTakeTime = this.randomNum(centerMinTime, centerMaxTime);
  1208. photoList.push(centerTakeTime); //中间拍一张
  1209. let endMaxTime = totalVideoTime - 60;
  1210. let endMinTime = totalVideoTime - 300;
  1211. let endTakeTime = this.randomNum(endMinTime, endMaxTime);
  1212. photoList.push(endTakeTime); //最后拍一张
  1213. } else {
  1214. //小于15分钟
  1215. let centerTime = this.randomNum(
  1216. (1 / 3) * totalVideoTime,
  1217. (2 / 3) * totalVideoTime
  1218. );
  1219. photoList.push(centerTime);
  1220. let endTakeTime = this.randomNum(
  1221. (2 / 3) * totalVideoTime,
  1222. totalVideoTime
  1223. );
  1224. photoList.push(endTakeTime);
  1225. }
  1226. }
  1227. }
  1228. return photoList;
  1229. },
  1230. studyNotice() {
  1231. this.noticeShow = true;
  1232. },
  1233. //正常播放视频
  1234. async playVideo(item) {
  1235. let {
  1236. learning,
  1237. videoCurrentTime,
  1238. recordingUrl
  1239. } = item;
  1240. this.videoCurrentTime =
  1241. videoCurrentTime || (await this.getRecordLast(item));
  1242. // 往前播3秒
  1243. if (this.videoCurrentTime > 3) {
  1244. this.videoCurrentTime -= 3;
  1245. }
  1246. this.sectionItem = item;
  1247. // 查找拍照历史
  1248. if ((this.photoNum > 0 || this.jjShiGongYuan || this.erJianErZao) && learning != 1) {
  1249. await this.getPhotoLastRecord();
  1250. }
  1251. if (this.refPlv) {
  1252. this.refPlv.changeVid({
  1253. vid: recordingUrl,
  1254. videoCurrentTime: this.videoCurrentTime,
  1255. });
  1256. }
  1257. },
  1258. getRecordLast(sectionItem) {
  1259. let {
  1260. chapterId,
  1261. sectionId,
  1262. courseId,
  1263. moduleId
  1264. } = sectionItem;
  1265. return new Promise((resolve) => {
  1266. let data = {
  1267. ...this.params(),
  1268. gradeId: this.gradeId || this.gradeId == 0 ? Number(this.gradeId) : null,
  1269. sectionId: sectionId || 0,
  1270. chapterId: chapterId || 0,
  1271. moduleId: moduleId || 0,
  1272. };
  1273. this.$api.recordLast(data).then((res) => {
  1274. resolve(res.data.data.videoCurrentTime);
  1275. });
  1276. });
  1277. },
  1278. jumpNote(item) {
  1279. this.$u.toast("即将跳到笔记位置");
  1280. if (this.sectionId != item.sectionId) {
  1281. this.initPlayVideo({
  1282. sectionType: 1,
  1283. ...item,
  1284. videoCurrentTime: Number(item.noteSecond),
  1285. });
  1286. } else {
  1287. this.refPlv.seekVideo(item.noteSecond);
  1288. }
  1289. },
  1290. getGradeInfo() {
  1291. // 即刻 1 待定2 日期3
  1292. return this.$api.goodsGradeInfo(this.gradeId).then((res) => {
  1293. if (res.data.code == 200) {
  1294. let {
  1295. data
  1296. } = res.data;
  1297. if (
  1298. data.learningStatus == 2 ||
  1299. (data.learningStatus == 3 &&
  1300. Number(data.learningTimeStart) > Number(new Date() / 1000))
  1301. ) {
  1302. uni.showModal({
  1303. showCancel: false,
  1304. confirmText: "确定",
  1305. content: "当前课程正在申请中,正式开班后方可进行学习,请耐心等候!",
  1306. success: function(resultst) {
  1307. uni.navigateBack();
  1308. },
  1309. });
  1310. return Promise.reject();
  1311. }
  1312. }
  1313. });
  1314. },
  1315. postStudyRecord(status = 0, sectionId = this.sectionId) {
  1316. if (!this.refPlv && this.playVid) {
  1317. return;
  1318. }
  1319. let currentTime = this.refPlv.playCurrentTime();
  1320. let PlayDuration = this.refPlv.playVideoTime();
  1321. if (currentTime < 10 && !this.ossAvatarUrl) {
  1322. if (status == 0) return;
  1323. currentTime = this.playTime;
  1324. }
  1325. let self = this;
  1326. let fromPlat = 1;
  1327. // #ifdef H5
  1328. fromPlat = 3;
  1329. // #endif
  1330. let data = {
  1331. ...this.params([
  1332. "orderGoodsId",
  1333. "goodsId",
  1334. "courseId",
  1335. "erJianErZao",
  1336. "gradeId",
  1337. ]),
  1338. fromPlat, //来源平台 1小程序 2网站
  1339. photo: self.ossAvatarUrl,
  1340. sectionId: sectionId || 0,
  1341. studyDuration: parseInt(PlayDuration),
  1342. chapterId: this.chapterId || 0,
  1343. moduleId: this.moduleId || 0,
  1344. videoCurrentTime: parseInt(currentTime),
  1345. };
  1346. if (this.ossAvatarUrl) {
  1347. data.similarity = this.compareFaceData; // 相似度
  1348. }
  1349. if (status > 0) {
  1350. data.status = status;
  1351. }
  1352. console.log(data, "记录参数");
  1353. return new Promise((resolve, reject) => {
  1354. this.$api
  1355. .studyRecord(data)
  1356. .then((res) => {
  1357. console.log(res, "记录返回");
  1358. let {
  1359. code,
  1360. msg
  1361. } = res.data;
  1362. if (code == 200) {
  1363. if (status > 0) {
  1364. // 刷新数据
  1365. uni.$emit("playEnd");
  1366. this.studyRecordMenuAllList();
  1367. }
  1368. self.ossAvatarUrl = "";
  1369. } else if (code == 600) {
  1370. uni.showModal({
  1371. showCancel: false,
  1372. title: "提示",
  1373. content: msg,
  1374. success: (resultst) => {
  1375. uni.navigateBack();
  1376. },
  1377. });
  1378. this.closeCamera();
  1379. return
  1380. } else if (code == 558) {
  1381. this.CountTo1 = msg.split(",")[1];
  1382. this.noticeShow1 = true;
  1383. var timer = setInterval(() => {
  1384. this.CountTo1--;
  1385. if (this.CountTo1 < 0) {
  1386. this.noticeShow1 = false;
  1387. clearInterval(timer);
  1388. this.postStudyRecord(1).then(this.nextSection);
  1389. }
  1390. }, 1000);
  1391. this.closeCamera();
  1392. return
  1393. } else {
  1394. uni.showToast({
  1395. icon: "none",
  1396. title: res.data.msg,
  1397. duration: 2000,
  1398. });
  1399. if (code == 559) {
  1400. this.isReach = true;
  1401. this.openCamera()
  1402. }
  1403. return
  1404. }
  1405. resolve();
  1406. })
  1407. .catch((err) => {
  1408. this.studyRecordMenuAllList();
  1409. });
  1410. });
  1411. },
  1412. timeEvent(time) {
  1413. console.log(this.refPlv.getDuration(), 'getDurationgetDuration')
  1414. this.clearPauseTimer();
  1415. if (this.playSecIsLearn && (this.erJianErZao || this.jjShiGongYuan || this.photoNum > 0)) {
  1416. this.configPhoto(time);
  1417. this.isReach = false;
  1418. const index = this.photoList.findIndex((e) => e < time && e > time - 8);
  1419. if (index != -1 && !this.photoHistoryList[index] && this.photoHistoryList[index] != 0) {
  1420. this.photoIndex = index;
  1421. // 拍照
  1422. this.openCamera();
  1423. }
  1424. }
  1425. },
  1426. // 新增用户视频学习日志
  1427. studyLog() {
  1428. this.$http({
  1429. url: "/user/study/log",
  1430. method: "post",
  1431. data: {
  1432. ...this.params(),
  1433. moduleId: this.moduleId || 0,
  1434. chapterId: this.chapterId || 0,
  1435. sectionId: this.sectionId || 0,
  1436. fromPlat: 1, //来源平台 1小程序 2PC网站
  1437. goodsType: 1, // 商品类型 1视频2题库 3补考 4前培 5虚拟赠送题库 6直播
  1438. },
  1439. }).then((res) => {});
  1440. },
  1441. timeupdate(time) {
  1442. console.log("🚀 ~ file: detail.vue:1498 ~ timeupdate ~ time:");
  1443. if (this.noticeShow) {
  1444. this.refPlv.playPause();
  1445. return;
  1446. }
  1447. this.playTime = time;
  1448. this.throttleFn();
  1449. this.timeEvent(time);
  1450. },
  1451. playing() {
  1452. //特殊设备跳过拍照停止学习
  1453. if (this.showCamera) {
  1454. this.refPlv.playPause();
  1455. this.refPlv.exitFullScreen();
  1456. return
  1457. }
  1458. console.log("播放");
  1459. this.isPlaying = true;
  1460. this.clearPauseTimer();
  1461. },
  1462. openCamera() {
  1463. if (this.showCamera) return;
  1464. this.showCamera = true;
  1465. this.refPlv.playPause();
  1466. this.refPlv.exitFullScreen();
  1467. },
  1468. closeCamera() {
  1469. console.log("关闭")
  1470. this.showCamera = false;
  1471. },
  1472. pause() {
  1473. console.log("暂停");
  1474. this.isPlaying = false;
  1475. this.erJianErZaoPauseTip();
  1476. },
  1477. async ended() {
  1478. console.log("结束");
  1479. this.isPlaying = false;
  1480. uni.showToast({
  1481. icon: "none",
  1482. title: "播放完毕",
  1483. });
  1484. this.clearPauseTimer();
  1485. await this.postStudyRecord(1);
  1486. this.nextSection();
  1487. },
  1488. playerError() {
  1489. console.log("播放错误");
  1490. },
  1491. //播放下一节
  1492. nextSection() {
  1493. console.log("播放下一节");
  1494. if (!this.menuAllList.length) {
  1495. return;
  1496. }
  1497. this.curPlayIndex = this.menuAllList.findIndex((item) => {
  1498. let i_sectionId = item.sectionId || 0;
  1499. let i_chapterId = item.chapterId || 0;
  1500. let i_moduleId = item.moduleId || 0;
  1501. return (
  1502. i_sectionId == this.sectionId &&
  1503. i_chapterId == this.chapterId &&
  1504. i_moduleId == this.moduleId
  1505. );
  1506. });
  1507. let data = this.menuAllList[this.curPlayIndex + 1];
  1508. data.learning = data.learning || data.studyStatus
  1509. if (!data) {
  1510. //第二个弹窗
  1511. uni.showModal({
  1512. title: "温馨提示",
  1513. content: "恭喜您课程学习全部完成,教务会在1-3个工作日内完成学习初审,请耐心等待。",
  1514. showCancel: !this.erJianErZao,
  1515. success: (res) => {
  1516. if (res.confirm) {
  1517. uni.switchTab({
  1518. url: "/pages/learn/index",
  1519. });
  1520. }
  1521. },
  1522. });
  1523. } else {
  1524. if (data.doType == 2) {
  1525. if (data.studyStatus == 1) {
  1526. uni.showToast({
  1527. title: "试卷已合格!",
  1528. duration: 2000,
  1529. icon: "none",
  1530. });
  1531. return;
  1532. }
  1533. uni.showModal({
  1534. title: "温馨提示",
  1535. content: "当前节视频已学完,是否进入考试?",
  1536. success: (res) => {
  1537. if (res.confirm) {
  1538. this.toQuestionBank(data);
  1539. }
  1540. },
  1541. });
  1542. return;
  1543. }
  1544. uni.showModal({
  1545. title: "温馨提示",
  1546. content: "当前节视频已学完,继续学习下一节?",
  1547. success: async (res) => {
  1548. if (res.confirm) {
  1549. this.moduleId = data.moduleId;
  1550. this.chapterId = data.chapterId;
  1551. this.sectionId = data.sectionId;
  1552. if (data.sectionType == 1) {
  1553. //录播
  1554. this.photoConfig = false;
  1555. this.sectionItem = data;
  1556. this.playVideo(data);
  1557. } else if (data.sectionType == 2) {
  1558. //直播
  1559. this.studyRecordGetLastLive();
  1560. } else if (data.sectionType == 3) {
  1561. //回放
  1562. this.sectionItem = data;
  1563. this.playVideo(data);
  1564. }
  1565. this.updateChapterOpen(true);
  1566. }
  1567. },
  1568. });
  1569. }
  1570. },
  1571. async userConfirmInfoDetail() {
  1572. let info = await this.$api.userConfirmInfoDetail({
  1573. orderGoodsId: this.orderGoodsId,
  1574. });
  1575. if (!info.data.data || info.data.data.pushInfo !== 1) {
  1576. uni.showModal({
  1577. showCancel: false,
  1578. title: "提示",
  1579. content: "开通信息推送不成功,无法进入学习!",
  1580. success: (resultst) => {
  1581. uni.navigateBack();
  1582. },
  1583. });
  1584. return Promise.reject();
  1585. }
  1586. },
  1587. checkFinishRequiredCourse() {
  1588. return this.$api
  1589. .checkFinishRequiredCourse({
  1590. businessId: this.goodsData.businessId,
  1591. goodsId: this.goodsId,
  1592. })
  1593. .then((res) => {
  1594. if (res.data.data > 0) {
  1595. uni.showModal({
  1596. showCancel: false,
  1597. confirmText: "确定",
  1598. content: "该业务层次下有未学完的商品,无法学习新商品!",
  1599. success: function(resultst) {
  1600. uni.navigateBack();
  1601. },
  1602. });
  1603. return Promise.reject();
  1604. }
  1605. return Promise.resolve();
  1606. });
  1607. },
  1608. async getGoodsDetail() {
  1609. let {
  1610. data
  1611. } = await this.$api.goodsDetail(this.goodsId);
  1612. this.goodsData = data.data;
  1613. if (data.data.firstChoiceStatus) {
  1614. uni.redirectTo({
  1615. 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}`,
  1616. });
  1617. return
  1618. }
  1619. await this.getbaseprofiletplists();
  1620. this.erJianErZao = this.goodsData.erJianErZao;
  1621. this.jjShiGongYuan = this.goodsData.jjShiGongYuan;
  1622. if (this.erJianErZao || this.jjShiGongYuan) {
  1623. await this.userConfirmInfoDetail();
  1624. }
  1625. if (this.erJianErZao) {
  1626. this.option.periodWaitTime && (await this.checkFinishRequiredCourse());
  1627. }
  1628. this.goodsData.buyNote && this.baseHandoutTipList();
  1629. !this.gradeId && (this.gradeId = this.goodsData.gradeId);
  1630. if (this.goodsData.goodsPlayConfig) {
  1631. this.goodsPlayConfig = JSON.parse(this.goodsData.goodsPlayConfig);
  1632. if (this.goodsPlayConfig.autoPlay > 0) {
  1633. this.autoplay = true;
  1634. }
  1635. if (this.goodsPlayConfig.drag > 0 && !this.erJianErZao) {
  1636. // #ifdef MP-WEIXIN
  1637. this.isAllowSeek = "yes";
  1638. // #endif
  1639. // #ifdef H5
  1640. this.isAllowSeek = "off";
  1641. // #endif
  1642. }
  1643. if (this.goodsPlayConfig.speed > 0) {
  1644. this.playbackRate = [0.5, 0.8, 1.0, 1.25, 1.5, 2.0];
  1645. }
  1646. }
  1647. if (this.goodsData.goodsPhotographConfig) {
  1648. this.goodsPhotographConfig = JSON.parse(
  1649. this.goodsData.goodsPhotographConfig
  1650. );
  1651. if (this.goodsPhotographConfig.photoNum > 0) {
  1652. this.photoNum = this.goodsPhotographConfig.photoNum;
  1653. }
  1654. }
  1655. },
  1656. change(index) {
  1657. this.current = index;
  1658. },
  1659. paramsFn(
  1660. keys = ["orderGoodsId", "goodsId", "courseId", "gradeId", "sectionItem"]
  1661. ) {
  1662. return this.params(keys);
  1663. },
  1664. },
  1665. provide() {
  1666. return {
  1667. paramsFn: this.paramsFn,
  1668. };
  1669. },
  1670. };
  1671. </script>
  1672. <style lang="scss" scope>
  1673. @import "./css/detail.scss";
  1674. .top {
  1675. &__header {
  1676. position: relative;
  1677. width: 100%;
  1678. height: 150rpx;
  1679. padding: 24rpx 150rpx 24rpx 24rpx;
  1680. .img {
  1681. position: absolute;
  1682. left: 0;
  1683. top: 0;
  1684. width: 100%;
  1685. }
  1686. .note {
  1687. position: relative;
  1688. z-index: 10;
  1689. font-size: 24rpx;
  1690. font-family: PingFang SC;
  1691. font-weight: bold;
  1692. color: #efdbff;
  1693. }
  1694. .title {
  1695. position: relative;
  1696. z-index: 10;
  1697. font-size: 26rpx;
  1698. font-family: PingFang SC;
  1699. font-weight: bold;
  1700. color: #ffffff;
  1701. }
  1702. }
  1703. }
  1704. #top {
  1705. position: relative;
  1706. z-index: 99;
  1707. }
  1708. .polyv_detail {
  1709. display: flex;
  1710. flex-direction: column;
  1711. height: 100vh;
  1712. position: relative;
  1713. top: 0;
  1714. left: 0;
  1715. .pops {
  1716. position: absolute;
  1717. top: 0;
  1718. left: 0;
  1719. background: #ccc;
  1720. opacity: 0.5;
  1721. width: 100%;
  1722. height: 300rpx;
  1723. z-index: 9999;
  1724. }
  1725. .box {
  1726. flex: 1;
  1727. overflow: hidden;
  1728. margin: 16rpx 16rpx 100rpx 16rpx;
  1729. .box_in {
  1730. height: 100%;
  1731. }
  1732. }
  1733. .first_ml {
  1734. margin: 16rpx 16rpx 16rpx 16rpx;
  1735. }
  1736. }
  1737. .title {
  1738. font-size: 24rpx;
  1739. color: #999999;
  1740. }
  1741. page {
  1742. background: #eaeef1;
  1743. }
  1744. .ts {
  1745. font-size: 24rpx;
  1746. color: #999;
  1747. margin: 14rpx 0rpx;
  1748. padding-right: 29rpx;
  1749. padding-left: 34rpx;
  1750. }
  1751. .content {
  1752. padding: 24rpx;
  1753. text-align: left;
  1754. }
  1755. .sc_t {
  1756. font-size: 22rpx;
  1757. color: #000000;
  1758. }
  1759. .sc {
  1760. width: 29rpx;
  1761. height: 29rpx;
  1762. }
  1763. .buy {
  1764. width: 138rpx;
  1765. height: 48rpx;
  1766. line-height: 48rpx;
  1767. background: #32467b;
  1768. border-radius: 10rpx;
  1769. color: #ffffff;
  1770. font-size: 28rpx;
  1771. text-align: center;
  1772. vertical-align: middle;
  1773. position: absolute;
  1774. right: 30rpx;
  1775. }
  1776. .video_body {
  1777. padding-bottom: 96rpx;
  1778. }
  1779. .tj_box {
  1780. width: 50%;
  1781. display: inline-block;
  1782. text-align: center;
  1783. margin: 10rpx 0;
  1784. }
  1785. .t2 {
  1786. font-size: 24rpx;
  1787. font-family: PingFang SC;
  1788. color: #666666;
  1789. line-height: 36rpx;
  1790. margin: 15rpx;
  1791. }
  1792. .r_t2 {
  1793. width: 201rpx;
  1794. height: 49rpx;
  1795. background: rgba(22, 119, 255, 0.05);
  1796. border: 1rpx solid #32467b;
  1797. border-radius: 16rpx;
  1798. color: #666666;
  1799. font-size: 23rpx;
  1800. text-align: center;
  1801. display: flex;
  1802. align-items: center;
  1803. padding: 5rpx;
  1804. }
  1805. .scroll_box {
  1806. width: 100%;
  1807. height: 60rpx;
  1808. background: #ffffff;
  1809. box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(145, 156, 178, 0.1);
  1810. white-space: nowrap;
  1811. overflow: hidden;
  1812. margin: 15rpx 0;
  1813. }
  1814. .r_sliper {
  1815. padding: 0 20rpx;
  1816. }
  1817. .top_line {
  1818. width: 6rpx;
  1819. height: 22rpx;
  1820. background: #32467b;
  1821. margin-right: 10rpx;
  1822. }
  1823. .video_t2 {
  1824. font-size: 24rpx;
  1825. font-family: PingFang SC;
  1826. font-weight: 500;
  1827. color: #666666;
  1828. }
  1829. .video_play {
  1830. position: absolute;
  1831. width: 95rpx;
  1832. height: 95rpx;
  1833. top: 0;
  1834. left: 0;
  1835. right: 0;
  1836. bottom: 0;
  1837. margin: auto;
  1838. }
  1839. .video_box {
  1840. position: relative;
  1841. }
  1842. .slot-content {
  1843. padding: 0 20rpx;
  1844. }
  1845. .notice_modal {
  1846. .content {
  1847. width: 100%;
  1848. height: 100%;
  1849. padding: 56rpx 56rpx 56rpx 64rpx;
  1850. .title {
  1851. color: #222;
  1852. line-height: 40rpx;
  1853. font-size: 36rpx;
  1854. text-align: center;
  1855. font-weight: bold;
  1856. margin-bottom: 24rpx;
  1857. }
  1858. .text {
  1859. height: 340rpx;
  1860. line-height: 40rpx;
  1861. text-indent: 2em;
  1862. font-size: 32rpx;
  1863. color: #222;
  1864. }
  1865. .had_read {
  1866. width: 100%;
  1867. height: 88rpx;
  1868. line-height: 88rpx;
  1869. text-align: center;
  1870. background: #3577e8;
  1871. border-radius: 240rpx;
  1872. font-size: 32rpx;
  1873. font-weight: 500;
  1874. color: #fff;
  1875. margin-top: 20rpx;
  1876. &.gray {
  1877. background: #bbbec5;
  1878. }
  1879. }
  1880. }
  1881. }
  1882. </style>