123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349 |
- <template>
- <view class="polyv_detail">
- <uni-nav-bar v-if="isShowBar" left-icon="back" :statusBar="true" fixed="true"
- :title="detail.courseName || '课程详情'" @clickLeft="clickLeft"></uni-nav-bar>
- <view id="top">
- <uni-popup ref="popup" :mask-click="false" v-if="goodsData.reminderSign===1">
- <view style="background: #d6acac;
- color: #ff3535;
- padding: 10px;"><text>禁止倍速或拖拽观看,否则学习无效</text>
- <icon type="cancel" style="float: right;color:#ff3535;" @click="closepopup" size="26" />
- </view>
- </uni-popup>
- <view class="video_box" v-if="!playVid||hideplayer">
- <image :src="$method.splitImgHost(goodsData.coverUrl)" mode="widthFix"
- style="width: 100%; height: 421rpx">
- </image>
- </view>
- <view v-else-if="playSource == 1">
- <my-player ref="player" :playVid="playVid" :autoplay="autoplay" :allowSeek="isAllowSeek"
- :playbackRate="playbackRate" :videoCurrentTime="videoCurrentTime || 0" @playing="playing"
- @pause="pause" @ended="ended" @loadedmetadata="loadedmetadata" @timeupdate="timeupdate"
- @playerError="playerError" @studyLog="studyLog"></my-player>
- </view>
- <view v-else>
- <my-player2 ref="player2" :playFileId="playVid" :autoplay="autoplay" :progressControl="isAllowSeek"
- :playbackRate="playbackRate" :currentTime="videoCurrentTime || 0" @playing="playing" @pause="pause"
- @ended="ended" @loadedmetadata="loadedmetadata" @timeupdate="timeupdate" @playerError="playerError"
- @studyLog="studyLog"></my-player2>
- </view>
- <view class="course_name">
- <view class="course_titles">
- <view class="video_t1" :class="{ one: !goodsData.buyNote }">{{
- detail.courseName
- }}</view>
- <view class="notice_wrap" v-if="goodsData.buyNote">
- <view class="video_t1_t" @click="studyNotice"> 学员须知 </view>
- </view>
- <view class="toggle_course" v-if="goodsTeacher.length > 1" @click="changeCourses()">
- <image class="img" src="/pages3/static/imgs/toggle.png" mode="widthFix"></image>
- <view class="toggle_name">切换课程</view>
- <view class="numbers">共{{ goodsTeacher.length }}门</view>
- </view>
- </view>
- </view>
- <u-line color="#D6D6DB" />
- <view>
- <view>
- <u-tabs :item-width="itemWidth()" :list="list" font-size="32" bar-width="24" :current="current"
- @change="change" active-color="#007AFF"></u-tabs>
- </view>
- </view>
- <u-line color="#D6D6DB" />
- </view>
- <view class="box" :class="{ first_ml: current == 0 }">
- <scroll-view class="box_in" scroll-y="true">
- <!--目录 -->
- <view v-show="current == 0">
- <view class="top__header" v-if="livingItem" @click="goLive(livingItem)">
- <image class="img" src="/pages3/static/imgs/live.png" mode="widthFix"></image>
- <view class="note">正在直播中</view>
- <view class="title">{{ livingItem.sectionName }}</view>
- </view>
- <course-tree v-if="sectionItem.id || sectionItem.sectionId" :sectionMaxNum="goodsData.sectionMaxNum"
- :isRebuild="false" :isBuy="true" @isHaverebuild="isHaverebuild = true"></course-tree>
- </view>
- <!--讲义 -->
- <view v-if="current == 1">
- <handouts-box :handoutsId="goodsData.handoutsId"></handouts-box>
- </view>
- <!--笔记 -->
- <view v-if="current == 2">
- <note-Box @jumpNote="jumpNote"></note-Box>
- </view>
- <!--答疑 -->
- <view v-if="current == 3">
- <answer-box :userId="userInfo ? userInfo.userId : 0"></answer-box>
- </view>
- <!--重修目录 -->
- <view v-if="current == 4">
- <course-tree v-if="sectionItem.id || sectionItem.sectionId" :sectionMaxNum="goodsData.sectionMaxNum"
- :isRebuild="true" :isBuy="true"></course-tree>
- </view>
- </scroll-view>
- </view>
- <u-popup v-model="noticeShow" class="notice_modal" mode="center" border-radius="28" width="650rpx"
- height="622rpx" :mask-close-able="false">
- <view class="content">
- <view class="title">学员须知</view>
- <scroll-view scroll-y="true">
- <view class="text" v-html="
- goodsData.buyNote && goodsData.buyNote.replace(/\n|\r\n/g, '<br>')
- ">
- </view>
- </scroll-view>
- <view class="had_read" :class="{ gray: CountTo > 0 }" @click="noticeConfirm()">
- <text v-if="CountTo > 0">请阅读学员须知,{{ " " + CountTo + "s" }}后可关闭</text>
- <text v-else>我已阅读学员须知</text>
- </view>
- </view>
- </u-popup>
- <!-- 倒计时提交 -->
- <u-popup v-model="noticeShow1" class="notice_modal" mode="center" border-radius="28" width="650rpx"
- height="262rpx" :mask-close-able="false">
- <view class="content">
- <view class="title">提示</view>
- <view class="had_read">
- <text v-if="CountTo1 >= 0">视频学习时长不达标,请等待</text>
- <text v-if="CountTo1 >= 0">{{ " " + CountTo1 + "s" }}</text>
- </view>
- </view>
- </u-popup>
- <u-modal v-model="noticeShow2" title="提示" @confirm="resetSection" confirm-text="返回重学"
- :show-cancel-button="false">
- <view class="slot-content">
- <text> 系统检测您在学习过程中有拖拽或快进行为,请重新学习!倒计时</text>
- <text v-if="CountTo2 >= 0" style="color: orange;">{{ " " + CountTo2 + "s " }} </text>
- <text> 秒后自动返回重学</text>
- </view>
- </u-modal>
- <u-modal v-model="showMark" title="提示" @confirm="markConfirm" @cancel="toBack" confirm-text="复制学习网址"
- :show-cancel-button="true" cancel-text="关闭">
- <view class="slot-content">
- <view>您的学习账号已经开通,请按照步骤操作,进行学习。</view>
- <view>1.复制学习地址:{{ markContent }}</view>
- <view>2.在【浏览器中】打开复制的学习网址</view>
- <view>3.打开学习网址后,选择【个人用户】进行登录</view>
- <view>(1)账号:您个人的身份证号码</view>
- <view>(2)密码:身份证号码,再加111111</view>
- </view>
- </u-modal>
- <!-- 切换课程弹窗 -->
- <u-popup v-model="toggleCourseShow" mode="bottom" border-radius="40" :mask-close-able="false">
- <view class="popup_box">
- <view class="check_head">
- <view class="headers">
- <view class="grade">切换课程</view>
- <u-icon name="close" color="#9C9C9C" size="40" @click="closePop()"></u-icon>
- </view>
- <view class="coruse_num">共{{ goodsTeacher.length }}门</view>
- <view class="menuSel">
- <scroll-view class="sub_sliper" scroll-x="true">
- <view v-for="(item, index) in subList" :key="index"
- style="margin-right: 50rpx; display: inline-block">
- <view class="r_t1" :class="{ nactive: subIndex == index }" @click="cMenu(item, index)">
- {{ item.subjectName }}
- </view>
- </view>
- </scroll-view>
- </view>
- </view>
- <view class="check_con">
- <scroll-view scroll-y="true" style="height: 700rpx">
- <view v-for="(courseItem, gTindex) in goodsTeacher" :key="gTindex">
- <view v-for="(item, index) in courseItem.courseList" :key="index" v-show="
- item.subjectId === newActiveSubjectId || !newActiveSubjectId
- ">
- <view class="course_items" v-if="item.show && item.show == 1">
- <view class="course_lefts">
- <view class="course_title">
- {{ item.courseName }}
- </view>
- <view v-if="courseItem.teaList && courseItem.teaList.length > 0"
- class="teacher_names">
- <view v-for="(tea, tindex) in courseItem.teaList" :key="tindex"
- class="names">{{ tea.aliasName }}
- </view>
- </view>
- <view class="course_pros">
- 学习进度
- <text>
- {{ item.stuAllNum + item.recordNum }}/{{
- item.secAllNum + item.examNum
- }}</text>
- </view>
- </view>
- <view class="course_rights" @click="jump(item, gTindex, 'jump')">
- <view class="cicles">
- <u-icon name="arrow-right" color="#498AFE" size="20"></u-icon>
- </view>
- <view class="intoStudy">进入学习</view>
- </view>
- </view>
- </view>
- </view>
- </scroll-view>
- </view>
- </view>
- </u-popup>
- <!-- 摄像头 -->
- <Popup-camera @submitPhoto="submitPhoto" :visible.sync="showCamera" ref="camera" />
- <Popup-media @submitTakeVideo="submitTakeVideo" :visible.sync="showMedia" ref="media" />
- </view>
- </template>
- <script>
- import handoutsBox from "@/components/course/handoutsBox.vue";
- import courseTree from "@/components/course/courseTree.vue";
- import PopupCamera from "../../components/popup/camera.vue";
- import PopupMedia from "../../components/popup/media.vue";
- import myPlayer from "@/components/myPlayer/polyvPlayer.vue";
- import myPlayer2 from "@/components/myPlayer2/tcPlayer.vue";
- import noteBox from "@/components/course/noteBox.vue";
- import answerBox from "@/components/course/answerBox.vue";
- import {
- mapGetters,
- mapMutations
- } from "vuex";
- import {
- lockAction
- } from "../../utils/lock";
- import {
- debounce,
- throttle,
- reload
- } from "../../utils/common";
- export default {
- components: {
- handoutsBox,
- myPlayer,
- myPlayer2,
- noteBox,
- answerBox,
- courseTree,
- PopupCamera,
- PopupMedia,
- },
- data() {
- return {
- markContent: "http://admin.zhujianpeixun.com/",
- showMark: false,
- lockTimer: null,
- orderGoodsId: 0,
- noticeShow: false,
- showSet: false,
- courseId: 0,
- current: 0,
- playSource: 1,
- vid: "",
- goodsId: 0,
- goodsData: {},
- showCamera: false,
- showMedia: false,
- goodsPlayConfig: null,
- autoplay: false,
- isAllowSeek: "no",
- playbackRate: [1.0],
- timer: null,
- goodsPhotographConfig: null,
- playTime: 0, // 播放时刻
- avatarUrl: "",
- ossAvatarUrl: "",
- gradeId: 0,
- chapterId: 0,
- moduleId: 0,
- videoCurrentTime: 0,
- photoIndex: 0,
- photoNum: 0,
- photoList: [], //拍照的时间点
- photoConfig: false, //是否配置好拍照次数
- photoHistoryList: [], //已拍照历史的下标点
- sectionItem: {},
- isShowBar: true,
- isRebuild: false, //视频是否从重修目录点击
- livingItem: "",
- option: null,
- toggleCourseShow: false, // 切换课程弹窗
- courseList: [], // 课程列表
- subList: [],
- subIndex: 0,
- goodsTeacher: [],
- teacherList: [],
- teacherIndex: 0,
- newActiveSubjectId: "", //当前选中ID
- compareFaceData: 0, // 拍照匹配相似度
- prendreAutoCarme: false, // 是否发起授权相机
- CountTo: 0, // 倒计时
- CountTo1: 0,
- menuAllList: [],
- curPlayIndex: 0, // 正在播放的节的下标
- faceUrl: "",
- erJianErZao: false,
- jjShiGongYuan: false,
- pauseTime: 0,
- pauseTimer: null,
- isReach: false,
- noticeShow1: false,
- refPlv: null,
- isCache: false,
- isHaverebuild: false,
- isPlaying: false,
- beforeHideIsPlaying: false,
- isLeave: false,
- text: "",
- isShowpopuptips: true,
- throttleFn: throttle(this.postStudyRecord, 15000),
- needtoTakeVideo: false, //是否需要随机录制2秒视频
- timeNeedtoTakeVideo: null, //需要随机录制2秒视频定时器
- curPlayOver: false, //当前视频已播放完毕
- noticeShow2: false,
- CountTo2: 0,
- CountTo2Times: null,
- reerrorcode:0,
- hideplayer:false,
- };
- },
- computed: {
- ...mapGetters(["userInfo", "other"]),
- playSecIsLearn() {
- if (!this.playVid) {
- return false;
- }
- return this.sectionItem.learning != 1;
- },
- orderNum() {
- return this.goodsData.goodsLearningOrder;
- },
- list() {
- let list = [{
- name: "目录",
- },
- {
- name: "讲义",
- },
- {
- name: "笔记",
- },
- {
- name: "答疑",
- },
- ];
- if (this.isHaverebuild) {
- list.push({
- name: "重修目录"
- });
- }
- return list;
- },
- params: function() {
- return (keys = ["orderGoodsId", "goodsId", "courseId"]) => {
- let params = {};
- for (const key of keys) {
- params[key] = this[key];
- }
- return params;
- };
- },
- detail() {
- if (!this.courseId || !this.courseList.length) {
- return {};
- }
- return this.courseList.find((e) => e.courseId == this.courseId);
- },
- sectionId() {
- return this.sectionItem.sectionId || this.sectionItem.id;
- },
- playVid() {
- return this.sectionItem.recordingUrl;
- },
- isPlayRebuild() {
- return this.sectionItem.rebuild != 1;
- },
- },
- async onLoad(option) {
- // #ifdef H5
- console.error(this.$method.myBrowser(), '浏览器')
- if (this.$method.myBrowser() == 'UC') {
- uni.showModal({
- title: "提示",
- content: "请使用其他浏览器进行学习",
- showCancel: false,
- complete: () => {
- uni.switchTab({
- url: "/pages/learn/index",
- });
- }
- })
- return
- }
- // #endif
- // 针对腾讯商品并且是webview重载后的对URl参数的处理
- if (option.obj) {
- this.isShowBar = false;
- console.log("检测option.obj", option)
- console.log("解析后的option.obj", JSON.parse(decodeURIComponent(option.obj)))
- option = JSON.parse(decodeURIComponent(option.obj));
- }
- // 请求商品类型并判断是否是小程序环境
- await this.orderGetViewSign(option)
- if (option.isOther) {
- this.showMark = true;
- return;
- }
- this.option = option;
- let {
- skipPort,
- id,
- goodsId,
- orderGoodsId,
- gradeId,
- informId
- } = option;
- this.orderGoodsId = Number(orderGoodsId) || "";
- this.courseId = Number(id) || "";
- this.goodsId = Number(goodsId);
- this.gradeId = Number(gradeId);
- this.isLeave = false;
- uni.addInterceptor("navigateTo", {
- success: (e) => {
- this.isLeave = true;
- this.isCache = true;
- },
- });
- if (skipPort) {
- await this.$method.skipLogin(skipPort);
- }
- if (this.$method.isGoLogin()) {
- return;
- }
- if (!this.lockTimer) {
- lockAction();
- this.lockTimer = setInterval(lockAction, 10000);
- }
- // 公众号模板消息的数据埋点
- informId && this.clickOfficial(informId);
- // 进行学习后,保存标识,用于检查是否二建15天提示弹窗弹出
- if (!this.userInfo) {
- await this.$store.dispatch('getUserInfo')
- }
- // #ifdef H5
- if (this.userInfo.slabSign == 1) {
- if (this.$method.isIPad()) {
- uni.showModal({
- title: "提示",
- content: "暂不支持使用iPad学习,请使用普通手机打开",
- showCancel: false,
- complete: () => {
- uni.switchTab({
- url: "/pages/learn/index",
- });
- }
- })
- return
- }
- if (this.$method.isTablet()) {
- uni.showModal({
- title: "提示",
- content: "当前页面暂不支持使用平板学习",
- showCancel: false,
- complete: () => {
- uni.switchTab({
- url: "/pages/learn/index",
- });
- }
- })
- return
- }
- }
- // #endif
- this.saveLoaclCheckClass(Number(option.orderGoodsId))
- this.init();
- // this.openMedia();
- // this.showCamera=true;
- },
- async onShow() {
- if (!this.$method.isLogin()) {
- return;
- }
- if (this.isCache) {
- console.log("返回刷新数据");
- this.isCache = false;
- this.sectionItem = {};
- this.beforeHideIsPlaying = false;
- reload(this.option);
- return;
- }
- if (this.beforeHideIsPlaying) {
- console.log("显示重新播放");
- if (this.text) {
- this.refPlv.playPause();
- return;
- }
- this.refPlv.resumeVideo();
- }
- },
- onUnload() {
- console.log("onUnload");
- if (this.isPlaying) {
- this.postStudyRecord();
- }
- this.refPlv = null;
- uni.$off();
- this.clearPauseTimer();
- uni.removeInterceptor("navigateTo");
- if (this.lockTimer) {
- clearInterval(this.lockTimer);
- this.$api.lockDelLock({
- action: "jxjy",
- uuid: this.$method.getUuid(),
- }).then(res => {
- console.log("删除登录", res)
- });
- }
- },
- onHide() {
- console.log('隐藏页面')
- this.beforeHideIsPlaying = this.isPlaying;
- if (this.isPlaying) {
- this.refPlv.playPause();
- }
- },
- mounted() {},
- methods: {
- ...mapMutations(["updateChapterOpen", "updateLiveLast"]),
- orderGetViewSign(option) {
- return new Promise(resolve => {
- this.$api.orderGetViewSign(Number(option.orderGoodsId)).then((res) => {
- this.playSource = res.data.data.viewSign;
- if (this.playSource == 2) {
- // #ifdef MP-WEIXIN
- this.$api
- .courseSkipPort()
- .then((res2) => {
- console.log("详情页请求的域名", res2.data.data.domain, res2.data.data
- .skipPort)
- let obj = {
- skipPort: res2.data.data.skipPort,
- ...option
- }
- let webViewUrl = encodeURIComponent(
- res2.data.data.domain +
- '/pages3/polyv/detail?obj=' +
- JSON.stringify(obj))
- uni.redirectTo({
- url: `/pages5/webview/detaillink?url=${webViewUrl}`
- })
- })
- return;
- // #endif
- }
- resolve()
- })
- })
- },
- // 进行学习后,保存标识,用于检查是否二建15天提示弹窗弹出
- saveLoaclCheckClass(orderGoodsId) {
- console.log('---------检查班级过期--------')
- let ary = uni.getStorageSync("loaclCheckClass") || []
- let userFindIndex = ary.findIndex(i => i.userId == this.userInfo.userId)
- if (userFindIndex !== -1) {
- if (!ary[userFindIndex].orderGoodsIds.includes(orderGoodsId)) {
- ary[userFindIndex].orderGoodsIds.push(orderGoodsId)
- }
- } else {
- ary.push({
- userId: this.userInfo.userId,
- orderGoodsIds: [orderGoodsId]
- })
- }
- uni.setStorageSync("loaclCheckClass", ary)
- },
- async init() {
- if (this.playSource == 2) {
- this.isAllowSeek = false;
- } else {
- // #ifdef MP-WEIXIN
- this.isAllowSeek = "no";
- // #endif
- // #ifdef H5
- this.isAllowSeek = "on";
- // #endif
- }
- console.log("进入:", this.playSource, this.isAllowSeek)
- this.photoList = [];
- this.courseList = [];
- this.photoConfig = false;
- await this.isCanLearn();
- this.courseCourseList();
- },
- closepopup() {
- this.goodsData.reminderSign = 0;
- },
- // 七大员是否能进入学习
- async qCheckIsCanLearn() {
- let res = await this.$api.qCheckIsCanLearn(this.orderGoodsId);
- if (res.data.code !== 200) {
- uni.showModal({
- showCancel: false,
- title: "提示",
- content: res.data.msg,
- success: (resultst) => {
- uni.navigateBack();
- },
- });
- return Promise.reject();
- }
- if (this.goodsData.gradeId > 0 && this.goodsData.jjShiGongYuan) {
- let res1 = await this.$api.syncSevenPublicClass({
- orderGoodsId: this.orderGoodsId,
- });
- if (res1.data.code !== 200) {
- if(res1.data.msg!='课程定位错误'){
- uni.showModal({
- showCancel: false,
- title: "提示",
- content: "无法进入学习!",
- success: (resultst) => {
- uni.navigateBack();
- },
- });
- return Promise.reject();
- }
- }
- }
- },
- // 新增微信公众号模板消息点击数据
- clickOfficial(informId) {
- this.$http({
- url: "/data/click",
- method: "post",
- data: {
- informId
- },
- });
- },
- // 点击课程目录
- cMenu(item, index) {
- this.subIndex = index;
- this.newActiveSubjectId = item.subjectId;
- },
- courseCourseList() {
- this.$api
- .courseCourseList({
- pageNum: 1,
- pageSize: 200,
- ...this.params(["goodsId", "orderGoodsId", "gradeId"]),
- })
- .then((res) => {
- if (res.data.code == 200) {
- this.courseList = res.data.rows;
- if (res.data.total > 1) {
- // 科目
- this.subList = [{
- subjectId: 0,
- subjectName: "所有"
- }];
- this.courseList.forEach((item) => {
- if (!this.subList.find((e) => e.subjectId == item.subjectId)) {
- this.subList.push(item);
- }
- });
- this.getUserWatchLast();
- } else {
- this.originOnShow();
- this.originMounted();
- }
- }
- });
- },
- // 查询用户最后一次看的录播的信息
- getUserWatchLast() {
- this.$http({
- url: "/study/record/getUserWatchLast",
- method: "get",
- data: {
- orderGoodsId: this.orderGoodsId,
- },
- }).then((res) => {
- if (res.data.code == 200 && res.data.data) {
- this.courseId = res.data.data.courseId;
- }
- if (!this.courseId) {
- this.courseId = this.courseList[0].courseId;
- }
- this.originOnShow();
- this.originMounted();
- //获取商品双师资模板
- this.getCourseTeacher(this.courseList);
- });
- },
- getCourseTeacher(rows) {
- this.goodsTeacher = [];
- //获取商品双师资模板
- this.$api
- .courseTeacherList({
- goodsId: this.goodsId,
- })
- .then((res1) => {
- if (res1.data.data && res1.data.data.length > 0) {
- //课程老师模板
- let teacherTel = res1.data.data;
- //商品课程
- let courses = rows;
- teacherTel.forEach((tea) => {
- let dataList = [];
- let teacherList = [];
- courses.forEach((item) => {
- let data = tea.courseList.filter(
- (x) => x.courseId == item.courseId
- );
- if (data && data.length > 0) {
- dataList.push(item);
- teacherList = tea.courseList;
- }
- });
- let result = {
- teaList: teacherList,
- courseList: dataList,
- };
- this.goodsTeacher.push(result);
- });
- if (this.goodsTeacher && this.goodsTeacher.length > 0) {
- let courseIds = [];
- this.goodsTeacher.forEach((item) => {
- item.courseList.forEach((course) => {
- courseIds.push(course.courseId);
- });
- });
- if (courseIds.length > 0) {
- courses.forEach((item) => {
- if (!courseIds.includes(item.courseId)) {
- let data = {
- teaList: [],
- courseList: [],
- };
- data.courseList.push(item);
- this.goodsTeacher.push(data);
- }
- });
- }
- this.goodsTeacher.forEach((item) => {
- if (item.courseList && item.courseList.length > 0) {
- item.courseList[0].show = 1;
- }
- });
- }
- } else {
- //没有双师资模板
- rows.forEach((item) => {
- item.show = 1;
- let data = {
- teaList: [],
- courseList: [],
- };
- data.courseList.push(item);
- this.goodsTeacher.push(data);
- });
- }
- this.goodsTeacher.forEach((item) => {
- if (item.courseList.some((x) => x.courseId == this.courseId)) {
- this.teacherList = item.teaList;
- }
- });
- });
- },
- erJianErZaoPauseTip() {
- if (this.playSecIsLearn && this.erJianErZao && !this.isLeave) {
- if (this.pauseTimer) {
- return;
- }
- this.pauseTime = Date.now();
- this.pauseTimer = setInterval(() => {
- console.log("暂停时间", Date.now() - this.pauseTime, this.pauseTime);
- if (Date.now() - this.pauseTime > 5 * 60 * 1000) {
- // 5 * 60 * 1000
- this.refPlv.exitFullScreen();
- this.text = "暂停";
- if (this.showCamera) {
- this.text = "拍照停留";
- this.closeCamera();
- }
- uni.showModal({
- title: "提示",
- showCancel: false,
- content: `检测${this.text}时间过长,刷新当前页面`,
- cancelText: "取消",
- confirmText: "确定",
- success: (res) => {
- this.text = "";
- reload(this.option);
- // #ifdef MP-WEIXIN
- this.sectionItem = {};
- // #endif
- },
- });
- this.clearPauseTimer();
- }
- }, 5000);
- }
- },
- // 原来onshow里面的内容
- async originOnShow() {
- await this.studyRecordMenuAllList();
- // 消息过来 定位某个节
- if (this.option.noteSecond) {
- this.jumpNote({
- sectionType: 1,
- ...this.option,
- });
- return;
- }
- this.studyRecordQueryLiveLast();
- },
- // 原来的mouted内容
- originMounted() {
- uni.$on(
- "getSection",
- debounce((item) => {
- if (this.playSource == 2) {
- if (!this.refPlv && this.playVid) {
- this.refPlv = this.$refs.player2;
- }
- } else {
- if (!this.refPlv && this.playVid) {
- this.refPlv = this.$refs.player;
- }
- }
- if (this.isPlaying) {
- this.refPlv.playPause();
- }
- this.photoConfig = false;
- this.photoList = [];
- this.moduleId = item.moduleId || 0;
- this.chapterId = item.chapterId || 0;
- this.sectionItem = item;
- this.playVideo(item);
- this.postStudyRecord(0);
- })
- );
- uni.$on("isRebuild", (item) => {
- this.isRebuild = item;
- });
- this.updateChapterOpen(true);
- },
- clearPauseTimer() {
- if (this.pauseTimer) {
- this.pauseTime = 0;
- clearInterval(this.pauseTimer);
- this.pauseTimer = null;
- }
- },
- changeCourses() {
- this.toggleCourseShow = true;
- },
- closePop() {
- this.toggleCourseShow = false;
- },
- async activeFunc(item, index) {
- this.teacherIndex = index;
- let findResult = "";
- this.goodsTeacher.forEach((citem, index) => {
- citem.courseList.forEach((e, e_index) => {
- if (e.courseId == item.courseId) {
- findResult = e;
- }
- });
- });
- this.jump(findResult, 1);
- },
- // 进入学习
- async jump(item, index, type) {
- if (this.courseId === item.courseId) {
- this.toggleCourseShow = false;
- return;
- }
- if (this.orderNum == 2 && index != 0) {
- let prevItem = this.courseList[index - 1];
- if (
- prevItem.stuAllNum + prevItem.recordNum <
- prevItem.secAllNum + prevItem.examNum
- ) {
- uni.showToast({
- icon: "none",
- title: "请按顺序学完上一课再学习这一课",
- });
- return;
- }
- }
- // 打回 需重修
- if (item.rebuild === 0) {
- this.$navTo.togo("/pages2/learn/details", {
- id: item.courseId,
- ...this.params(["goodsId", "orderGoodsId", "gradeId"]),
- });
- return;
- }
- if (type) {
- this.teacherIndex = 0;
- this.goodsTeacher.forEach((citem) => {
- if (citem.courseList.some((x) => x.courseId == item.courseId)) {
- this.teacherList = citem.teaList;
- }
- });
- }
- this.sectionItem = {};
- this.toggleCourseShow = false;
- this.courseId = item.courseId;
- this.originOnShow();
- },
- clickLeft() {
- uni.switchTab({
- url: "/pages/learn/index",
- });
- },
- toBack(delta = 1) {
- uni.navigateBack({
- delta,
- });
- },
- markConfirm() {
- uni.setClipboardData({
- data: this.markContent,
- success: () => {
- setTimeout(this.toBack, 1000);
- },
- });
- },
- noticeConfirm() {
- if (this.CountTo <= 0) {
- this.noticeShow = false;
- if (this.autoplay) {
- this.refPlv && this.refPlv.resumeVideo();
- }
- this.$api.baseHandoutTip({
- orderGoodsId: this.orderGoodsId,
- });
- }
- },
- baseHandoutTipList() {
- this.$api
- .baseHandoutTipList({
- orderGoodsId: this.orderGoodsId,
- })
- .then((res) => {
- if (res.data.rows.length == 0) {
- this.noticeShow = true;
- this.CountTo = 30;
- var timer = setInterval(() => {
- this.CountTo--;
- if (this.CountTo < 0) {
- clearInterval(timer);
- }
- }, 1000);
- }
- });
- },
- /**
- * 获取上次观看的直播
- */
- studyRecordGetLastLive() {
- this.$api
- .studyRecordGetLastLive({
- orderGoodsId: this.orderGoodsId,
- courseId: this.courseId,
- })
- .then((res) => {
- this.updateLiveLast(res.data.data);
- });
- },
- async initPlayVideo(sectionItem) {
- this.moduleId = sectionItem.moduleId || 0;
- this.chapterId = sectionItem.chapterId || 0;
- this.sectionItem = sectionItem;
- if (sectionItem.sectionType == 1) {
- //录播
- this.playVideo(sectionItem);
- } else if (sectionItem.sectionType == 2) {
- //直播
- this.studyRecordGetLastLive();
- } else if (sectionItem.sectionType == 3) {
- //回放
- this.playVideo(sectionItem);
- } else if (sectionItem.doType == 2) {
- uni.showModal({
- title: "温馨提示",
- content: "当前节视频已学完,是否进入考试?",
- success: (res) => {
- if (res.confirm) {
- this.toQuestionBank(sectionItem);
- }
- },
- });
- return;
- }
- },
- async submitPhoto(url, compareFaceData) {
- this.ossAvatarUrl = url;
- this.compareFaceData = compareFaceData;
- this.postCoursePhotoRecord()
- .then(async (res) => {
- console.log("showCamera1", this.showCamera)
- this.photoHistoryList[this.photoIndex] = true;
- await this.postStudyRecord();
- this.closeCamera();
- if (this.isReach) {
- console.log("showCamera2", this.showCamera)
- await this.postStudyRecord(1);
- this.nextSection();
- console.log("showCamera3", this.showCamera)
- return;
- }
- console.log("showCamera4", this.showCamera)
- this.refPlv.resumeVideo();
- })
- .catch((err) => {
- uni.showToast({
- title: "上传接口报错,请重新拍照上传" + err,
- icon: "none",
- });
- this.$refs["camera"].reTake();
- });
- },
- toQuestionBank(sectionItem) {
- // type 1模块 2章 3节 4章卷 5模块卷
- uni.navigateTo({
- url: "/pages2/class/questionBank?courseId=" +
- this.courseId +
- "&gradeId=" +
- this.gradeId +
- "&isFromVideo=1&id=" +
- sectionItem.id +
- "&goodsid=" +
- this.goodsId +
- "&moduleId=" +
- (sectionItem.moduleId || 0) +
- "&chapterId=" +
- (sectionItem.chapterId || 0) +
- "&orderGoodsId=" +
- this.orderGoodsId +
- "&type=" +
- (sectionItem.type == 4 ? 1 : 3) +
- "&learning=" +
- sectionItem.studyStatus +
- "&isBackVideo=" +
- 1,
- });
- },
- studyRecordQueryLiveLast() {
- this.$api
- .studyRecordQueryLiveLast({
- gradeId: this.gradeId,
- orderGoodsId: this.orderGoodsId,
- courseId: this.courseId,
- })
- .then((res) => {
- let {
- data
- } = res.data;
- if (data && data.endTime > parseInt(new Date().getTime() / 1000)) {
- uni.showModal({
- showCancel: false,
- title: "提示",
- content: "当前无法学习," + this.$method.timestampToTime(data.endTime, false) +
- "过后可继续学习",
- success: (resultst) => {
- uni.navigateBack();
- },
- });
- return
- }
- if (!data.sectionId) {
- data = this.menuAllList[0];
- }
- if (data.learning == 1 && this.orderNum == 2) {
- let next = this.menuAllList.find((e) => e.studyStatus != 1);
- next && (data = next);
- }
- this.initPlayVideo(data);
- });
- },
- async goLive(item) {
- let moduleId = item.moduleId || 0;
- let chapterId = item.chapterId || 0;
- let sectionId = item.sectionId || item.menuId;
- let uuid = new Date().valueOf() + "";
- if (!this.userInfo) {
- await this.$store.dispatch('getUserInfo')
- }
- // buyCourse 是否购买课程:1是 0否
- let encode = encodeURIComponent(
- this.other.hostLive +
- "/pages/live/index?token=" +
- uni.getStorageSync("token") +
- "&userInfo=" +
- JSON.stringify(this.userInfo) +
- "&channelId=" +
- item.liveUrl +
- "&gradeId=" +
- this.gradeId +
- "&courseId=" +
- this.courseId +
- "&goodsId=" +
- this.goodsId +
- "&orderGoodsId=" +
- this.orderGoodsId +
- "§ionId=" +
- sectionId +
- "&chapterId=" +
- chapterId +
- "&moduleId=" +
- moduleId +
- "&buyCourse=1" +
- "&ident=" +
- uuid
- );
- uni.navigateTo({
- url: `/pages5/webview/index?url=` + encode,
- });
- },
- studyRecordMenuAllList() {
- // study/record/menuAllList
- return this.$api
- .studMenuAllList({
- courseId: this.courseId,
- ...this.params(["goodsId", "orderGoodsId", "gradeId"]),
- })
- .then((res) => {
- let nowTime = Number(new Date().getTime() / 1000).toFixed(0);
- if (res.data.data) {
- this.menuAllList = res.data.data.filter(
- (e) => e.doType != 1 || (e.doType == 2 && e.studyStatus == 1)
- );
- this.livingItem = res.data.data.find(
- (item) =>
- item.liveStartTime <= nowTime && item.liveEndTime > nowTime
- );
- }
- return Promise.resolve();
- });
- },
- async getbaseprofiletplists() {
- let {
- data: {
- code,
- rows
- },
- } = await this.$api.getbaseprofiletplists({
- goodsId: this.goodsId,
- orderGoodsId: this.orderGoodsId,
- });
- if (code === 200 && rows.length && rows[0].keyValue) {
- let baseRes = await this.$api.getbaseprofiletpId(this.goodsId);
- if (baseRes.data.code === 200 && baseRes.data.data) {
- let {
- data: {
- code,
- data
- },
- } = await this.$api.getbaseprofiletpgetInfo({
- goodsId: this.goodsId,
- orderGoodsId: this.orderGoodsId,
- });
- if (
- code === 200 &&
- (!data || (data.status === 3 && data.changeStatus === 1))
- ) {
- uni.showModal({
- content: !data ?
- "请前往填写资料" : "资料审核不通过,请前往重新填写",
- cancelText: "返回",
- success: (resultst) => {
- if (resultst.confirm) {
- this.$navTo.togo("/pages2/verify/input", {
- id: this.goodsId,
- orderGoodsId: this.orderGoodsId,
- });
- }
- if (resultst.cancel) {
- uni.navigateBack();
- }
- },
- });
- return Promise.reject();
- } else if (data.status === 1 && JSON.parse(rows[0].keyValue2)[0] && false) {
- let {
- data: {
- code,
- data
- },
- } = await this.$api.getbaseprofileStampgetInfo({
- goodsId: this.goodsId,
- orderGoodsId: this.orderGoodsId,
- });
- if (
- code === 200 &&
- (!data || (data.status === 3 && data.changeStatus === 1))
- ) {
- uni.showModal({
- content: !data ?
- "请前往填写盖章资料" : "资料盖章审核不通过,请前往重新填写",
- cancelText: "返回",
- success: (resultst) => {
- if (resultst.confirm) {
- this.$navTo.togo("/pages2/verify/input2", {
- id: this.goodsId,
- orderGoodsId: this.orderGoodsId,
- });
- }
- if (resultst.cancel) {
- uni.navigateBack();
- }
- },
- });
- return Promise.reject();
- }
- } else if (data.status !== 1 && baseRes.data.data.checkStatus == 1) {
- uni.showModal({
- content: "资料正在审核中,暂无法学习,请耐心等待!如需加急审核,请联系客服人员",
- cancelText: "返回",
- success: (resultst) => {
- if (resultst.confirm) {
- uni.switchTab({
- url: '/pages/learn/index'
- });
- }
- if (resultst.cancel) {
- uni.switchTab({
- url: '/pages/learn/index'
- });
- }
- },
- });
- return Promise.reject();
- }
- }
- }
- return Promise.resolve();
- },
- async isCanLearn() {
- let {
- data
- } = await this.$api.goodsDetail(this.goodsId);
- this.goodsData = data.data;
- if (data.data.firstChoiceStatus) {
- uni.redirectTo({
- url: `/pages3/polyv/preference?courseId=${this.courseId}&goodsId=${data.data.goodsId}&orderGoodsId=${this.orderGoodsId}&gradeId=${data.data.gradeId}&minClassHour=${data.data.minClassHour || 0}`,
- });
- return
- }
- await this.getbaseprofiletplists();
- await this.qCheckIsCanLearn();
- await this.getGradeInfo();
- await this.getGoodsDetail();
- },
- /**
- * 计算tabs宽度
- */
- itemWidth() {
- return 100 / this.list.length + "%";
- },
- loadedmetadata(event) {
- if (this.playSource == 2) {
- this.refPlv = this.$refs.player2;
- } else {
- this.refPlv = this.$refs.player;
- }
- },
- getPhotoLastRecord() {
- let {
- chapterId,
- sectionId,
- moduleId
- } = this.sectionItem;
- let data = {
- ...this.params(),
- sectionId: sectionId || 0,
- gradeId: this.gradeId,
- chapterId: chapterId || 0,
- moduleId: moduleId || 0,
- };
- this.$api.getPhotoLastRecord(data).then((res) => {
- if (res.data.code == 200) {
- //清空历史数据
- this.photoHistoryList = [];
- this.photoList = [];
- for (let i = 0; i < res.data.data.length; i++) {
- //-2存储随机拍照数组
- if (res.data.data[i].photoIndex == -2) {
- this.photoList =
- res.data.data[i].timeInterval &&
- res.data.data[i].timeInterval.split(",");
- } else {
- this.photoHistoryList.push(res.data.data[i].photoIndex);
- }
- }
- }
- });
- },
- //postTime 只提交随机时间
- postCoursePhotoRecord(postTime = false) {
- return new Promise((resolve, reject) => {
- let data = {
- ...this.params(["orderGoodsId", "goodsId", "courseId", "gradeId"]),
- photo: this.ossAvatarUrl,
- sectionId: this.sectionId,
- photoTime: this.playTime || 0,
- photoIndex: postTime ? -2 : this.photoIndex, //从0算起,-2只提交随机时间
- photoNum: this.photoNum,
- chapterId: this.chapterId,
- moduleId: this.moduleId,
- timeInterval: postTime ? this.photoList.join(",") : "",
- };
- this.$api
- .coursePhotoRecord(data)
- .then((res) => {
- if (res.data.code == 200) {
- resolve();
- } else {
- reject();
- }
- })
- .catch((err) => {
- reject();
- });
- });
- },
- randomNum(minNum, maxNum) {
- switch (arguments.length) {
- case 1:
- return parseInt(Math.random() * minNum + 1, 10);
- break;
- case 2:
- return parseInt(Math.random() * (maxNum - minNum + 1) + minNum, 10);
- break;
- default:
- return 0;
- break;
- }
- },
- //配置随机拍照时间
- configPhoto(duration) {
- if ((this.photoConfig && this.photoList.length) || !this.isPlaying) {
- return;
- }
- //计算录视频逻辑
- if (this.needtoTakeVideo) {
- this.takeVideoLogic();
- }
- let totalVideoTime = this.refPlv.getDuration();
- this.photoConfig = true;
- if (this.erJianErZao) {
- this.photoList = this.randomConfig(totalVideoTime, duration);
- console.log(this.photoList, "this.photoList");
- return;
- }
- //没有历史拍照间隔数据
- if (!this.photoList || this.photoList.length == 0) {
- // 46 * 60
- this.photoList = this.commonConfig(
- totalVideoTime,
- this.jjShiGongYuan ? totalVideoTime < 2760 ? (46 * 60) - 1 : (45 * 60) - 1 : undefined
- );
- this.postCoursePhotoRecord(true); //提交随机拍照时间数组
- }
- console.log(this.photoList, "this.photoList");
- },
- // 二建随机拍摄时间
- randomConfig(totalVideoTime, duration) {
- this.photoHistoryList = [];
- let photoList = [duration];
- let pre = duration;
- if (totalVideoTime > 300) {
- while (pre <= totalVideoTime) {
- pre += this.randomNum(780, 900);
- pre <= totalVideoTime && photoList.push(pre);
- }
- if (totalVideoTime - 300 > photoList.slice(-1)[0]) {
- photoList.push(this.randomNum(totalVideoTime - 180, totalVideoTime));
- }
- }
- return photoList;
- },
- // 随机前后五分钟
- commonConfig(totalVideoTime, fixS) {
- let photoList = [];
- // 固定间隔时间取
- if (fixS) {
- let num = Math.ceil(totalVideoTime / fixS);
- if (num == 1) {
- photoList.push(parseInt(totalVideoTime / 2));
- } else {
- for (let i = 0; i < num; i++) {
- photoList.push(parseInt((totalVideoTime / (num + 1)) * (i + 1)));
- }
- }
- this.photoNum = num;
- } else {
- photoList = [0];
- if (this.photoNum == 3) {
- if (totalVideoTime >= 900) {
- //大于15分钟
- let centerTime = Math.floor(totalVideoTime / 2); //获取中间时间
- let centerMinTime = centerTime - 300; //前后5分钟
- let centerMaxTime = centerTime + 300;
- let centerTakeTime = this.randomNum(centerMinTime, centerMaxTime);
- photoList.push(centerTakeTime); //中间拍一张
- let endMaxTime = totalVideoTime - 60;
- let endMinTime = totalVideoTime - 300;
- let endTakeTime = this.randomNum(endMinTime, endMaxTime);
- photoList.push(endTakeTime); //最后拍一张
- } else {
- //小于15分钟
- let centerTime = this.randomNum(
- (1 / 3) * totalVideoTime,
- (2 / 3) * totalVideoTime
- );
- photoList.push(centerTime);
- let endTakeTime = this.randomNum(
- (2 / 3) * totalVideoTime,
- totalVideoTime
- );
- photoList.push(endTakeTime);
- }
- }
- }
- return photoList;
- },
- studyNotice() {
- this.noticeShow = true;
- },
- //正常播放视频
- async playVideo(item) {
- let {
- learning,
- videoCurrentTime,
- recordingUrl
- } = item;
- this.videoCurrentTime =
- videoCurrentTime || (await this.getRecordLast(item));
- // 往前播3秒
- if (this.videoCurrentTime > 3) {
- this.videoCurrentTime -= 3;
- }
- this.sectionItem = item;
- // 查找拍照历史
- if ((this.photoNum > 0 || this.jjShiGongYuan || this.erJianErZao) && learning != 1) {
- await this.getPhotoLastRecord();
- // #ifdef H5
- this.curPlayOver = false;
- await this.getCheckTakeVideo(); //获取是否需要随机录制3秒视频
- // #endif
- }
- if (this.refPlv) {
- if (this.playSource == 2) {
- this.refPlv.changeFileId({
- fileId: recordingUrl,
- currentTime: this.videoCurrentTime,
- });
- } else {
- this.refPlv.changeVid({
- vid: recordingUrl,
- videoCurrentTime: this.videoCurrentTime,
- });
- }
- }
- },
- getRecordLast(sectionItem) {
- let {
- chapterId,
- sectionId,
- courseId,
- moduleId
- } = sectionItem;
- return new Promise((resolve) => {
- let data = {
- ...this.params(),
- gradeId: this.gradeId || this.gradeId == 0 ? Number(this.gradeId) : null,
- sectionId: sectionId || 0,
- chapterId: chapterId || 0,
- moduleId: moduleId || 0,
- };
- this.$api.recordLast(data).then((res) => {
- resolve(res.data.data.videoCurrentTime);
- });
- });
- },
- jumpNote(item) {
- this.$u.toast("即将跳到笔记位置");
- if (this.sectionId != item.sectionId) {
- this.initPlayVideo({
- sectionType: 1,
- ...item,
- videoCurrentTime: Number(item.noteSecond),
- });
- } else {
- this.refPlv.seekVideo(item.noteSecond);
- }
- },
- getGradeInfo() {
- // 即刻 1 待定2 日期3
- return this.$api.goodsGradeInfo(this.gradeId).then((res) => {
- if (res.data.code == 200) {
- let {
- data
- } = res.data;
- if (
- data.learningStatus == 2 ||
- (data.learningStatus == 3 &&
- Number(data.learningTimeStart) > Number(new Date() / 1000))
- ) {
- uni.showModal({
- showCancel: false,
- confirmText: "确定",
- content: "当前课程正在申请中,正式开班后方可进行学习,请耐心等候!",
- success: function(resultst) {
- uni.navigateBack();
- },
- });
- return Promise.reject();
- }
- }
- });
- },
- postStudyRecord(status = 0, sectionId = this.sectionId) {
- if (!this.refPlv && this.playVid) {
- return;
- }
- let currentTime = this.refPlv.playCurrentTime();
- let PlayDuration = this.refPlv.playVideoTime();
- if (currentTime < 10 && !this.ossAvatarUrl) {
- if (status == 0) return;
- currentTime = this.playTime;
- }
- let self = this;
- let fromPlat = 1;
- // #ifdef H5
- fromPlat = 3;
- // #endif
- let data = {
- ...this.params([
- "orderGoodsId",
- "goodsId",
- "courseId",
- "erJianErZao",
- "gradeId",
- ]),
- fromPlat, //来源平台 1小程序 2网站
- photo: self.ossAvatarUrl,
- sectionId: sectionId || 0,
- studyDuration: parseInt(PlayDuration),
- chapterId: this.chapterId || 0,
- moduleId: this.moduleId || 0,
- videoCurrentTime: parseInt(currentTime),
- };
- if (this.ossAvatarUrl) {
- data.similarity = this.compareFaceData; // 相似度
- }
- if (status > 0) {
- data.status = status;
- }
- console.log(data, "记录参数");
- return new Promise((resolve, reject) => {
- this.$api
- .studyRecord(data)
- .then((res) => {
- console.log(res, "记录返回");
- let {
- code,
- msg
- } = res.data;
- if (code == 200) {
- if (status > 0) {
- // 刷新数据
- uni.$emit("playEnd");
- this.studyRecordMenuAllList();
- }
- self.ossAvatarUrl = "";
- } else if (code == 600) {
- uni.showModal({
- showCancel: false,
- title: "提示",
- content: msg,
- success: (resultst) => {
- uni.navigateBack();
- },
- });
- this.closeCamera();
- return
- } else if (code == 557 || code == 5581 || code == 5591) {
- this.abnormal(data);
- this.refPlv.playPause();
- this.refPlv.exitFullScreen();
- this.CountTo2 = 180;
- this.noticeShow2 = true;
- this.reerrorcode=code;
- if (this.CountTo2Times) {
- clearInterval(this.CountTo2Times);
- }
- this.CountTo2Times = setInterval(() => {
- if (this.CountTo2 <= 0) {
- clearInterval(this.CountTo2Times);
- this.noticeShow2 = false;
- this.resetSection(); //重置
- } else {
- this.CountTo2--;
- }
- }, 1000);
- return
- } else if (code == 558) {
- this.abnormal(data);
- this.CountTo1 = msg.split(",")[1];
- this.noticeShow1 = true;
- var timer = setInterval(() => {
- this.CountTo1--;
- if (this.CountTo1 < 0) {
- this.noticeShow1 = false;
- clearInterval(timer);
- this.postStudyRecord(1).then(this.nextSection);
- }
- }, 1000);
- this.closeCamera();
- return
- } else {
- uni.showToast({
- icon: "none",
- title: res.data.msg,
- duration: 2000,
- });
- if (code == 559) {
- this.abnormal(data);
- this.isReach = true;
- this.openCamera()
- }
- return
- }
- resolve();
- })
- .catch((err) => {
- this.studyRecordMenuAllList();
- });
- });
- },
- //异常记录
- abnormal(data) {
- this.$api
- .abnormal(data)
- .then((res) => {
-
- })
- .catch((err) => {
- console.log(err, "err");
- });
- },
- resetSection() {
- if (this.CountTo2Times) {
- clearInterval(this.CountTo2Times);
- }
- if(this.reerrorcode==557)
- {
- this.reerrorcode=0;
- uni.navigateBack();
- return
- }
- else if(this.reerrorcode==5581||this.reerrorcode==5591){
- let data = {
- ...this.params([
- "orderGoodsId",
- "courseId",
- ]),
- sectionId: this.sectionId || 0,
- errorCode:this.reerrorcode,
- };
- this.reerrorcode=0;
- this.$api
- .resetSection(data)
- .then((res) => {
- console.log(res, "记录返回");
- let {
- code,
- msg
- } = res.data;
- uni.navigateBack();
- })
- .catch((err) => {
- uni.navigateBack();
- });
- }
- },
- timeEvent(time) {
- console.log(this.refPlv.getDuration(), 'getDurationgetDuration')
- this.clearPauseTimer();
- if (this.playSecIsLearn && (this.erJianErZao || this.jjShiGongYuan || this.photoNum > 0)) {
- this.configPhoto(time);
- this.isReach = false;
- const index = this.photoList.findIndex((e) => e < time && e > time - 8);
- if (index != -1 && !this.photoHistoryList[index] && this.photoHistoryList[index] != 0) {
- this.photoIndex = index;
- // 拍照
- this.openCamera();
- }
- }
- },
- // 新增用户视频学习日志
- studyLog() {
- this.$http({
- url: "/user/study/log",
- method: "post",
- data: {
- ...this.params(),
- moduleId: this.moduleId || 0,
- chapterId: this.chapterId || 0,
- sectionId: this.sectionId || 0,
- fromPlat: 1, //来源平台 1小程序 2PC网站
- goodsType: 1, // 商品类型 1视频2题库 3补考 4前培 5虚拟赠送题库 6直播
- },
- }).then((res) => {});
- },
- timeupdate(time) {
- console.log("🚀 ~ file: detail.vue:1498 ~ timeupdate ~ time:"+time);
- if (this.noticeShow) {
- this.refPlv.playPause();
- return;
- }
- this.playTime = time;
- this.throttleFn();
- this.timeEvent(time);
- },
- playing() {
- //特殊设备跳过拍照停止学习
- if (this.showCamera) {
- this.refPlv.playPause();
- this.refPlv.exitFullScreen();
- return;
- }
- this.isPlaying = true;
- this.clearPauseTimer();
- },
- openCamera() {
- if (this.showCamera) return;
- if (this.showMedia) //如果正在录制视频,则5秒后再弹出
- {
- setTimeout(() => {
- this.openCamera();
- }, 5000);
- return;
- }
- this.showCamera = true;
- this.refPlv.playPause();
- this.refPlv.exitFullScreen();
- },
- closeCamera() {
- console.log("关闭")
- this.showCamera = false;
- },
- pause() {
- console.log("视频暂停");
- this.isPlaying = false;
- this.erJianErZaoPauseTip();
- },
- async ended() {
- console.log("视频播放完毕");
- this.isPlaying = false;
- uni.showToast({
- icon: "none",
- title: "播放完毕",
- });
- this.curPlayOver = true; //当前视频已播放完毕
- if (this.needtoTakeVideo) {
- this.openTakeVideo();
- return;
- }
- this.clearPauseTimer();
- await this.postStudyRecord(1);
- this.nextSection();
- this.curPlayOver = false;
- },
- playerError() {
- console.log("播放错误");
- },
- //播放下一节
- nextSection() {
- console.log("播放下一节");
- if (!this.menuAllList.length) {
- return;
- }
- this.curPlayIndex = this.menuAllList.findIndex((item) => {
- let i_sectionId = item.sectionId || 0;
- let i_chapterId = item.chapterId || 0;
- let i_moduleId = item.moduleId || 0;
- return (
- i_sectionId == this.sectionId &&
- i_chapterId == this.chapterId &&
- i_moduleId == this.moduleId
- );
- });
- let data = this.menuAllList[this.curPlayIndex + 1];
- if (!data) {
- //第二个弹窗
- uni.showModal({
- title: "温馨提示",
- content: "恭喜您课程学习全部完成,教务会在1-3个工作日内完成学习初审,请耐心等待。",
- showCancel: !this.erJianErZao,
- success: (res) => {
- if (res.confirm) {
- uni.switchTab({
- url: "/pages/learn/index",
- });
- }
- },
- });
- } else {
- data.learning = data.learning || data.studyStatus
- if (data.doType == 2) {
- if (data.studyStatus == 1) {
- uni.showToast({
- title: "试卷已合格!",
- duration: 2000,
- icon: "none",
- });
- return;
- }
- uni.showModal({
- title: "温馨提示",
- content: "当前节视频已学完,是否进入考试?",
- success: (res) => {
- if (res.confirm) {
- this.toQuestionBank(data);
- }
- },
- });
- return;
- }
- this.hideplayer=true;//先隐藏播放器
- uni.showModal({
- title: "温馨提示",
- content: "当前节视频已学完,继续学习下一节?",
- success: async (res) => {
- if (res.confirm) {
- this.hideplayer=false;
- this.videoCurrentTime=0;
- this.moduleId = data.moduleId;
- this.chapterId = data.chapterId;
- this.sectionId = data.sectionId;
- if (data.sectionType == 1) {
- //录播
- this.photoConfig = false;
- this.sectionItem = data;
- this.playVideo(data);
- } else if (data.sectionType == 2) {
- //直播
- this.studyRecordGetLastLive();
- } else if (data.sectionType == 3) {
- //回放
- this.sectionItem = data;
- this.playVideo(data);
- }
- this.updateChapterOpen(true);
- }
- else if(res.cancel){
- this.hideplayer=false;
- }
- },
- });
- }
- },
- async userConfirmInfoDetail() {
- let info = await this.$api.userConfirmInfoDetail({
- orderGoodsId: this.orderGoodsId,
- });
- if (!info.data.data || info.data.data.pushInfo !== 1) {
- uni.showModal({
- showCancel: false,
- title: "提示",
- content: "开通信息推送不成功,无法进入学习!",
- success: (resultst) => {
- uni.navigateBack();
- },
- });
- return Promise.reject();
- }
- },
- checkFinishRequiredCourse() {
- return this.$api
- .checkFinishRequiredCourse({
- businessId: this.goodsData.businessId,
- goodsId: this.goodsId,
- })
- .then((res) => {
- if (res.data.code == 200) {
- if (res.data.data > 0) {
- uni.showModal({
- showCancel: false,
- confirmText: "确定",
- content: "该业务层次下有未学完的商品,无法学习新商品!",
- success: function(resultst) {
- uni.navigateBack();
- },
- });
- return Promise.reject();
- }
- return Promise.resolve();
- } else {
- uni.showModal({
- showCancel: false,
- confirmText: "确定",
- content: res.data.msg,
- success: function(resultst) {
- uni.navigateBack();
- },
- });
- return Promise.reject();
- }
- })
- },
- async getGoodsDetail() {
- this.erJianErZao = this.goodsData.erJianErZao;
- this.jjShiGongYuan = this.goodsData.jjShiGongYuan;
- if (this.erJianErZao || this.jjShiGongYuan) {
- await this.userConfirmInfoDetail();
- }
- if (this.erJianErZao) {
- await this.checkFinishRequiredCourse()
- }
- this.goodsData.buyNote && this.baseHandoutTipList();
- !this.gradeId && (this.gradeId = this.goodsData.gradeId);
- if (this.goodsData.goodsPlayConfig) {
- this.goodsPlayConfig = JSON.parse(this.goodsData.goodsPlayConfig);
- if (this.goodsPlayConfig.autoPlay > 0) {
- this.autoplay = true;
- }
- if (this.goodsPlayConfig.drag > 0 && !this.erJianErZao) {
- if (this.playSource == 2) {
- this.isAllowSeek = true;
- } else {
- // #ifdef MP-WEIXIN
- this.isAllowSeek = "yes";
- // #endif
- // #ifdef H5
- this.isAllowSeek = "off";
- // #endif
- }
- }
- if (this.goodsPlayConfig.speed > 0) {
- this.playbackRate = [0.5, 0.8, 1.0, 1.25, 1.5, 2.0];
- }
- }
- if (this.goodsData.goodsPhotographConfig) {
- this.goodsPhotographConfig = JSON.parse(
- this.goodsData.goodsPhotographConfig
- );
- if (this.goodsPhotographConfig.photoNum > 0) {
- this.photoNum = this.goodsPhotographConfig.photoNum;
- }
- }
- },
- change(index) {
- this.current = index;
- },
- paramsFn(
- keys = ["orderGoodsId", "goodsId", "courseId", "gradeId", "sectionItem"]
- ) {
- return this.params(keys);
- },
- //计算录视频逻辑
- takeVideoLogic() {
- if (!this.needtoTakeVideo) return;
- if (!this.erJianErZao) return;
- let totalVideoTime = this.refPlv.getDuration();
- var duration = this.playTime;
- var durtime = totalVideoTime - duration;
- var takevideosec = this.randomNum(
- durtime > 10 ? 10 : 1,
- durtime > 310 ? durtime - 300 : durtime - 1
- ); //多少秒后执行
- clearTimeout(this.timeNeedtoTakeVideo);
- this.timeNeedtoTakeVideo = setTimeout(() => {
- this.openTakeVideo();
- }, takevideosec * 1000);
- console.log("多少秒后录制", takevideosec * 1000);
- },
- //启动录制视频
- openTakeVideo() {
- //console.log("showMedia",this.showMedia,this.showCamera)
- if (!this.needtoTakeVideo) return;
- if (this.showMedia) return;
- if (this.showCamera) {
- this.timeNeedtoTakeVideo = setTimeout(() => {
- this.openTakeVideo();
- }, 3000);
- return;
- }
- this.showMedia = true;
- console.log("showMedia2", this.showMedia, this.showCamera, "弹出录像")
- this.refPlv.playPause();
- this.refPlv.exitFullScreen();
- },
- //提交录制视频结果
- postCourseVideoRecord(videoUrl) {
- return new Promise((resolve, reject) => {
- var currentTime = this.playTime;
- let data = {
- goodsId: this.goodsId,
- gradeId: this.gradeId,
- orderGoodsId: this.orderGoodsId,
- courseId: this.courseId,
- moduleId: this.moduleId || 0,
- chapterId: this.chapterId || 0,
- sectionId: this.sectionId,
- videoUrl: videoUrl,
- videoCurrentTime: parseInt(currentTime > 0 ? currentTime : 0),
- fromPlat: 2, // 来源平台 1小程序 2PC网站 3h5
- };
- this.$api
- .courseTakeVideoRecord(data)
- .then((res) => {
- resolve(res);
- })
- .catch((err) => {
- reject();
- });
- });
- },
- //获取是否需要随机录制2秒视频
- async getCheckTakeVideo() {
- return new Promise((resolve) => {
- var data = {
- sectionId: this.sectionId,
- goodsId: this.goodsId,
- courseId: this.courseId,
- gradeId: this.gradeId,
- orderGoodsId: this.orderGoodsId,
- chapterId: this.chapterId || 0,
- moduleId: this.moduleId || 0,
- };
- this.$api.getCheckTakeVideo(data).then((res) => {
- this.needtoTakeVideo = res.data.data > 0;
- resolve();
- });
- });
- },
- async submitTakeVideo(url) {
- //上传视频
- //let file = this.$tools.convertBase64UrlToBlob(url);
- try {
- const file = new window.File([url], "video" + this.orderGoodsId.toString() + this.sectionId
- .toString() + ".mp4", {
- type: 'video/mp4',
- });
- // console.log(file, 'file')
- var videoUrl = await this.$method.uploadFileH5(file, 6, {
- gradeId: this.gradeId,
- orderGoodsId: this.orderGoodsId,
- }, "video");
- } catch (err) {
- console.log(err, "err");
- uni.showToast({
- title: "上传接口报错,请重新录制上传",
- icon: "none",
- duration: 2000,
- });
- setTimeout(() => {
- this.showMedia = true;
- }, 1500);
- return;
- }
- this.showMedia = false;
- this.postCourseVideoRecord(videoUrl)
- .then(async (res) => {
- this.needtoTakeVideo = false;
- if (this.curPlayOver) {
- await this.ended();
- }
- //恢复播放
- if (this.viewSign == 2) {
- var polyvPlayerContext = this.player_tencent;
- if (polyvPlayerContext && this.openPhotoStatus !== 1) {
- polyvPlayerContext.play();
- }
- } else {
- var polyvPlayerContext = this.player;
- if (polyvPlayerContext && this.openPhotoStatus !== 1) {
- polyvPlayerContext.j2s_resumeVideo();
- }
- }
- })
- .catch((err) => {
- console.log(err, "err");
- uni.showToast({
- title: "上传接口报错,请重新录制上传",
- icon: "none",
- duration: 2000,
- });
- setTimeout(() => {
- this.showMedia = true;
- }, 1500);
- });
- },
- },
- provide() {
- return {
- paramsFn: this.paramsFn,
- };
- },
- };
- </script>
- <style lang="scss" scope>
- @import "./css/detail.scss";
- .top {
- &__header {
- position: relative;
- width: 100%;
- height: 150rpx;
- padding: 24rpx 150rpx 24rpx 24rpx;
- .img {
- position: absolute;
- left: 0;
- top: 0;
- width: 100%;
- }
- .note {
- position: relative;
- z-index: 10;
- font-size: 24rpx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #efdbff;
- }
- .title {
- position: relative;
- z-index: 10;
- font-size: 26rpx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #ffffff;
- }
- }
- }
- #top {
- position: relative;
- z-index: 99;
- }
- .polyv_detail {
- display: flex;
- flex-direction: column;
- height: 100vh;
- position: relative;
- top: 0;
- left: 0;
- .pops {
- position: absolute;
- top: 0;
- left: 0;
- background: #ccc;
- opacity: 0.5;
- width: 100%;
- height: 300rpx;
- z-index: 9999;
- }
- .box {
- flex: 1;
- overflow: hidden;
- margin: 16rpx 16rpx 100rpx 16rpx;
- .box_in {
- height: 100%;
- }
- }
- .first_ml {
- margin: 16rpx 16rpx 16rpx 16rpx;
- }
- }
- .title {
- font-size: 24rpx;
- color: #999999;
- }
- page {
- background: #eaeef1;
- }
- .ts {
- font-size: 24rpx;
- color: #999;
- margin: 14rpx 0rpx;
- padding-right: 29rpx;
- padding-left: 34rpx;
- }
- .content {
- padding: 24rpx;
- text-align: left;
- }
- .sc_t {
- font-size: 22rpx;
- color: #000000;
- }
- .sc {
- width: 29rpx;
- height: 29rpx;
- }
- .buy {
- width: 138rpx;
- height: 48rpx;
- line-height: 48rpx;
- background: #32467b;
- border-radius: 10rpx;
- color: #ffffff;
- font-size: 28rpx;
- text-align: center;
- vertical-align: middle;
- position: absolute;
- right: 30rpx;
- }
- .video_body {
- padding-bottom: 96rpx;
- }
- .tj_box {
- width: 50%;
- display: inline-block;
- text-align: center;
- margin: 10rpx 0;
- }
- .t2 {
- font-size: 24rpx;
- font-family: PingFang SC;
- color: #666666;
- line-height: 36rpx;
- margin: 15rpx;
- }
- .r_t2 {
- width: 201rpx;
- height: 49rpx;
- background: rgba(22, 119, 255, 0.05);
- border: 1rpx solid #32467b;
- border-radius: 16rpx;
- color: #666666;
- font-size: 23rpx;
- text-align: center;
- display: flex;
- align-items: center;
- padding: 5rpx;
- }
- .scroll_box {
- width: 100%;
- height: 60rpx;
- background: #ffffff;
- box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(145, 156, 178, 0.1);
- white-space: nowrap;
- overflow: hidden;
- margin: 15rpx 0;
- }
- .r_sliper {
- padding: 0 20rpx;
- }
- .top_line {
- width: 6rpx;
- height: 22rpx;
- background: #32467b;
- margin-right: 10rpx;
- }
- .video_t2 {
- font-size: 24rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #666666;
- }
- .video_play {
- position: absolute;
- width: 95rpx;
- height: 95rpx;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- margin: auto;
- }
- .video_box {
- position: relative;
- }
- .slot-content {
- padding: 0 20rpx;
- }
- .notice_modal {
- .content {
- width: 100%;
- height: 100%;
- padding: 56rpx 56rpx 56rpx 64rpx;
- .title {
- color: #222;
- line-height: 40rpx;
- font-size: 36rpx;
- text-align: center;
- font-weight: bold;
- margin-bottom: 24rpx;
- }
- .text {
- height: 340rpx;
- line-height: 40rpx;
- text-indent: 2em;
- font-size: 32rpx;
- color: #222;
- }
- .had_read {
- width: 100%;
- height: 88rpx;
- line-height: 88rpx;
- text-align: center;
- background: #3577e8;
- border-radius: 240rpx;
- font-size: 32rpx;
- font-weight: 500;
- color: #fff;
- margin-top: 20rpx;
- &.gray {
- background: #bbbec5;
- }
- }
- }
- }
- </style>
|