detail.vue 53 KB

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