detail.vue 55 KB

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