detail.vue 49 KB

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