detail.vue 52 KB

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