detail.vue 55 KB

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