detail.vue 51 KB

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