detail.vue 54 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935
  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.isPlaying) {
  490. this.postStudyRecord();
  491. }
  492. this.refPlv = null;
  493. uni.$off();
  494. this.clearPauseTimer();
  495. uni.removeInterceptor("navigateTo");
  496. if (this.lockTimer) {
  497. clearInterval(this.lockTimer);
  498. this.$api.lockDelLock({
  499. action: "jxjy",
  500. uuid: this.$method.getUuid(),
  501. });
  502. }
  503. },
  504. onHide() {
  505. this.beforeHideIsPlaying = this.isPlaying;
  506. if (this.isPlaying) {
  507. this.refPlv.playPause();
  508. }
  509. },
  510. mounted() {},
  511. methods: {
  512. ...mapMutations(["updateChapterOpen", "updateLiveLast"]),
  513. async init() {
  514. // #ifdef MP-WEIXIN
  515. this.isAllowSeek = "no";
  516. // #endif
  517. // #ifdef H5
  518. this.isAllowSeek = "on";
  519. // #endif
  520. this.photoList = [];
  521. this.courseList = [];
  522. this.photoConfig = false;
  523. await this.isCanLearn();
  524. this.courseCourseList();
  525. },
  526. // 七大员是否能进入学习
  527. async qCheckIsCanLearn() {
  528. let res = await this.$api.qCheckIsCanLearn(this.orderGoodsId);
  529. if (res.data.code !== 200) {
  530. uni.showModal({
  531. showCancel: false,
  532. title: "提示",
  533. content: res.data.msg,
  534. success: (resultst) => {
  535. uni.navigateBack();
  536. },
  537. });
  538. return Promise.reject();
  539. }
  540. let res1 = await this.$api.syncSevenPublicClass({
  541. orderGoodsId: this.orderGoodsId,
  542. });
  543. if (res1.data.code !== 200) {
  544. uni.showModal({
  545. showCancel: false,
  546. title: "提示",
  547. content: "无法进入学习!",
  548. success: (resultst) => {
  549. uni.navigateBack();
  550. },
  551. });
  552. return Promise.reject();
  553. }
  554. },
  555. // 新增微信公众号模板消息点击数据
  556. clickOfficial(informId) {
  557. this.$http({
  558. url: "/data/click",
  559. method: "post",
  560. data: { informId },
  561. });
  562. },
  563. // 点击课程目录
  564. cMenu(item, index) {
  565. this.subIndex = index;
  566. this.newActiveSubjectId = item.subjectId;
  567. },
  568. courseCourseList() {
  569. this.$api
  570. .courseCourseList({
  571. pageNum: 1,
  572. pageSize: 200,
  573. ...this.params(["goodsId", "orderGoodsId", "gradeId"]),
  574. })
  575. .then((res) => {
  576. if (res.data.code == 200) {
  577. this.courseList = res.data.rows;
  578. if (res.data.total > 1) {
  579. // 科目
  580. this.subList = [{ subjectId: 0, subjectName: "所有" }];
  581. this.courseList.forEach((item) => {
  582. if (!this.subList.find((e) => e.subjectId == item.subjectId)) {
  583. this.subList.push(item);
  584. }
  585. });
  586. this.getUserWatchLast();
  587. } else {
  588. this.originOnShow();
  589. this.originMounted();
  590. }
  591. }
  592. });
  593. },
  594. // 查询用户最后一次看的录播的信息
  595. getUserWatchLast() {
  596. this.$http({
  597. url: "/study/record/getUserWatchLast",
  598. method: "get",
  599. data: {
  600. orderGoodsId: this.orderGoodsId,
  601. },
  602. }).then((res) => {
  603. if (res.data.code == 200 && res.data.data) {
  604. this.courseId = res.data.data.courseId;
  605. }
  606. if (!this.courseId) {
  607. this.courseId = this.courseList[0].courseId;
  608. }
  609. this.originOnShow();
  610. this.originMounted();
  611. //获取商品双师资模板
  612. this.getCourseTeacher(this.courseList);
  613. });
  614. },
  615. getCourseTeacher(rows) {
  616. this.goodsTeacher = [];
  617. //获取商品双师资模板
  618. this.$api
  619. .courseTeacherList({
  620. goodsId: this.goodsId,
  621. })
  622. .then((res1) => {
  623. if (res1.data.data && res1.data.data.length > 0) {
  624. //课程老师模板
  625. let teacherTel = res1.data.data;
  626. //商品课程
  627. let courses = rows;
  628. teacherTel.forEach((tea) => {
  629. let dataList = [];
  630. let teacherList = [];
  631. courses.forEach((item) => {
  632. let data = tea.courseList.filter(
  633. (x) => x.courseId == item.courseId
  634. );
  635. if (data && data.length > 0) {
  636. dataList.push(item);
  637. teacherList = tea.courseList;
  638. }
  639. });
  640. let result = {
  641. teaList: teacherList,
  642. courseList: dataList,
  643. };
  644. this.goodsTeacher.push(result);
  645. });
  646. if (this.goodsTeacher && this.goodsTeacher.length > 0) {
  647. let courseIds = [];
  648. this.goodsTeacher.forEach((item) => {
  649. item.courseList.forEach((course) => {
  650. courseIds.push(course.courseId);
  651. });
  652. });
  653. if (courseIds.length > 0) {
  654. courses.forEach((item) => {
  655. if (!courseIds.includes(item.courseId)) {
  656. let data = {
  657. teaList: [],
  658. courseList: [],
  659. };
  660. data.courseList.push(item);
  661. this.goodsTeacher.push(data);
  662. }
  663. });
  664. }
  665. this.goodsTeacher.forEach((item) => {
  666. if (item.courseList && item.courseList.length > 0) {
  667. item.courseList[0].show = 1;
  668. }
  669. });
  670. }
  671. } else {
  672. //没有双师资模板
  673. rows.forEach((item) => {
  674. item.show = 1;
  675. let data = {
  676. teaList: [],
  677. courseList: [],
  678. };
  679. data.courseList.push(item);
  680. this.goodsTeacher.push(data);
  681. });
  682. }
  683. this.goodsTeacher.forEach((item) => {
  684. if (item.courseList.some((x) => x.courseId == this.courseId)) {
  685. this.teacherList = item.teaList;
  686. }
  687. });
  688. });
  689. },
  690. erJianErZaoPauseTip() {
  691. if (this.playSecIsLearn && this.erJianErZao && !this.isLeave) {
  692. if (this.pauseTimer) {
  693. return;
  694. }
  695. this.pauseTime = Date.now();
  696. this.pauseTimer = setInterval(() => {
  697. console.log("暂停时间", Date.now() - this.pauseTime, this.pauseTime);
  698. if (Date.now() - this.pauseTime > 20 * 1000) {
  699. // 5 * 60 * 1000
  700. this.refPlv.exitFullScreen();
  701. this.text = "暂停";
  702. if (this.showCamera) {
  703. this.text = "拍照停留";
  704. this.closeCamera();
  705. }
  706. uni.showModal({
  707. title: "提示",
  708. showCancel: false,
  709. content: `检测${this.text}时间过长,刷新当前页面`,
  710. cancelText: "取消",
  711. confirmText: "确定",
  712. success: (res) => {
  713. this.text = "";
  714. reload(this.option);
  715. // #ifdef MP-WEIXIN
  716. this.sectionItem = {};
  717. // #endif
  718. },
  719. });
  720. this.clearPauseTimer();
  721. }
  722. }, 5000);
  723. }
  724. },
  725. // 原来onshow里面的内容
  726. async originOnShow() {
  727. await this.studyRecordMenuAllList();
  728. // 消息过来 定位某个节
  729. if (this.option.noteSecond) {
  730. this.jumpNote({
  731. sectionType: 1,
  732. ...this.option,
  733. });
  734. return;
  735. }
  736. this.studyRecordQueryLiveLast();
  737. },
  738. // 原来的mouted内容
  739. originMounted() {
  740. uni.$on(
  741. "getSection",
  742. debounce((item) => {
  743. if (!this.refPlv && this.playVid) {
  744. this.refPlv = this.$refs.player;
  745. }
  746. if (this.isPlaying) {
  747. this.refPlv.playPause();
  748. }
  749. this.postStudyRecord(0);
  750. this.photoConfig = false;
  751. this.photoList = [];
  752. this.moduleId = item.moduleId || null;
  753. this.chapterId = item.chapterId || null;
  754. this.playVideo(item);
  755. })
  756. );
  757. uni.$on("isRebuild", (item) => {
  758. this.isRebuild = item;
  759. });
  760. this.updateChapterOpen(true);
  761. },
  762. clearPauseTimer() {
  763. if (this.pauseTimer) {
  764. this.pauseTime = 0;
  765. clearInterval(this.pauseTimer);
  766. this.pauseTimer = null;
  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.switchTab({
  829. url: "/pages/learn/index",
  830. });
  831. },
  832. toBack(delta = 1) {
  833. uni.navigateBack({
  834. delta,
  835. });
  836. },
  837. markConfirm() {
  838. uni.setClipboardData({
  839. data: this.markContent,
  840. success: () => {
  841. setTimeout(this.toBack, 1000);
  842. },
  843. });
  844. },
  845. noticeConfirm() {
  846. if (this.CountTo <= 0) {
  847. this.noticeShow = false;
  848. if (this.autoplay) {
  849. this.refPlv && this.refPlv.resumeVideo();
  850. }
  851. this.$api.baseHandoutTip({
  852. orderGoodsId: this.orderGoodsId,
  853. });
  854. }
  855. },
  856. baseHandoutTipList() {
  857. this.$api
  858. .baseHandoutTipList({
  859. orderGoodsId: this.orderGoodsId,
  860. })
  861. .then((res) => {
  862. if (res.data.rows.length == 0) {
  863. this.noticeShow = true;
  864. this.CountTo = 30;
  865. var timer = setInterval(() => {
  866. this.CountTo--;
  867. if (this.CountTo < 0) {
  868. clearInterval(timer);
  869. }
  870. }, 1000);
  871. }
  872. });
  873. },
  874. /**
  875. * 获取上次观看的直播
  876. */
  877. studyRecordGetLastLive() {
  878. this.$api
  879. .studyRecordGetLastLive({
  880. orderGoodsId: this.orderGoodsId,
  881. courseId: this.courseId,
  882. })
  883. .then((res) => {
  884. this.updateLiveLast(res.data.data);
  885. });
  886. },
  887. async initPlayVideo(sectionItem) {
  888. this.moduleId = sectionItem.moduleId;
  889. this.chapterId = sectionItem.chapterId;
  890. this.sectionItem = sectionItem;
  891. if (sectionItem.sectionType == 1) {
  892. //录播
  893. this.playVideo(sectionItem);
  894. } else if (sectionItem.sectionType == 2) {
  895. //直播
  896. this.studyRecordGetLastLive();
  897. } else if (sectionItem.sectionType == 3) {
  898. //回放
  899. this.playVideo(sectionItem);
  900. } else if (sectionItem.doType == 2) {
  901. uni.showModal({
  902. title: "温馨提示",
  903. content: "当前节视频已学完,是否进入考试?",
  904. success: (res) => {
  905. if (res.confirm) {
  906. this.toQuestionBank(sectionItem);
  907. }
  908. },
  909. });
  910. return;
  911. }
  912. },
  913. async submitPhoto(url, compareFaceData) {
  914. this.ossAvatarUrl = url;
  915. this.compareFaceData = compareFaceData;
  916. this.postCoursePhotoRecord()
  917. .then(async (res) => {
  918. this.photoHistoryList[this.photoIndex] = true;
  919. await this.postStudyRecord();
  920. if (this.erJianErZao && this.isReach) {
  921. await this.postStudyRecord(1);
  922. this.closeCamera();
  923. this.nextSection();
  924. return;
  925. }
  926. this.closeCamera();
  927. this.refPlv.resumeVideo();
  928. })
  929. .catch((err) => {
  930. uni.showToast({
  931. title: "上传接口报错,请重新拍照上传" + err,
  932. icon: "none",
  933. });
  934. this.$refs["camera"].reTake();
  935. });
  936. },
  937. toQuestionBank(sectionItem) {
  938. // type 1模块 2章 3节 4章卷 5模块卷
  939. uni.navigateTo({
  940. url:
  941. "/pages2/class/questionBank?courseId=" +
  942. this.courseId +
  943. "&gradeId=" +
  944. this.gradeId +
  945. "&isFromVideo=1&id=" +
  946. sectionItem.id +
  947. "&goodsid=" +
  948. this.goodsId +
  949. "&moduleId=" +
  950. (sectionItem.moduleId || 0) +
  951. "&chapterId=" +
  952. (sectionItem.chapterId || 0) +
  953. "&orderGoodsId=" +
  954. this.orderGoodsId +
  955. "&type=" +
  956. (sectionItem.type == 4 ? 1 : 3) +
  957. "&learning=" +
  958. sectionItem.studyStatus +
  959. "&isBackVideo=" +
  960. 1,
  961. });
  962. },
  963. studyRecordQueryLiveLast() {
  964. this.$api
  965. .studyRecordQueryLiveLast({
  966. gradeId: this.gradeId,
  967. orderGoodsId: this.orderGoodsId,
  968. courseId: this.courseId,
  969. })
  970. .then((res) => {
  971. let { data } = res.data;
  972. if (!data.sectionId) {
  973. data = this.menuAllList[0];
  974. }
  975. if (data.learning == 1 && this.orderNum == 2) {
  976. let next = this.menuAllList.find((e) => e.studyStatus != 1);
  977. next && (data = next);
  978. }
  979. this.initPlayVideo(data);
  980. });
  981. },
  982. goLive(item) {
  983. let moduleId = item.moduleId || 0;
  984. let chapterId = item.chapterId || 0;
  985. let sectionId = item.sectionId || item.menuId;
  986. let uuid = new Date().valueOf() + "";
  987. // buyCourse 是否购买课程:1是 0否
  988. let encode = encodeURIComponent(
  989. this.config.hostLive +
  990. "/pages/live/index?token=" +
  991. uni.getStorageSync("token") +
  992. "&userInfo=" +
  993. JSON.stringify(this.userInfo) +
  994. "&channelId=" +
  995. item.liveUrl +
  996. "&gradeId=" +
  997. this.gradeId +
  998. "&courseId=" +
  999. this.courseId +
  1000. "&goodsId=" +
  1001. this.goodsId +
  1002. "&orderGoodsId=" +
  1003. this.orderGoodsId +
  1004. "&sectionId=" +
  1005. sectionId +
  1006. "&chapterId=" +
  1007. chapterId +
  1008. "&moduleId=" +
  1009. moduleId +
  1010. "&buyCourse=1" +
  1011. "&ident=" +
  1012. uuid
  1013. );
  1014. uni.navigateTo({
  1015. url: `../../pages/webview/index?url=` + encode,
  1016. });
  1017. },
  1018. studyRecordMenuAllList() {
  1019. // study/record/menuAllList
  1020. return this.$api
  1021. .studMenuAllList({
  1022. courseId: this.courseId,
  1023. ...this.params(["goodsId", "orderGoodsId", "gradeId"]),
  1024. })
  1025. .then((res) => {
  1026. let nowTime = Number(new Date().getTime() / 1000).toFixed(0);
  1027. if (res.data.data) {
  1028. this.menuAllList = res.data.data.filter(
  1029. (e) => e.doType != 1 || (e.doType == 2 && e.studyStatus == 1)
  1030. );
  1031. this.livingItem = res.data.data.find(
  1032. (item) =>
  1033. item.liveStartTime <= nowTime && item.liveEndTime > nowTime
  1034. );
  1035. }
  1036. return Promise.resolve();
  1037. });
  1038. },
  1039. async getbaseprofiletplists() {
  1040. let {
  1041. data: { code, rows },
  1042. } = await this.$api.getbaseprofiletplists({
  1043. goodsId: this.goodsId,
  1044. orderGoodsId: this.orderGoodsId,
  1045. });
  1046. if (code === 200 && rows.length && rows[0].keyValue) {
  1047. let baseRes = await this.$api.getbaseprofiletpId(this.goodsId);
  1048. if (baseRes.data.code === 200 && baseRes.data.data) {
  1049. let {
  1050. data: { code, data },
  1051. } = await this.$api.getbaseprofiletpgetInfo({
  1052. goodsId: this.goodsId,
  1053. orderGoodsId: this.orderGoodsId,
  1054. });
  1055. if (
  1056. code === 200 &&
  1057. (!data || (data.status === 3 && data.changeStatus === 1))
  1058. ) {
  1059. uni.showModal({
  1060. content: !data
  1061. ? "请前往填写资料"
  1062. : "资料审核不通过,请前往重新填写",
  1063. cancelText: "返回",
  1064. success: (resultst) => {
  1065. if (resultst.confirm) {
  1066. this.$navTo.togo("/pages2/verify/input", {
  1067. id: this.goodsId,
  1068. orderGoodsId: this.orderGoodsId,
  1069. });
  1070. }
  1071. if (resultst.cancel) {
  1072. uni.navigateBack();
  1073. }
  1074. },
  1075. });
  1076. return Promise.reject();
  1077. } else if (data.status === 1 && JSON.parse(rows[0].keyValue2)[0]) {
  1078. let {
  1079. data: { code, data },
  1080. } = await this.$api.getbaseprofileStampgetInfo({
  1081. goodsId: this.goodsId,
  1082. orderGoodsId: this.orderGoodsId,
  1083. });
  1084. if (
  1085. code === 200 &&
  1086. (!data || (data.status === 3 && data.changeStatus === 1))
  1087. ) {
  1088. uni.showModal({
  1089. content: !data
  1090. ? "请前往填写盖章资料"
  1091. : "资料盖章审核不通过,请前往重新填写",
  1092. cancelText: "返回",
  1093. success: (resultst) => {
  1094. if (resultst.confirm) {
  1095. this.$navTo.togo("/pages2/verify/input2", {
  1096. id: this.goodsId,
  1097. orderGoodsId: this.orderGoodsId,
  1098. });
  1099. }
  1100. if (resultst.cancel) {
  1101. uni.navigateBack();
  1102. }
  1103. },
  1104. });
  1105. return Promise.reject();
  1106. }
  1107. }
  1108. }
  1109. }
  1110. return Promise.resolve();
  1111. },
  1112. async isCanLearn() {
  1113. this.option.isQ !== "" && (await this.qCheckIsCanLearn());
  1114. await this.getbaseprofiletplists();
  1115. await this.getGradeInfo();
  1116. await this.getGoodsDetail();
  1117. },
  1118. /**
  1119. * 计算tabs宽度
  1120. */
  1121. itemWidth() {
  1122. return 100 / this.list.length + "%";
  1123. },
  1124. loadedmetadata(event) {
  1125. this.refPlv = this.$refs.player;
  1126. },
  1127. getPhotoLastRecord() {
  1128. let { chapterId, sectionId, moduleId } = this.sectionItem;
  1129. let data = {
  1130. ...this.params(),
  1131. sectionId: sectionId || 0,
  1132. gradeId: this.gradeId,
  1133. chapterId: chapterId || 0,
  1134. moduleId: moduleId || 0,
  1135. };
  1136. this.$api.getPhotoLastRecord(data).then((res) => {
  1137. if (res.data.code == 200) {
  1138. //清空历史数据
  1139. this.photoHistoryList = [];
  1140. this.photoList = [];
  1141. for (let i = 0; i < res.data.data.length; i++) {
  1142. //-2存储随机拍照数组
  1143. if (res.data.data[i].photoIndex == -2) {
  1144. this.photoList =
  1145. res.data.data[i].timeInterval &&
  1146. res.data.data[i].timeInterval.split(",");
  1147. } else {
  1148. this.photoHistoryList.push(res.data.data[i].photoIndex);
  1149. }
  1150. }
  1151. }
  1152. });
  1153. },
  1154. //postTime 只提交随机时间
  1155. postCoursePhotoRecord(postTime = false) {
  1156. return new Promise((resolve, reject) => {
  1157. let data = {
  1158. ...this.params(["orderGoodsId", "goodsId", "courseId", "gradeId"]),
  1159. photo: this.ossAvatarUrl,
  1160. sectionId: this.sectionId,
  1161. photoTime: this.playTime || 0,
  1162. photoIndex: postTime ? -2 : this.photoIndex, //从0算起,-2只提交随机时间
  1163. photoNum: this.photoNum,
  1164. chapterId: this.chapterId,
  1165. moduleId: this.moduleId,
  1166. timeInterval: postTime ? this.photoList.join(",") : "",
  1167. };
  1168. this.$api
  1169. .coursePhotoRecord(data)
  1170. .then((res) => {
  1171. if (res.data.code == 200) {
  1172. resolve();
  1173. } else {
  1174. reject();
  1175. }
  1176. })
  1177. .catch((err) => {
  1178. reject();
  1179. });
  1180. });
  1181. },
  1182. randomNum(minNum, maxNum) {
  1183. switch (arguments.length) {
  1184. case 1:
  1185. return parseInt(Math.random() * minNum + 1, 10);
  1186. break;
  1187. case 2:
  1188. return parseInt(Math.random() * (maxNum - minNum + 1) + minNum, 10);
  1189. break;
  1190. default:
  1191. return 0;
  1192. break;
  1193. }
  1194. },
  1195. //配置随机拍照时间
  1196. configPhoto(duration) {
  1197. if ((this.photoConfig && this.photoList.length) || !this.isPlaying) {
  1198. return;
  1199. }
  1200. let totalVideoTime = this.refPlv.getDuration();
  1201. this.photoConfig = true;
  1202. if (this.erJianErZao) {
  1203. this.photoList = this.randomConfig(totalVideoTime, duration);
  1204. console.log(this.isPlaying, this.photoList, "this.photoList");
  1205. return;
  1206. }
  1207. //没有历史拍照间隔数据
  1208. if (!this.photoList || this.photoList.length == 0) {
  1209. // 46 * 60
  1210. this.photoList = this.commonConfig(
  1211. totalVideoTime,
  1212. this.jjShiGongYuan ? 10 : undefined
  1213. );
  1214. this.postCoursePhotoRecord(true); //提交随机拍照时间数组
  1215. }
  1216. console.log(this.photoList, "this.photoList");
  1217. },
  1218. // 二建随机拍摄时间
  1219. randomConfig(totalVideoTime, duration) {
  1220. this.photoHistoryList = [];
  1221. let photoList = [duration];
  1222. let pre = duration;
  1223. if (totalVideoTime > 300) {
  1224. while (pre <= totalVideoTime) {
  1225. pre += this.randomNum(780, 900);
  1226. pre <= totalVideoTime && photoList.push(pre);
  1227. }
  1228. if (totalVideoTime - 300 > photoList.slice(-1)[0]) {
  1229. photoList.push(this.randomNum(totalVideoTime - 180, totalVideoTime));
  1230. }
  1231. }
  1232. return photoList;
  1233. },
  1234. // 随机前后五分钟
  1235. commonConfig(totalVideoTime, fixS) {
  1236. let photoList = [0];
  1237. // 固定间隔时间取
  1238. if (fixS) {
  1239. let num = Math.ceil(totalVideoTime / fixS);
  1240. for (let i = 1; i < num; i++) {
  1241. photoList.push(i * fixS);
  1242. }
  1243. this.photoNum = num;
  1244. } else {
  1245. if (this.photoNum == 3) {
  1246. if (totalVideoTime >= 900) {
  1247. //大于15分钟
  1248. let centerTime = Math.floor(totalVideoTime / 2); //获取中间时间
  1249. let centerMinTime = centerTime - 300; //前后5分钟
  1250. let centerMaxTime = centerTime + 300;
  1251. let centerTakeTime = this.randomNum(centerMinTime, centerMaxTime);
  1252. photoList.push(centerTakeTime); //中间拍一张
  1253. let endMaxTime = totalVideoTime - 60;
  1254. let endMinTime = totalVideoTime - 300;
  1255. let endTakeTime = this.randomNum(endMinTime, endMaxTime);
  1256. photoList.push(endTakeTime); //最后拍一张
  1257. } else {
  1258. //小于15分钟
  1259. let centerTime = this.randomNum(
  1260. (1 / 3) * totalVideoTime,
  1261. (2 / 3) * totalVideoTime
  1262. );
  1263. photoList.push(centerTime);
  1264. let endTakeTime = this.randomNum(
  1265. (2 / 3) * totalVideoTime,
  1266. totalVideoTime
  1267. );
  1268. photoList.push(endTakeTime);
  1269. }
  1270. }
  1271. }
  1272. return photoList;
  1273. },
  1274. studyNotice() {
  1275. this.noticeShow = true;
  1276. },
  1277. //正常播放视频
  1278. async playVideo(item) {
  1279. this.sectionItem = item;
  1280. let { learning, videoCurrentTime, recordingUrl } = item;
  1281. this.videoCurrentTime =
  1282. videoCurrentTime || (await this.getRecordLast(item));
  1283. // 往前播3秒
  1284. if (this.videoCurrentTime > 3) {
  1285. this.videoCurrentTime -= 3;
  1286. }
  1287. // 查找拍照历史
  1288. if ((this.photoNum > 0 || this.jjShiGongYuan) && learning != 1) {
  1289. await this.getPhotoLastRecord();
  1290. }
  1291. if (this.refPlv) {
  1292. this.refPlv.changeVid({
  1293. vid: recordingUrl,
  1294. videoCurrentTime: this.videoCurrentTime,
  1295. });
  1296. }
  1297. },
  1298. getRecordLast(sectionItem) {
  1299. let { chapterId, sectionId, courseId, moduleId } = sectionItem;
  1300. return new Promise((resolve) => {
  1301. let data = {
  1302. ...this.params(),
  1303. gradeId:
  1304. this.gradeId || this.gradeId == 0 ? Number(this.gradeId) : null,
  1305. sectionId: sectionId || 0,
  1306. chapterId: chapterId || 0,
  1307. moduleId: moduleId || 0,
  1308. };
  1309. this.$api.recordLast(data).then((res) => {
  1310. resolve(res.data.data.videoCurrentTime);
  1311. });
  1312. });
  1313. },
  1314. jumpNote(item) {
  1315. this.$u.toast("即将跳到笔记位置");
  1316. if (this.sectionId != item.sectionId) {
  1317. this.initPlayVideo({
  1318. sectionType: 1,
  1319. ...item,
  1320. videoCurrentTime: Number(item.noteSecond),
  1321. });
  1322. } else {
  1323. this.refPlv.seekVideo(item.noteSecond);
  1324. }
  1325. },
  1326. getGradeInfo() {
  1327. // 即刻 1 待定2 日期3
  1328. return this.$api.goodsGradeInfo(this.gradeId).then((res) => {
  1329. if (res.data.code == 200) {
  1330. let { data } = res.data;
  1331. if (
  1332. data.learningStatus == 2 ||
  1333. (data.learningStatus == 3 &&
  1334. Number(data.learningTimeStart) > Number(new Date() / 1000))
  1335. ) {
  1336. uni.showModal({
  1337. showCancel: false,
  1338. confirmText: "确定",
  1339. content:
  1340. "当前课程正在申请中,正式开班后方可进行学习,请耐心等候!",
  1341. success: function (resultst) {
  1342. uni.navigateBack();
  1343. },
  1344. });
  1345. return Promise.reject();
  1346. }
  1347. }
  1348. });
  1349. },
  1350. postStudyRecord(status = 0, sectionId = this.sectionId) {
  1351. if (!this.refPlv && this.playVid) {
  1352. return;
  1353. }
  1354. let currentTime = this.refPlv.playCurrentTime();
  1355. let PlayDuration = this.refPlv.playVideoTime();
  1356. if (currentTime < 10 && !this.ossAvatarUrl) {
  1357. console.log("不提交", currentTime);
  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("播放");
  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. async userConfirmInfoDetail() {
  1595. let info = await this.$api.userConfirmInfoDetail({
  1596. orderGoodsId: this.orderGoodsId,
  1597. });
  1598. if (!info.data.data || info.data.data.pushInfo !== 1) {
  1599. uni.showModal({
  1600. showCancel: false,
  1601. title: "提示",
  1602. content: "开通信息推送不成功,无法进入学习!",
  1603. success: (resultst) => {
  1604. uni.navigateBack();
  1605. },
  1606. });
  1607. return Promise.reject();
  1608. }
  1609. },
  1610. checkFinishRequiredCourse() {
  1611. return this.$api
  1612. .checkFinishRequiredCourse({
  1613. businessId: this.goodsData.businessId,
  1614. goodsId: this.goodsId,
  1615. })
  1616. .then((res) => {
  1617. if (res.data.data > 0) {
  1618. uni.showModal({
  1619. showCancel: false,
  1620. confirmText: "确定",
  1621. content: "该业务层次下有未学完的商品,无法学习新商品!",
  1622. success: function (resultst) {
  1623. uni.navigateBack();
  1624. },
  1625. });
  1626. return Promise.reject();
  1627. }
  1628. return Promise.resolve();
  1629. });
  1630. },
  1631. async getGoodsDetail() {
  1632. let { data } = await this.$api.goodsDetail(this.goodsId);
  1633. this.goodsData = data.data;
  1634. this.erJianErZao = this.goodsData.erJianErZao;
  1635. this.jjShiGongYuan = this.goodsData.jjShiGongYuan;
  1636. if (this.erJianErZao || this.jjShiGongYuan) {
  1637. await this.userConfirmInfoDetail();
  1638. }
  1639. this.option.periodWaitTime && (await this.checkFinishRequiredCourse());
  1640. this.goodsData.buyNote && this.baseHandoutTipList();
  1641. !this.gradeId && (this.gradeId = this.goodsData.gradeId);
  1642. if (this.goodsData.goodsPlayConfig) {
  1643. this.goodsPlayConfig = JSON.parse(this.goodsData.goodsPlayConfig);
  1644. if (this.goodsPlayConfig.autoPlay > 0) {
  1645. this.autoplay = true;
  1646. }
  1647. if (this.goodsPlayConfig.drag > 0 && !this.erJianErZao) {
  1648. // #ifdef MP-WEIXIN
  1649. this.isAllowSeek = "yes";
  1650. // #endif
  1651. // #ifdef H5
  1652. this.isAllowSeek = "off";
  1653. // #endif
  1654. }
  1655. if (this.goodsPlayConfig.speed > 0) {
  1656. this.playbackRate = [0.5, 0.8, 1.0, 1.25, 1.5, 2.0];
  1657. }
  1658. }
  1659. if (this.goodsData.goodsPhotographConfig) {
  1660. this.goodsPhotographConfig = JSON.parse(
  1661. this.goodsData.goodsPhotographConfig
  1662. );
  1663. if (this.goodsPhotographConfig.photoNum > 0) {
  1664. this.photoNum = this.goodsPhotographConfig.photoNum;
  1665. }
  1666. }
  1667. },
  1668. change(index) {
  1669. this.current = index;
  1670. },
  1671. paramsFn(
  1672. keys = ["orderGoodsId", "goodsId", "courseId", "gradeId", "sectionItem"]
  1673. ) {
  1674. return this.params(keys);
  1675. },
  1676. },
  1677. provide() {
  1678. return {
  1679. paramsFn: this.paramsFn,
  1680. };
  1681. },
  1682. };
  1683. </script>
  1684. <style lang="scss" scope>
  1685. @import "./css/detail.scss";
  1686. .top {
  1687. &__header {
  1688. position: relative;
  1689. width: 100%;
  1690. height: 150rpx;
  1691. padding: 24rpx 150rpx 24rpx 24rpx;
  1692. .img {
  1693. position: absolute;
  1694. left: 0;
  1695. top: 0;
  1696. width: 100%;
  1697. }
  1698. .note {
  1699. position: relative;
  1700. z-index: 10;
  1701. font-size: 24rpx;
  1702. font-family: PingFang SC;
  1703. font-weight: bold;
  1704. color: #efdbff;
  1705. }
  1706. .title {
  1707. position: relative;
  1708. z-index: 10;
  1709. font-size: 26rpx;
  1710. font-family: PingFang SC;
  1711. font-weight: bold;
  1712. color: #ffffff;
  1713. }
  1714. }
  1715. }
  1716. #top {
  1717. position: relative;
  1718. z-index: 99;
  1719. }
  1720. .polyv_detail {
  1721. display: flex;
  1722. flex-direction: column;
  1723. height: 100vh;
  1724. position: relative;
  1725. top: 0;
  1726. left: 0;
  1727. .pops {
  1728. position: absolute;
  1729. top: 0;
  1730. left: 0;
  1731. background: #ccc;
  1732. opacity: 0.5;
  1733. width: 100%;
  1734. height: 300rpx;
  1735. z-index: 9999;
  1736. }
  1737. .box {
  1738. flex: 1;
  1739. overflow: hidden;
  1740. margin: 16rpx 16rpx 100rpx 16rpx;
  1741. .box_in {
  1742. height: 100%;
  1743. }
  1744. }
  1745. .first_ml {
  1746. margin: 16rpx 16rpx 16rpx 16rpx;
  1747. }
  1748. }
  1749. .title {
  1750. font-size: 24rpx;
  1751. color: #999999;
  1752. }
  1753. page {
  1754. background: #eaeef1;
  1755. }
  1756. .ts {
  1757. font-size: 24rpx;
  1758. color: #999;
  1759. margin: 14rpx 0rpx;
  1760. padding-right: 29rpx;
  1761. padding-left: 34rpx;
  1762. }
  1763. .content {
  1764. padding: 24rpx;
  1765. text-align: left;
  1766. }
  1767. .sc_t {
  1768. font-size: 22rpx;
  1769. color: #000000;
  1770. }
  1771. .sc {
  1772. width: 29rpx;
  1773. height: 29rpx;
  1774. }
  1775. .buy {
  1776. width: 138rpx;
  1777. height: 48rpx;
  1778. line-height: 48rpx;
  1779. background: #32467b;
  1780. border-radius: 10rpx;
  1781. color: #ffffff;
  1782. font-size: 28rpx;
  1783. text-align: center;
  1784. vertical-align: middle;
  1785. position: absolute;
  1786. right: 30rpx;
  1787. }
  1788. .video_body {
  1789. padding-bottom: 96rpx;
  1790. }
  1791. .tj_box {
  1792. width: 50%;
  1793. display: inline-block;
  1794. text-align: center;
  1795. margin: 10rpx 0;
  1796. }
  1797. .t2 {
  1798. font-size: 24rpx;
  1799. font-family: PingFang SC;
  1800. color: #666666;
  1801. line-height: 36rpx;
  1802. margin: 15rpx;
  1803. }
  1804. .r_t2 {
  1805. width: 201rpx;
  1806. height: 49rpx;
  1807. background: rgba(22, 119, 255, 0.05);
  1808. border: 1rpx solid #32467b;
  1809. border-radius: 16rpx;
  1810. color: #666666;
  1811. font-size: 23rpx;
  1812. text-align: center;
  1813. display: flex;
  1814. align-items: center;
  1815. padding: 5rpx;
  1816. }
  1817. .scroll_box {
  1818. width: 100%;
  1819. height: 60rpx;
  1820. background: #ffffff;
  1821. box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(145, 156, 178, 0.1);
  1822. white-space: nowrap;
  1823. overflow: hidden;
  1824. margin: 15rpx 0;
  1825. }
  1826. .r_sliper {
  1827. padding: 0 20rpx;
  1828. }
  1829. .top_line {
  1830. width: 6rpx;
  1831. height: 22rpx;
  1832. background: #32467b;
  1833. margin-right: 10rpx;
  1834. }
  1835. .video_t2 {
  1836. font-size: 24rpx;
  1837. font-family: PingFang SC;
  1838. font-weight: 500;
  1839. color: #666666;
  1840. }
  1841. .video_play {
  1842. position: absolute;
  1843. width: 95rpx;
  1844. height: 95rpx;
  1845. top: 0;
  1846. left: 0;
  1847. right: 0;
  1848. bottom: 0;
  1849. margin: auto;
  1850. }
  1851. .video_box {
  1852. position: relative;
  1853. }
  1854. .slot-content {
  1855. padding: 0 20rpx;
  1856. }
  1857. .notice_modal {
  1858. .content {
  1859. width: 100%;
  1860. height: 100%;
  1861. padding: 56rpx 56rpx 56rpx 64rpx;
  1862. .title {
  1863. color: #222;
  1864. line-height: 40rpx;
  1865. font-size: 36rpx;
  1866. text-align: center;
  1867. font-weight: bold;
  1868. margin-bottom: 24rpx;
  1869. }
  1870. .text {
  1871. height: 340rpx;
  1872. line-height: 40rpx;
  1873. text-indent: 2em;
  1874. font-size: 32rpx;
  1875. color: #222;
  1876. }
  1877. .had_read {
  1878. width: 100%;
  1879. height: 88rpx;
  1880. line-height: 88rpx;
  1881. text-align: center;
  1882. background: #3577e8;
  1883. border-radius: 240rpx;
  1884. font-size: 32rpx;
  1885. font-weight: 500;
  1886. color: #fff;
  1887. margin-top: 20rpx;
  1888. &.gray {
  1889. background: #bbbec5;
  1890. }
  1891. }
  1892. }
  1893. }
  1894. </style>