detail.vue 54 KB

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