detail.vue 61 KB

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