detail.vue 61 KB

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