detail.vue 52 KB

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