detail.vue 51 KB

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