detail.vue 55 KB

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