detail.vue 50 KB

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