detail.vue 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933
  1. <template>
  2. <view>
  3. <view style="position: fixed;width: 100%;z-index: 999;background: #FFFFFF;top: 0;" id="top">
  4. <view class="video_box" v-if="!startStatus">
  5. <image :src="$method.splitImgHost(detail.coverUrl)" style="width: 100%;height: 460rpx;"></image>
  6. <image v-if="false" class="video_play" src="/static/play.png" @click="startVideo"></image>
  7. </view>
  8. <view v-else>
  9. <view class="video_box" style="width: 100%;height: 460rpx;" v-if="playVID">
  10. <polyv-player
  11. id="playerVideo"
  12. playerId="playerVideo"
  13. height="460rpx"
  14. :vid="vid"
  15. :showSettingBtn="true"
  16. :enablePlayGesture="true"
  17. @statechange="onStateChange"
  18. :autoplay="autoplay"
  19. :isAllowSeek="isAllowSeek"
  20. :playbackRate="playbackRate"
  21. :startTime="startTime"
  22. ></polyv-player>
  23. </view>
  24. <view class="video_box" style="width: 100%;height: 460rpx;" v-if="playChannelId>0">
  25. <player
  26. class="plv-mp-demo-player"
  27. :videoOption="videoOption"
  28. @onLiveStatusChange="playerLiveStatusChange"
  29. />
  30. </view>
  31. </view>
  32. <view>
  33. <u-row>
  34. <u-col span="10">
  35. <view class="video_t1">{{ detail.courseName }}</view>
  36. </u-col>
  37. <u-col span="2" v-if="false">
  38. <view class="video_t1_t" @click="openJY">
  39. <image src="/static/icon/jy_icon.png" style="width: 40rpx;height: 40rpx;"></image>
  40. 讲义
  41. </view>
  42. </u-col>
  43. </u-row>
  44. </view>
  45. <u-line color="#D6D6DB" />
  46. <view>
  47. <view><u-tabs gutter="0" :item-width="itemWidth()" :list="list" font-size="32" bar-width="24" :current="current" @change="change" active-color="#007AFF"></u-tabs></view>
  48. </view>
  49. <u-line color="#D6D6DB" />
  50. </view>
  51. <view class="box">
  52. <!--目录 -->
  53. <view v-show="current == 0">
  54. <view class="menuBox" v-for="(item, index) in menuList" :key="index">
  55. <!--模块 -->
  56. <view v-if="item.type == 1"><courseModule :courseId="courseId" :learningOrder="businessData.goodsLearningOrder" :goodsId="goodsId" :gradeId="gradeId" :isBuy="true" :menuItem="item" :levelId="item.menuId"></courseModule></view>
  57. <!--章 -->
  58. <view v-if="item.type == 2"><courseChapter :courseId="courseId" :learningOrder="businessData.goodsLearningOrder" :goodsId="goodsId" :gradeId="gradeId" :isBuy="true" :menuItem="item" :levelId="'0-' + item.menuId"></courseChapter></view>
  59. <!--节 -->
  60. <view v-if="item.type == 3"><courseSection @playEnd="sectionPlayEnd(index)" :courseId="courseId" :goodsId="goodsId" :gradeId="gradeId" :isBuy="true" :menuItem="item" :levelId="'0-0-' + item.menuId"></courseSection></view>
  61. </view>
  62. </view>
  63. <!--讲义 -->
  64. <view v-show="current == 1">
  65. <view class="lecture-box" v-if="courseHandoutsData">
  66. <view class="title">
  67. {{courseHandoutsData.handoutsName}}
  68. <!-- 这是后台配置的讲义标题过长省略这是后台配置的讲义标题过长省略 -->
  69. </view>
  70. <view class="btn" @click="openDocument">
  71. <u-icon name="download" color="#007AFF" size="40"></u-icon>
  72. </view>
  73. </view>
  74. <view style="text-align: center;" v-else>暂无讲义</view>
  75. <!-- <view class="lecture-content">
  76. <rich-text :nodes="'讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容讲义内容'"></rich-text>
  77. </view> -->
  78. <!-- <view class="inputBottom">
  79. <view style="width: 10%;"><image src="/static/icon/note3.png" style="width: 39rpx;height: 39rpx;margin:0 29rpx;"></image></view>
  80. <view style="width: 73%;height: 100%;padding: 10rpx 0;">
  81. <u-input class="input" height="60" fixed="true" placeholder="您可以在这里输入笔记内容" type="textarea" :custom-style="inputStyle" v-model="noteValue" />
  82. </view>
  83. <view style="color: #007AFF;font-size: 30rpx;font-weight: bold;width: 15%;text-align: center;" @click="postNote">提交</view>
  84. </view> -->
  85. </view>
  86. <!--笔记 -->
  87. <view v-show="current == 2">
  88. <view v-if="noteList.length == 0" style="text-align: center;">暂无笔记</view>
  89. <view class="inputBottom">
  90. <view style="width: 10%;"><image src="/static/icon/note3.png" style="width: 39rpx;height: 39rpx;margin:0 29rpx;"></image></view>
  91. <view style="width: 73%;height: 100%;padding: 10rpx 0;">
  92. <u-input class="input" height="60" fixed="true" placeholder="您可以在这里输入笔记内容" type="textarea" :custom-style="inputStyle" v-model="noteValue" />
  93. </view>
  94. <view style="color: #007AFF;font-size: 30rpx;font-weight: bold;width: 15%;text-align: center;" @click="postNote">提交</view>
  95. </view>
  96. <view v-for="(item, index) in noteList" :key="index">
  97. <view class="dateBox">{{ $method.timestampToTime(item.dateNote) }}</view>
  98. <view class="noteBox">
  99. <view v-for="(item1, index1) in item.userNotes" :key="index1" style="margin-top: 30rpx;" @click="jumpNote(item1)">
  100. <view style="display: flex;">
  101. <view>
  102. <view>
  103. <image src="/static/icon/note2.png" v-if="noteId != item1.noteId" style="width: 39rpx;height: 39rpx;margin:0 29rpx;"></image>
  104. <image src="/static/icon/note1.png" v-if="noteId == item1.noteId" style="width: 39rpx;height: 39rpx;margin:0 29rpx;"></image>
  105. </view>
  106. <view class="title" style="width: 39rpx;height: 39rpx;margin:0 29rpx;">{{ $method.secondToDate(item1.noteSecond) }}</view>
  107. </view>
  108. <view style="margin-left: 10rpx;">
  109. <view class="t2Content leftPadding">{{ item1.sectionName }}</view>
  110. <view class="tBox2">{{ item1.noteText }}</view>
  111. </view>
  112. </view>
  113. </view>
  114. </view>
  115. </view>
  116. </view>
  117. <!--答疑 -->
  118. <view v-show="current == 3">
  119. <view class="inputBottom">
  120. <view class="flex_auto">
  121. <u-input height="60" fixed="true" :placeholder="placeholder" type="textarea" :custom-style="inputStyle" v-model="ctxValue" />
  122. </view>
  123. <view class="btn" @click="postContent">提交</view>
  124. </view>
  125. <view v-for="(item, index) in answerList" :key="index" style="background-color: #FFFFFF;margin-bottom: 20rpx;">
  126. <view class="chat_box" @click.stop="clearCtx">
  127. <view style="display: flex;">
  128. <view><image :src="$method.splitImgHost(item.avatar)" style="width: 64rpx;height: 64rpx;"></image></view>
  129. <view style="margin-left: 15rpx;">
  130. <view class="chat1">{{ item.realname }}</view>
  131. <view class="chat2">{{ $method.timestampToTime(item.createTime) }}</view>
  132. <view class="chat3">
  133. <text v-if="item.assignUserId > 0">回复</text>
  134. <text v-if="item.assignUserId > 0" style="color: #007AFF;">@{{ item.assignRealname }}</text>
  135. {{ item.answerText }}
  136. </view>
  137. </view>
  138. </view>
  139. <view class="btnReply" @click.stop="replyContent(item)" v-if="item.userId != userInfo.userId">回复</view>
  140. <view v-else class="btnDel" @click.stop="delContent(item)">删除</view>
  141. </view>
  142. <u-line color="#D6D6DB" />
  143. </view>
  144. <view v-if="answerList.length == 0" style="text-align: center;">暂无记录</view>
  145. </view>
  146. <!--目录 -->
  147. <view v-show="current == 4" >
  148. <view class="menuBox" v-for="(item, index) in reMenuList" :key="index">
  149. <!--模块 -->
  150. <view v-if="item.type == 1"><courseModule :courseId="courseId" :goodsId="goodsId" :gradeId="gradeId" :isRebuild="true" :isBuy="true" :menuItem="item" :levelId="item.menuId"></courseModule></view>
  151. <!--章 -->
  152. <view v-if="item.type == 2">
  153. <courseChapter :courseId="courseId" :gradeId="gradeId" :goodsId="goodsId" :isRebuild="true" :isBuy="true" :menuItem="item" :levelId="'0-' + item.menuId"></courseChapter>
  154. </view>
  155. <!--节 -->
  156. <view v-if="item.type == 3">
  157. <courseSection :courseId="courseId" :gradeId="gradeId" :goodsId="goodsId" :isRebuild="true" :isBuy="true" :nextMenuItem="findMenuNextSection(index)" :menuItem="item" :levelId="'0-0-' + item.menuId"></courseSection>
  158. </view>
  159. </view>
  160. </view>
  161. </view>
  162. <!-- 播放前拍照end -->
  163. <u-popup v-model="showSet" :mask-close-able="false" mode="center" border-radius="24">
  164. <view style="align-items:center;padding: 0 40rpx;display: flex;flex-direction: column;justify-content:center;">
  165. <view style="font-weight: bold;color: #333333;font-size: 30rpx;margin-top: 30rpx;">温馨提示</view>
  166. <view style="width: 457rpx;color: #666666;font-size: 30rpx;margin-top: 30rpx;">学习过程中需要拍照验证学员身份,
  167. 拍照功能需要使用您的相机。
  168. 是否授权使用?</view>
  169. <view style="margin: 40rpx 0;">
  170. <button open-type="openSetting" @bindopensetting="openSetting" class="btnSet">去授权</button>
  171. </view>
  172. </view>
  173. </u-popup>
  174. <u-mask :show="photoPopup" >
  175. <!-- 播放前拍照start -->
  176. <view v-if="photoPopup" :mask-close-able="false" style="bottom: 0;position: fixed;width: 100%;z-index: 999;">
  177. <view class="photoBox">
  178. <view class="photoTop">
  179. <view class="sqzz" v-if="false"><u-icon name="close" color="#333333" size="30" @click="closePhoto"></u-icon></view>
  180. <view class="centersq">请正视手机屏幕</view>
  181. <view class="sqzz"></view>
  182. </view>
  183. <view class="photoCenter">
  184. <view style="width: 100%; height: 979rpx;position: fixed;" v-if="photoPopup">
  185. <camera device-position="front" flash="off" @error="error" style="width: 100%; height: 100%;" ></camera>
  186. </view>
  187. <view class="custom"><image src="/static/zhezhao.png" mode=""></image></view>
  188. </view>
  189. <view class="btnResult" @click="takePhoto">拍照</view>
  190. </view>
  191. </view>
  192. </u-mask>
  193. </view>
  194. </template>
  195. <script>
  196. import plv from '../static/polyv-sdk/index';
  197. import courseModule from '@/components/course/courseModule.vue';
  198. import courseChapter from '@/components/course/courseChapter.vue';
  199. import courseSection from '@/components/course/courseSection.vue';
  200. import { mapGetters } from 'vuex';
  201. export default {
  202. components: {
  203. courseModule,
  204. courseChapter,
  205. courseSection
  206. },
  207. data() {
  208. return {
  209. initLiveOk:false,
  210. livePlay:false, //是否正在播放直播,不含暂停
  211. liveDuration:0, //直播观看时长
  212. videoOption:{
  213. mode: 'live',
  214. uid: '',
  215. cid: '',
  216. openId: '',
  217. isAutoChange: false,
  218. forceVideo: false,
  219. },
  220. courseHandoutsData:'',
  221. liveDetail:{},
  222. showSet:false,
  223. startStatus: false,
  224. detail: {},
  225. courseId: 0,
  226. placeholder: '您可以在这里输入笔记内容\n还可以点击左侧图标为笔记加上时间标记',
  227. inputStyle: {
  228. background: 'rgba(244, 244, 244, 0.98)',
  229. borderRadius: '24rpx',
  230. padding: '8rpx',
  231. marginBottom: '10rpx'
  232. },
  233. list: [],
  234. menuList: [],
  235. current: 0,
  236. vid: '',
  237. goodsId: 0,
  238. goodsData: {},
  239. photoPopup: false,
  240. goodsPlayConfig: null,
  241. autoplay: false,
  242. isAllowSeek: 'no',
  243. playbackRate: [1.0],
  244. timer: null,
  245. goodsPhotographConfig: null,
  246. intervalTimeList: [], // 间隔拍照时长
  247. intervalTimeIndex: 0, //当前处于哪个时间段拍照
  248. playTime: 0, //页面播放时长,不含暂停
  249. currentTime: 0,
  250. avatarUrl: '',
  251. ossAvatarUrl: '',
  252. studyDuration: 0, // 当前视频时长
  253. gradeId: 0,
  254. chapterId: 0,
  255. moduleId: 0,
  256. reMenuList: [],
  257. answerList: [],
  258. assignUserId: 0,
  259. placeholder: '您可以在这里输入答疑内容',
  260. ctxValue: '',
  261. noteList: [],
  262. noteValue: '',
  263. noteId: 0,
  264. recordObj: 0,
  265. gradeDetail:{},
  266. needSeek: false, //第一次播放是否需要跳转
  267. needProfileModal:false, //是否需要资料审核弹框
  268. liveObj:{},
  269. photoNum:0,
  270. photoList:[], //拍照的时间点
  271. photoConfig:false, //是否配置好拍照次数
  272. photoIndex:0, //当前位于拍照的区间下标 从0开始
  273. photoHistoryList:[], //已拍照历史的下标点
  274. businessData:{},
  275. };
  276. },
  277. computed: { ...mapGetters(['userInfo', 'playSectionId','playChannelId','playVID']) },
  278. onLoad(option) {
  279. this.courseId = Number(option.id);
  280. this.goodsId = Number(option.goodsId);
  281. this.courseDetail();
  282. this.getGoodsDetail();
  283. this.getAnswerList();
  284. let noteSecond = Number(option.noteSecond);
  285. if(noteSecond>0){
  286. //我的消息跳过来,播放节
  287. let item = {
  288. sectionId:Number(option.sectionId),
  289. recordingUrl:option.recordingUrl,
  290. noteSecond:noteSecond
  291. }
  292. this.$store.commit('setPlaySectionId', {playSectionId :item.sectionId});
  293. this.playNoteVideo(item);
  294. }
  295. },
  296. onShow() {
  297. var self = this;
  298. //相机授权
  299. this.getCameraSetting()
  300. this.$api.getbaseprofiletplists({ goodsId: self.goodsId }).then(res => {
  301. console.log(res,'res')
  302. if (res.data.code === 200 && res.data.rows.length) {
  303. if (res.data.rows[0].keyValue) {
  304. self.$api.getbaseprofiletpgetInfo({ goodsId: self.goodsId }).then(result => {
  305. console.log(result,'result')
  306. if (result.data.code === 200) {
  307. if (!result.data.data || (result.data.data.status === 3 && result.data.data.changeStatus === 1)) {
  308. if (!result.data.data) {
  309. self.needProfileModal = true
  310. uni.showModal({
  311. content: '请前往填写资料',
  312. cancelText: '返回',
  313. success: function(resultst) {
  314. if (resultst.confirm) {
  315. self.$navTo.togo('/pages2/verify/input', {
  316. id: self.goodsId
  317. });
  318. }
  319. if (resultst.cancel) {
  320. uni.navigateBack();
  321. }
  322. }
  323. });
  324. } else {
  325. self.needProfileModal = true
  326. uni.showModal({
  327. content: '资料审核不通过,请前往重新填写',
  328. cancelText: '返回',
  329. success: function(resultst) {
  330. if (resultst.confirm) {
  331. self.$navTo.togo('/pages2/verify/input', {
  332. id: self.goodsId
  333. });
  334. }
  335. if (resultst.cancel) {
  336. uni.navigateBack();
  337. }
  338. }
  339. });
  340. }
  341. } else if (result.data.data.status === 1 && JSON.parse(res.data.rows[0].keyValue2)[0]) {
  342. self.$api.getbaseprofileStampgetInfo({ goodsId: self.goodsId }).then(k => {
  343. if (k.data.code === 200) {
  344. if (!k.data.data || (k.data.data.status === 3 && k.data.data.changeStatus === 1)) {
  345. if (!k.data.data) {
  346. self.needProfileModal = true
  347. uni.showModal({
  348. cancelText: '返回',
  349. content: '请前往填写盖章资料',
  350. success: function(resultst) {
  351. if (resultst.confirm) {
  352. self.$navTo.togo('/pages2/verify/input2', {
  353. id: self.goodsId
  354. });
  355. }
  356. if (resultst.cancel) {
  357. uni.navigateBack();
  358. }
  359. }
  360. });
  361. } else {
  362. self.needProfileModal = true
  363. uni.showModal({
  364. cancelText: '返回',
  365. content: '资料盖章审核不通过,请前往重新填写',
  366. success: function(resultst) {
  367. if (resultst.confirm) {
  368. self.$navTo.togo('/pages2/verify/input2', {
  369. id: self.goodsId
  370. });
  371. }
  372. if (resultst.cancel) {
  373. uni.navigateBack();
  374. }
  375. }
  376. });
  377. }
  378. }
  379. }
  380. });
  381. }
  382. }
  383. });
  384. }
  385. }
  386. });
  387. console.log(this.gradeId,7512)
  388. if(this.gradeId>0){
  389. //提交完资料返回判断是否已开班
  390. this.getGradeInfo()
  391. }
  392. },
  393. onUnload() {
  394. if (this.playSectionId > 0) {
  395. //退出提交记录
  396. this.postStudyRecord();
  397. }
  398. //清除正在播放的节ID
  399. this.$store.commit('setPlaySectionId', { playSectionId: 0 });
  400. this.$store.commit('setPlayChannelId', { playChannelId: 0 });
  401. this.$store.commit('setPlayVID', { playVID: null });
  402. this.closePlv()
  403. console.log('onUnload')
  404. //移除所有的事件监听器
  405. uni.$off();
  406. if (this.timer) {
  407. clearInterval(this.timer);
  408. }
  409. },
  410. mounted() {
  411. uni.$on('changeSection', oldSectionId => {
  412. console.log(this.playVID)
  413. this.photoConfig = false
  414. this.photoIndex = 0
  415. var polyvPlayerContext = this.selectComponent('#playerVideo');
  416. if(polyvPlayerContext){
  417. //解决同个节视频切换问题
  418. polyvPlayerContext.pause();
  419. }
  420. //清除直播
  421. this.$store.commit('setPlayChannelId', { playChannelId: 0 });
  422. this.postStudyRecord(0, oldSectionId);
  423. });
  424. uni.$on('getSection', item => {
  425. //清除直播
  426. this.photoConfig = false
  427. this.photoIndex = 0
  428. this.$store.commit('setPlayChannelId', { playChannelId: 0 });
  429. //获取拍照历史
  430. this.getPhotoLastRecord()
  431. this.playVideo(item);
  432. });
  433. uni.$on('levelId', item => {
  434. let arr = item.split('-');
  435. //点击节获取的各层级ID
  436. this.moduleId = arr[0];
  437. this.chapterId = arr[1];
  438. });
  439. uni.$on('getChannel', item => {
  440. //清除录播
  441. this.$store.commit('setPlayVID', {playVID :null});
  442. this.playChannel(item);
  443. });
  444. },
  445. methods: {
  446. /**
  447. * 模块大节播放完毕,刷新列表
  448. */
  449. sectionPlayEnd(index) {
  450. console.log('sectionPlayEnd')
  451. this.$api.reMenuList({ courseId: this.courseId, gradeId: this.gradeId }).then(res => {
  452. if (res.data.code == 200) {
  453. res.data.rows[index].name = res.data.rows[index].menuName;
  454. this.$set(this.menuList,index,res.data.rows[index])
  455. }
  456. });
  457. },
  458. /**
  459. * 获取业务层次详情
  460. */
  461. courseBusiness(){
  462. this.$api.courseBusiness(this.goodsData.businessId).then(res => {
  463. this.businessData = res.data.data;
  464. })
  465. },
  466. /**
  467. * 计算tabs宽度
  468. */
  469. itemWidth() {
  470. return 100/this.list.length + '%'
  471. },
  472. /**
  473. * 获取讲义权限
  474. */
  475. courseHandouts() {
  476. this.$api.courseHandouts(this.goodsData.handoutsId).then(res => {
  477. this.courseHandoutsData = res.data.data
  478. })
  479. },
  480. findMenuNextSection(index){
  481. for(let i=index+1;i<this.reMenuList.length;i++){
  482. let item = this.reMenuList[i]
  483. if(item.type==3){
  484. return item;
  485. }
  486. }
  487. return {}
  488. },
  489. getPhotoLastRecord() {
  490. let self = this;
  491. let data = {
  492. sectionId: parseInt(self.playSectionId),
  493. goodsId: parseInt(self.goodsId),
  494. courseId: parseInt(self.courseId),
  495. gradeId: parseInt(self.gradeId),
  496. chapterId: parseInt(self.chapterId),
  497. moduleId: parseInt(self.moduleId)}
  498. this.$api.getPhotoLastRecord(data).then(res => {
  499. if(res.data.code==200){
  500. //清空历史数据
  501. self.photoHistoryList = []
  502. this.photoIndex = 0
  503. self.photoList = []
  504. for(let i=0;i<res.data.data.length;i++){
  505. //-2存储随机拍照数组
  506. if(res.data.data[i].photoIndex==-2){
  507. self.photoList = res.data.data[i].timeInterval.split(',')
  508. }else{
  509. self.photoHistoryList.push(res.data.data[i].photoIndex)
  510. }
  511. }
  512. }
  513. });
  514. },
  515. //postTime 只提交随机时间
  516. postCoursePhotoRecord(postTime=false) {
  517. let currentTime = 0;
  518. var polyvPlayerContext = this.selectComponent('#playerVideo');
  519. if (polyvPlayerContext) {
  520. currentTime = polyvPlayerContext.getCurrentTime();
  521. }
  522. let self = this;
  523. let photoIndex = self.photoIndex-1
  524. let data = {
  525. photo: self.ossAvatarUrl,
  526. sectionId: parseInt(self.playSectionId),
  527. goodsId: parseInt(self.goodsId),
  528. courseId: parseInt(self.courseId),
  529. photoTime: parseInt(currentTime > 0 ? currentTime : 0),
  530. gradeId: parseInt(self.gradeId),
  531. photoIndex: postTime?-2:parseInt(photoIndex),//从0算起,-2只提交随机时间
  532. photoNum:parseInt(self.photoNum),
  533. chapterId: parseInt(self.chapterId),
  534. moduleId: parseInt(self.moduleId),
  535. timeInterval: postTime?self.photoList.join(','):''
  536. };
  537. console.log('提交接口', data);
  538. this.$api.coursePhotoRecord(data).then(res => {
  539. console.log(res);
  540. });
  541. },
  542. randomNum(minNum,maxNum){
  543. switch(arguments.length){
  544. case 1:
  545. return parseInt(Math.random()*minNum+1,10);
  546. break;
  547. case 2:
  548. return parseInt(Math.random()*(maxNum-minNum+1)+minNum,10);
  549. break;
  550. default:
  551. return 0;
  552. break;
  553. }
  554. },
  555. //配置随机拍照时间
  556. configPhoto(){
  557. var polyvPlayerContext = this.selectComponent('#playerVideo');
  558. let totalVideoTime = polyvPlayerContext.getDuration()
  559. let duration = polyvPlayerContext.getCurrentTime()
  560. let photoNum = this.photoNum
  561. if(!this.photoConfig){
  562. this.photoConfig = true
  563. let spaceTime = Math.floor(totalVideoTime/photoNum) //拍照时间区间
  564. if(spaceTime<5){//区间小于5秒
  565. photoNum = Math.floor(totalVideoTime/5)
  566. spaceTime = 5
  567. }
  568. if(photoNum<1){
  569. photoNum = 1 //只要设置,至少拍一次
  570. spaceTime = totalVideoTime
  571. }
  572. let initSpace = 0
  573. //没有历史拍照间隔数据
  574. if(this.photoList.length==0){
  575. for(let i=0;i<photoNum;i++){
  576. let s = this.randomNum(initSpace,initSpace+spaceTime)
  577. if(s>totalVideoTime){
  578. s = totalVideoTime-1
  579. }
  580. if(s<=5){
  581. s =5 //避免出现5秒内拍照时间
  582. }
  583. this.photoList.push(s)
  584. initSpace+=spaceTime
  585. }
  586. console.log(this.photoList,"随机拍照时间数组11",photoNum,initSpace,spaceTime)
  587. this.postCoursePhotoRecord(true)//提交随机拍照时间数组
  588. }
  589. console.log(this.photoList,"随机拍照时间数组")
  590. //兼容已有观看历史
  591. for(let i=0;i<this.photoList.length-1;i++){
  592. if(this.photoList[i]<duration&&this.photoList[i+1]>duration){
  593. this.photoIndex = i+1
  594. // console.log("我的修改了photoIndex")
  595. break
  596. }
  597. if(duration>this.photoList[this.photoList.length-1]){
  598. this.photoIndex = this.photoList.length-1 //取最后一个下标
  599. // console.log("我的修改了photoIndex")
  600. break
  601. }
  602. }
  603. }
  604. },
  605. getLiveUid(channelId) {
  606. let self = this;
  607. return new Promise(resolve => {
  608. let data = {
  609. channelId: channelId
  610. };
  611. self.$api.polyvSign(data).then(res => {
  612. resolve(res.data.data);
  613. });
  614. });
  615. },
  616. timeEventLiving() {
  617. if (plv != null) {
  618. if(this.livePlay){
  619. this.liveDuration = this.liveDuration +1 //每隔1秒
  620. if(this.liveDuration==2){ //直播第2秒拍照
  621. if(this.goodsPhotographConfig){
  622. if(this.goodsPhotographConfig.livephotograph==1){
  623. //开启直播拍照
  624. this.openPhoto();
  625. }
  626. }
  627. }
  628. }
  629. }
  630. },
  631. playerLiveStatusChange(e) {
  632. const status = e.detail.status;
  633. console.log('直播状态',status);
  634. if (status === 'live') {
  635. console.log('开始直播');
  636. //开始播放
  637. if (this.timer) {
  638. clearInterval(this.timer);
  639. }
  640. this.livePlay = true
  641. this.timer = setInterval(this.timeEventLiving, 1000); //定时器
  642. }
  643. if (status === 'end') {
  644. if(this.livePlay){
  645. //只有播放过的结束才提交,避免未开播触发结束
  646. this.postStudyRecord(1);
  647. }
  648. console.log('结束直播');
  649. this.livePlay = false
  650. // 未开始
  651. }
  652. },
  653. closePlv(){
  654. if(plv){
  655. plv.destroy();
  656. }
  657. },
  658. playChannel(item){
  659. if (this.timer) {
  660. clearInterval(this.timer);
  661. }
  662. this.startStatus = true
  663. this.initLive()
  664. },
  665. setLiveOption(status) {
  666. const { userId, channelId, recordFileSimpleModel, playbackEnabled } = this.detail;
  667. const playRecordFile = playbackEnabled && recordFileSimpleModel && status === 'end';
  668. this.videoOption = {
  669. mode: 'live',
  670. uid: this.liveObj.uid, //this.playChannelId egsxlptzdq
  671. cid: this.playChannelId,
  672. openId: this.userInfo.userAccount,
  673. isAutoChange: false,
  674. forceVideo: false,
  675. }
  676. },
  677. async initLive(){
  678. console.log(this.playChannelId,7111)
  679. this.liveObj = await this.getLiveUid(this.playChannelId);
  680. this.initLiveOk = true
  681. let optionsData = {}
  682. optionsData.mode = 'live';
  683. optionsData.forceVideo = false;
  684. optionsData.channelId = this.playChannelId; // 频道ID '2553128'
  685. optionsData.openId = this.userInfo.userAccount; // 用户openId this.userInfo.userAccount 'oQ5eX5BCtSjkE1ct8CzvxGWgh0hQ'
  686. optionsData.userId = this.liveObj.uid // 2.0.0及以上版本的demo需要使用 userId 设置学员唯一id 'egsxlptzdq'
  687. let self = this
  688. this.closePlv()
  689. plv.init(optionsData)
  690. .then(({ detail, chat }) => {
  691. self.liveDetail = detail
  692. // 设置mode为live的videoOption
  693. this.setLiveOption();
  694. if (detail.isPPT) {
  695. chat.on(chat.events.SLICESTART, () => {
  696. // 开始直播
  697. });
  698. } else {
  699. plv.api.getOrdinaryLiveStatus(detail.stream);
  700. }
  701. });
  702. },
  703. openSetting(res){
  704. console.log(res,98)
  705. },
  706. getCameraSetting () {
  707. const self = this
  708. wx.getSetting({
  709. success: res => {
  710. if (res.authSetting['scope.camera']) {
  711. // 用户已经授权
  712. self.showSet = false
  713. } else {
  714. // 用户还没有授权,向用户发起授权请求
  715. wx.authorize({
  716. scope: 'scope.camera',
  717. success() { // 用户同意授权
  718. self.showSet = false
  719. },
  720. fail() { // 用户不同意授权
  721. self.showSet = true
  722. /* wx.showToast({
  723. title: '摄像头授权失败',
  724. icon: 'none',
  725. duration: 3000
  726. }) */
  727. }
  728. })
  729. }
  730. },
  731. fail: res => {
  732. }
  733. })
  734. },
  735. openJY(){
  736. this.$u.toast('此功能正在开发中');
  737. },
  738. //播放笔记视频
  739. async playNoteVideo(item) {
  740. if (this.timer) {
  741. clearInterval(this.timer);
  742. }
  743. if (this.vid) {
  744. //切换视频
  745. var polyvPlayerContext = this.selectComponent('#playerVideo');
  746. polyvPlayerContext.changeVid(item.recordingUrl);
  747. } else {
  748. this.vid = item.recordingUrl;
  749. }
  750. this.recordObj = {videoCurrentTime:item.noteSecond}
  751. if (this.recordObj.studyDuration) {
  752. this.needSeek = true; //需要跳转到播放记录
  753. }
  754. this.startStatus = true;
  755. //获取节笔记
  756. this.getNoteList();
  757. },
  758. //正常播放视频
  759. async playVideo(item) {
  760. if (this.timer) {
  761. clearInterval(this.timer);
  762. }
  763. if (this.vid) {
  764. //切换视频
  765. var polyvPlayerContext = this.selectComponent('#playerVideo');
  766. polyvPlayerContext.changeVid(item.recordingUrl);
  767. } else {
  768. this.vid = item.recordingUrl;
  769. }
  770. this.recordObj = null
  771. this.recordObj = await this.getRecordLast();
  772. this.needSeek = true; //跳转到播放记录
  773. this.startStatus = true;
  774. //获取节笔记
  775. this.getNoteList();
  776. },
  777. getRecordLast() {
  778. let self = this;
  779. return new Promise(resolve => {
  780. let data = {
  781. gradeId: Number(self.gradeId),
  782. goodsId: Number(self.goodsId),
  783. sectionId: Number(self.playSectionId),
  784. courseId: Number(self.courseId),
  785. chapterId: parseInt(self.chapterId),
  786. moduleId: parseInt(self.moduleId)
  787. };
  788. self.$api.recordLast(data).then(res => {
  789. resolve(res.data.data);
  790. });
  791. });
  792. },
  793. jumpNote(item) {
  794. this.noteId = item.noteId;
  795. //没视频播放
  796. if(this.playSectionId==0){
  797. this.$u.toast('即将跳到笔记位置');
  798. this.$store.commit('setPlaySectionId', {playSectionId :item.sectionId});
  799. this.playNoteVideo(item);
  800. }else{
  801. //正在看当前笔记视频
  802. this.$u.toast('即将跳到笔记位置');
  803. //跳到笔记时刻
  804. var polyvPlayerContext = this.selectComponent('#playerVideo');
  805. polyvPlayerContext.seek(item.noteSecond);
  806. polyvPlayerContext.play();
  807. }
  808. },
  809. postNote() {
  810. let self = this;
  811. if (!(this.playSectionId > 0)) {
  812. this.$u.toast('目前无播放视频');
  813. return;
  814. }
  815. if (!this.noteValue) {
  816. this.$u.toast('请输入内容');
  817. return;
  818. }
  819. if(!this.gradeId){
  820. this.$u.toast('暂无班级数据');
  821. return;
  822. }
  823. var polyvPlayerContext = this.selectComponent('#playerVideo');
  824. let noteDate = this.$method.getZeroTime();
  825. let noteSecond = polyvPlayerContext.getCurrentTime();
  826. console.log(noteSecond,698)
  827. if (!noteSecond) {
  828. if(noteSecond==0){
  829. //播放结束
  830. noteSecond = polyvPlayerContext.getDuration();
  831. console.log(noteSecond,63398)
  832. }
  833. if(!noteSecond){
  834. this.$u.toast('视频暂未开始');
  835. return;
  836. }
  837. }
  838. let data = {
  839. gradeId: this.gradeId,
  840. goodsId: this.goodsId,
  841. sectionId: this.playSectionId,
  842. courseId: this.courseId,
  843. noteText: this.noteValue,
  844. noteDate: noteDate,
  845. noteSecond: noteSecond
  846. };
  847. this.$api.postNote(data).then(res => {
  848. if (res.data.code == 200) {
  849. this.$u.toast('发布成功');
  850. self.getNoteList();
  851. this.noteValue = '';
  852. }
  853. });
  854. },
  855. getGradeInfo() {
  856. let self = this;
  857. this.$store.state.allowLoading = false;
  858. this.$api.goodsGradeInfo(this.gradeId).then(res => {
  859. if (res.data.code == 200) {
  860. self.gradeDetail = res.data.data;
  861. if(self.needProfileModal){
  862. return
  863. }
  864. if(self.gradeDetail.learningStatus==2){
  865. uni.showModal({
  866. showCancel:false,
  867. cancelText: '返回',
  868. content: '当前课程正在申请中,请耐心等待',
  869. success: function(resultst) {
  870. uni.navigateBack();
  871. }
  872. });
  873. }
  874. if(self.gradeDetail.learningStatus==3&&(Number(self.gradeDetail.learningTimeStart)>Number((new Date())/1000))){
  875. uni.showModal({
  876. showCancel:false,
  877. cancelText: '返回',
  878. content: '当前课程正在申请中,请耐心等待',
  879. success: function(resultst) {
  880. uni.navigateBack();
  881. }
  882. });
  883. }
  884. }
  885. });
  886. this.$store.state.allowLoading = true;
  887. },
  888. getNoteList() {
  889. let self = this;
  890. self.noteList = [];
  891. let data = { courseId: this.courseId, gradeId: this.gradeId, goodsId: this.goodsId }
  892. if(this.playSectionId>0){
  893. data.sectionId = this.playSectionId
  894. }
  895. this.$api.noteList(data).then(res => {
  896. if (res.data.code == 200) {
  897. self.noteList = res.data.rows;
  898. }
  899. });
  900. },
  901. delAnswer(answerId) {
  902. let self = this;
  903. let data = { answerId: answerId, status: -1 };
  904. this.$api.delAnswer(data).then(res => {
  905. if (res.data.code == 200) {
  906. self.getAnswerList();
  907. }
  908. });
  909. },
  910. clearCtx() {
  911. console.log(4234);
  912. this.placeholder = '您可以在这里输入答疑内容';
  913. this.ctxValue = '';
  914. this.assignUserId = 0;
  915. },
  916. replyContent(item) {
  917. this.assignUserId = item.userId;
  918. this.placeholder = '@' + item.realname;
  919. },
  920. delContent(item) {
  921. this.delAnswer(item.answerId);
  922. },
  923. postAnswer() {
  924. let self = this;
  925. let data = { courseId: this.courseId, answerText: this.ctxValue, goodsId: this.goodsId };
  926. if (this.assignUserId > 0) {
  927. data.assignUserId = this.assignUserId;
  928. }
  929. this.$api.postAnswer(data).then(res => {
  930. if (res.data.code == 200) {
  931. this.$u.toast('发布成功');
  932. self.getAnswerList();
  933. this.placeholder = '您可以在这里输入答疑内容';
  934. this.ctxValue = '';
  935. this.assignUserId = 0;
  936. }
  937. });
  938. },
  939. postContent() {
  940. if (!this.ctxValue||this.ctxValue=='') {
  941. this.$u.toast('请输入内容');
  942. return
  943. }
  944. this.postAnswer();
  945. },
  946. postStudyRecord(status = 0, sectionId = this.playSectionId) {
  947. console.log('status',status)
  948. let currentTime = 0;
  949. let PlayDuration = 0
  950. var polyvPlayerContext = this.selectComponent('#playerVideo');
  951. if (polyvPlayerContext) {
  952. currentTime = polyvPlayerContext.getCurrentTime(); //总的视频播放时刻
  953. PlayDuration = polyvPlayerContext.getVideoPlayDuration();//本次看的时长
  954. }
  955. if(this.playChannelId>0){
  956. currentTime = 2;//直播无法获取,无论开始结束都传2秒
  957. }
  958. let self = this;
  959. let data = {
  960. photo: self.ossAvatarUrl,
  961. sectionId: parseInt(sectionId),
  962. goodsId: parseInt(self.goodsId),
  963. courseId: parseInt(self.courseId),
  964. studyDuration: parseInt(PlayDuration > 0 ? PlayDuration : self.studyDuration),
  965. gradeId: parseInt(self.gradeId),
  966. chapterId: parseInt(self.chapterId),
  967. moduleId: parseInt(self.moduleId),
  968. videoCurrentTime: parseInt(currentTime > 0 ? currentTime : self.studyDuration)
  969. };
  970. if (status > 0) {
  971. data.status = status;
  972. }
  973. console.log('提交接口', data);
  974. this.$api.studyRecord(data).then(res => {
  975. if (status > 0) {
  976. uni.$emit('playend'); //通知播放结束
  977. }
  978. self.ossAvatarUrl = ''
  979. console.log(res,'res');
  980. });
  981. },
  982. uploadFile(options, int) {
  983. var self = this;
  984. return new Promise((resolve, reject) => {
  985. var data = {
  986. imageStatus: int
  987. };
  988. self.$api.aliyunpolicy(data).then(res => {
  989. if (res.data.code != 200) {
  990. self.$method.showToast('签名错误' + JSON.stringify(res.data));
  991. return;
  992. }
  993. var ossToken = res.data.data.resultContent;
  994. if (ossToken.host == null || ossToken.host == undefined) {
  995. self.$method.showToast('上传路径报错' + JSON.stringify(res.data));
  996. return;
  997. }
  998. uni.uploadFile({
  999. url: ossToken.host,
  1000. name: 'file',
  1001. filePath: options,
  1002. fileType: 'image',
  1003. header: {
  1004. AuthorizationToken: 'WX ' + uni.getStorageSync('token')
  1005. },
  1006. formData: {
  1007. key: ossToken.dir,
  1008. OSSAccessKeyId: ossToken.accessid,
  1009. policy: ossToken.policy,
  1010. Signature: ossToken.signature,
  1011. callback: ossToken.callback,
  1012. success_action_status: 200
  1013. },
  1014. success: result => {
  1015. if (result.statusCode === 200) {
  1016. self.ossAvatarUrl = ossToken.dir;
  1017. resolve();
  1018. } else {
  1019. uni.showToast({
  1020. title: '上传失败',
  1021. icon: 'none'
  1022. });
  1023. return;
  1024. }
  1025. },
  1026. fail: error => {
  1027. uni.showToast({
  1028. title: '上传接口报错' + error,
  1029. icon: 'none'
  1030. });
  1031. return;
  1032. }
  1033. });
  1034. });
  1035. });
  1036. },
  1037. imageInfos() {
  1038. var self = this;
  1039. return new Promise((resolve, reject) => {
  1040. uni.getImageInfo({
  1041. src: self.avatarUrl,
  1042. success: async res => {
  1043. let canvasWidth = res.width; //图片原始长宽
  1044. let canvasHeight = res.height;
  1045. if (canvasWidth > 1000 || canvasHeight > 1000) {
  1046. uni.compressImage({
  1047. src: self.avatarUrl,
  1048. quality: 75,
  1049. width: '50%',
  1050. height: '50%',
  1051. success: async rest => {
  1052. const waitUpload = await self.uploadFile(rest.tempFilePath, 0);
  1053. resolve();
  1054. }
  1055. });
  1056. } else {
  1057. console.log('无需压缩');
  1058. const waitUpload = await self.uploadFile(self.avatarUrl, 0);
  1059. resolve();
  1060. }
  1061. }
  1062. });
  1063. });
  1064. },
  1065. timeEvent() {
  1066. let self = this;
  1067. var polyvPlayerContext = this.selectComponent('#playerVideo');
  1068. if (polyvPlayerContext != null) {
  1069. this.playTime = polyvPlayerContext.getCurrentTime() //播放时刻
  1070. //判断是否需要拍照
  1071. if (this.photoNum > 0) {
  1072. this.configPhoto()
  1073. if(this.photoIndex<this.photoList.length){
  1074. let photoTime = Number(this.photoList[this.photoIndex]); //获取拍照秒数
  1075. let nextIndex = this.photoIndex+1
  1076. let nextTime = 0
  1077. if(nextIndex<this.photoList.length){
  1078. nextTime = Number(this.photoList[nextIndex]); //获取下次拍照秒数
  1079. }
  1080. if (photoTime < this.playTime&&photoTime>this.playTime-4) { //3秒区间内才触发拍照,避免拉动滚动条
  1081. if(this.photoHistoryList.indexOf(this.photoIndex)<0){ //不存在拍照历史则拍照
  1082. //启动拍照
  1083. //暂停
  1084. polyvPlayerContext.exitFullScreen();
  1085. polyvPlayerContext.pause();
  1086. this.photoIndex++;
  1087. this.openPhoto();
  1088. }
  1089. }
  1090. }
  1091. }
  1092. }
  1093. },
  1094. onStateChange(newstate, oldstate) {
  1095. if (newstate.detail.newstate == 'playing') {
  1096. if (this.needSeek) {
  1097. var polyvPlayerContext = this.selectComponent('#playerVideo');
  1098. if(this.recordObj.videoCurrentTime){
  1099. polyvPlayerContext.seek(this.recordObj.videoCurrentTime);
  1100. }else{
  1101. polyvPlayerContext.seek(1);//避免相同节继续播放
  1102. }
  1103. polyvPlayerContext.play();
  1104. this.needSeek = false;
  1105. }
  1106. //开始播放
  1107. if (this.timer) {
  1108. clearInterval(this.timer);
  1109. }
  1110. this.timer = setInterval(this.timeEvent, 1000); //定时器
  1111. }
  1112. if (newstate.detail.newstate == 'pause') {
  1113. //暂停提交记录
  1114. /* this.ossAvatarUrl = ""
  1115. this.postStudyRecord() */
  1116. }
  1117. if (newstate.detail.newstate == 'ended') {
  1118. this.postStudyRecord(1);
  1119. uni.$emit('playNext') //播放重修下一节
  1120. }
  1121. },
  1122. //拍照
  1123. openPhoto() {
  1124. this.photoPopup = true;
  1125. uni.authorize({
  1126. scope: 'scope.camera',
  1127. success() {
  1128. }
  1129. })
  1130. },
  1131. async submit() {
  1132. const waitYS = await this.imageInfos();
  1133. this.postCoursePhotoRecord()
  1134. this.postStudyRecord(); //提交记录
  1135. //恢复播放
  1136. var polyvPlayerContext = this.selectComponent('#playerVideo');
  1137. if (polyvPlayerContext != null) {
  1138. polyvPlayerContext.play();
  1139. }
  1140. },
  1141. //确认拍照
  1142. takePhoto() {
  1143. var self = this;
  1144. const ctx = uni.createCameraContext();
  1145. ctx.takePhoto({
  1146. quality: 'high',
  1147. success: res => {
  1148. console.log(res.tempImagePath);
  1149. self.avatarUrl = res.tempImagePath;
  1150. self.submit();
  1151. self.photoPopup = false;
  1152. },
  1153. fail: err => {
  1154. console.log(err);
  1155. }
  1156. });
  1157. },
  1158. //拍照报错
  1159. error(e) {
  1160. console.log(e.detail);
  1161. },
  1162. //关闭相机
  1163. closePhoto() {
  1164. this.photoPopup = false;
  1165. },
  1166. getGoodsDetail() {
  1167. let self = this;
  1168. this.$api.goodsDetail(this.goodsId).then(res => {
  1169. self.goodsData = res.data.data;
  1170. self.gradeId = self.goodsData.gradeId;
  1171. console.log(self.gradeId, "班级ID");
  1172. this.courseBusiness()
  1173. this.courseHandouts();
  1174. self.getMenuList();
  1175. self.getReMenuList(); //获取重修目录
  1176. setTimeout(function(){
  1177. if(!self.needProfileModal){
  1178. self.getGradeInfo()
  1179. }
  1180. },500)
  1181. //获取节笔记
  1182. this.getNoteList();
  1183. if (self.goodsData.goodsPlayConfig) {
  1184. self.goodsPlayConfig = JSON.parse(self.goodsData.goodsPlayConfig);
  1185. if (self.goodsPlayConfig.autoPlay > 0) {
  1186. self.autoplay = true;
  1187. }
  1188. if (self.goodsPlayConfig.drag > 0) {
  1189. self.isAllowSeek = 'yes';
  1190. }
  1191. if (self.goodsPlayConfig.speed > 0) {
  1192. self.playbackRate = [0.5, 0.8, 1.0, 1.25, 1.5, 2.0];
  1193. }
  1194. }
  1195. if (self.goodsData.goodsPhotographConfig) {
  1196. self.goodsPhotographConfig = JSON.parse(self.goodsData.goodsPhotographConfig);
  1197. if (self.goodsPhotographConfig.photoNum>0) {
  1198. self.photoNum = self.goodsPhotographConfig.photoNum
  1199. console.log(self.photoNum,777777)
  1200. }
  1201. }
  1202. });
  1203. },
  1204. startVideo() {
  1205. this.startStatus = true;
  1206. },
  1207. getAnswerList() {
  1208. let self = this;
  1209. this.$api.answerList({ courseId: this.courseId,goodsId: this.goodsId }).then(res => {
  1210. if (res.data.code == 200) {
  1211. self.answerList = res.data.rows;
  1212. }
  1213. });
  1214. },
  1215. getReMenuList() {
  1216. let self = this;
  1217. this.$api.reMenuList({ courseId: this.courseId, rebuild: 1, gradeId: this.gradeId }).then(res => {
  1218. if (res.data.code == 200) {
  1219. for (let i = 0; i < res.data.rows.length; i++) {
  1220. let item = res.data.rows[i];
  1221. item.down = true;
  1222. item.id = item.menuId;
  1223. item.name = item.menuName;
  1224. }
  1225. self.reMenuList = res.data.rows;
  1226. if(self.reMenuList.length>0){
  1227. self.list = [
  1228. {
  1229. name: '目录'
  1230. },
  1231. {
  1232. name: '讲义'
  1233. },
  1234. {
  1235. name: '笔记'
  1236. },
  1237. {
  1238. name: '答疑'
  1239. },
  1240. {name:'重修目录'}
  1241. ];
  1242. this.current = 0;
  1243. } else {
  1244. self.list = [
  1245. {
  1246. name: '目录'
  1247. },
  1248. {
  1249. name: '讲义'
  1250. },
  1251. {
  1252. name: '笔记'
  1253. },
  1254. {
  1255. name: '答疑'
  1256. }
  1257. ];
  1258. this.current = 0;
  1259. }
  1260. }
  1261. });
  1262. },
  1263. getMenuList() {
  1264. let self = this;
  1265. this.$api.reMenuList({ courseId: this.courseId, gradeId: this.gradeId }).then(res => {
  1266. if (res.data.code == 200) {
  1267. for (let i = 0; i < res.data.rows.length; i++) {
  1268. let item = res.data.rows[i];
  1269. item.down = true;
  1270. item.id = item.menuId;
  1271. item.name = item.menuName;
  1272. }
  1273. self.menuList = res.data.rows;
  1274. }
  1275. });
  1276. },
  1277. courseDetail() {
  1278. let self = this;
  1279. this.$api.courseDetail(this.courseId).then(res => {
  1280. if (res.data.code == 200) {
  1281. self.detail = res.data.data;
  1282. uni.setNavigationBarTitle({
  1283. title:self.detail.courseName
  1284. })
  1285. }
  1286. });
  1287. },
  1288. open(item) {
  1289. item.showChildren = !item.showChildren;
  1290. },
  1291. change(index) {
  1292. this.current = index;
  1293. },
  1294. openDocument() {
  1295. let self = this;
  1296. let url = this.$method.splitImgHost(this.courseHandoutsData.handoutsUrl)
  1297. console.log(url)
  1298. uni.downloadFile({
  1299. url: url,
  1300. success: function (res) {
  1301. console.log(999)
  1302. var filePath = res.tempFilePath;
  1303. uni.openDocument({
  1304. filePath: filePath,
  1305. showMenu: self.courseHandoutsData.canDownload == 1 ? true : false,
  1306. success: function (res) {
  1307. console.log(res,'打开文档成功');
  1308. },
  1309. fail:function(err) {
  1310. console.log(err)
  1311. uni.showToast({
  1312. icon:'none',
  1313. title:'文档地址错误'
  1314. })
  1315. }
  1316. });
  1317. },
  1318. fail:(err) => {
  1319. uni.showModal({
  1320. title:'提示',
  1321. content:'文档错误,'+err.errMsg,
  1322. showCancel:false
  1323. })
  1324. }
  1325. });
  1326. }
  1327. }
  1328. };
  1329. </script>
  1330. <style lang="scss" scope>
  1331. .btnSet{
  1332. width: 440rpx;
  1333. height: 80rpx;
  1334. background: #007AFF;
  1335. border-radius: 40rpx;
  1336. color: #FFFFFF;
  1337. font-size: 28rpx;
  1338. line-height: 80rpx;
  1339. }
  1340. .btnReply {
  1341. width: 80rpx;
  1342. height: 40rpx;
  1343. background: #e3f0ff;
  1344. border-radius: 16rpx;
  1345. text-align: center;
  1346. color: #007aff;
  1347. }
  1348. .btnDel {
  1349. width: 80rpx;
  1350. height: 40rpx;
  1351. background: #ffedf0;
  1352. border-radius: 16rpx;
  1353. text-align: center;
  1354. color: #ff2d55;
  1355. }
  1356. .btnReply {
  1357. width: 80rpx;
  1358. height: 40rpx;
  1359. background: #e3f0ff;
  1360. border-radius: 16rpx;
  1361. font-size: 24rpx;
  1362. }
  1363. .lecture-box {
  1364. display: flex;
  1365. align-items: center;
  1366. height: 80rpx;
  1367. background: #FFFFFF;
  1368. border-radius: 16rpx 16rpx 16rpx 16rpx;
  1369. .title {
  1370. padding:10rpx;
  1371. flex:1;
  1372. overflow: hidden;
  1373. text-overflow: ellipsis;
  1374. white-space: nowrap;
  1375. color:#333;
  1376. font-weight: bold;
  1377. font-size: 32rpx;
  1378. }
  1379. .btn {
  1380. display: flex;
  1381. align-items: center;
  1382. justify-content: center;
  1383. width:80rpx;
  1384. height:80rpx;
  1385. background: #FFFFFF;
  1386. box-shadow: -4rpx 0rpx 4rpx 0rpx rgba(0,0,0,0.1);
  1387. border-radius: 16rpx 16rpx 16rpx 16rpx;
  1388. }
  1389. }
  1390. .lecture-content {
  1391. background:#fff;
  1392. margin-top:10rpx;
  1393. padding:10rpx;
  1394. border-radius:16rpx;
  1395. }
  1396. .photoBox {
  1397. background-color: #FFFFFF;
  1398. border-radius: 32px 32px 0px 0px;
  1399. .photoTop {
  1400. height: 74upx;
  1401. display: flex;
  1402. align-items: center;
  1403. justify-content: space-between;
  1404. padding: 0upx 38upx;
  1405. .sqzz {
  1406. width: 28upx;
  1407. height: 28upx;
  1408. display: flex;
  1409. align-items: center;
  1410. justify-content: center;
  1411. }
  1412. .centersq {
  1413. color: #333;
  1414. font-size: 30upx;
  1415. font-weight: 500;
  1416. }
  1417. }
  1418. .photoCenter {
  1419. width: 750upx;
  1420. height: 979upx;
  1421. position: relative;
  1422. .custom {
  1423. width: 750upx;
  1424. height: 979upx;
  1425. position: absolute;
  1426. z-index: 1000;
  1427. top: 0;
  1428. left: 0;
  1429. image {
  1430. width: 100%;
  1431. height: 100%;
  1432. }
  1433. }
  1434. }
  1435. .btnResult {
  1436. height: 100rpx;
  1437. width: 100%;
  1438. background-color: #07c160;
  1439. text-align: center;
  1440. line-height: 100upx;
  1441. color: #fff;
  1442. font-size: 32upx;
  1443. font-weight: bold;
  1444. }
  1445. }
  1446. .chat_box {
  1447. display: flex;
  1448. padding: 20rpx;
  1449. justify-content: space-between;
  1450. }
  1451. .chat3 {
  1452. font-size: 30rpx;
  1453. font-family: PingFang SC;
  1454. font-weight: 500;
  1455. color: #666666;
  1456. margin-top: 10rpx;
  1457. }
  1458. .chat2 {
  1459. font-size: 20rpx;
  1460. font-family: PingFang SC;
  1461. font-weight: 500;
  1462. color: #999999;
  1463. margin-top: 10rpx;
  1464. }
  1465. .chat1 {
  1466. font-size: 24rpx;
  1467. font-family: PingFang SC;
  1468. font-weight: 500;
  1469. color: #333333;
  1470. }
  1471. .leftPadding {
  1472. margin-left: 8rpx;
  1473. }
  1474. .t2Content {
  1475. font-size: 28rpx;
  1476. font-family: PingFang SC;
  1477. font-weight: bold;
  1478. color: #999999;
  1479. line-height: 48rpx;
  1480. }
  1481. .tBox2 {
  1482. display: flex;
  1483. padding-top: 10rpx;
  1484. color: #333333;
  1485. font-size: 30rpx;
  1486. }
  1487. .tBox {
  1488. display: flex;
  1489. align-items: center;
  1490. padding-top: 10rpx;
  1491. }
  1492. .title {
  1493. font-size: 24rpx;
  1494. color: #999999;
  1495. }
  1496. page {
  1497. padding-top: 10px;
  1498. padding-top: constant(safe-area-inset-top);
  1499. padding-top: env(safe-area-inset-top);
  1500. }
  1501. .inputBottom {
  1502. position: fixed;
  1503. left: 0;
  1504. bottom: 0;
  1505. background: #ffffff;
  1506. height: 98rpx;
  1507. display: flex;
  1508. align-items: center;
  1509. width: 100%;
  1510. .flex_auto {
  1511. flex:1;
  1512. margin-left: 10% ;
  1513. .input {
  1514. height:60rpx;
  1515. }
  1516. }
  1517. .btn {
  1518. color: #007AFF;font-size: 30rpx;font-weight: bold;width: 15%;text-align: center;
  1519. }
  1520. }
  1521. .noteBox {
  1522. width: 100%;
  1523. background: #ffffff;
  1524. padding: 10rpx;
  1525. border-radius: 16rpx;
  1526. }
  1527. .dateBox {
  1528. width: 216rpx;
  1529. height: 48rpx;
  1530. background: #ffffff;
  1531. border-radius: 24rpx;
  1532. font-size: 24rpx;
  1533. color: #666666;
  1534. text-align: center;
  1535. line-height: 48rpx;
  1536. margin: 20rpx 0;
  1537. }
  1538. .t_content1 {
  1539. color: #007aff;
  1540. margin-left: 10rpx;
  1541. }
  1542. .tag1 {
  1543. border: 2rpx solid #007aff;
  1544. border-radius: 8rpx;
  1545. font-size: 20rpx;
  1546. color: #007aff;
  1547. padding: 5rpx;
  1548. }
  1549. .b_title {
  1550. color: #333333;
  1551. font-size: 30rpx;
  1552. font-weight: bold;
  1553. }
  1554. page {
  1555. background: #eaeef1;
  1556. }
  1557. .menuBox {
  1558. width: 100%;
  1559. background: #ffffff;
  1560. border-radius: 16rpx;
  1561. padding: 20rpx;
  1562. margin-bottom: 20rpx;
  1563. }
  1564. .btnspric {
  1565. border-top: 1rpx solid #eee;
  1566. display: flex;
  1567. align-items: center;
  1568. justify-content: space-between;
  1569. height: 108rpx;
  1570. padding-left: 43rpx;
  1571. padding-right: 32rpx;
  1572. }
  1573. .btnspric > .lefprL {
  1574. font-size: 36rpx;
  1575. color: #0c141f;
  1576. font-weight: bold;
  1577. }
  1578. .btnspric > .lefprR {
  1579. padding: 0rpx 24rpx;
  1580. height: 60rpx;
  1581. line-height: 60rpx;
  1582. text-align: center;
  1583. color: #fff;
  1584. background: #32467b;
  1585. border-radius: 24rpx;
  1586. box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(145, 156, 178, 0.1);
  1587. }
  1588. .yhj,
  1589. .hdyhj {
  1590. padding: 24rpx 29rpx 24rpx 34rpx;
  1591. }
  1592. .yhj {
  1593. border-bottom: 16rpx solid #f9f9f9;
  1594. }
  1595. .yhjtit {
  1596. font-size: 30rpx;
  1597. color: #0c141f;
  1598. font-weight: 500;
  1599. margin-bottom: 14rpx;
  1600. }
  1601. .yhjList {
  1602. display: flex;
  1603. align-items: center;
  1604. justify-content: space-between;
  1605. margin-bottom: 14rpx;
  1606. }
  1607. .yhjList > .yhjLefts {
  1608. display: flex;
  1609. align-items: center;
  1610. }
  1611. .yhjLefts > .yhl {
  1612. color: #32467b;
  1613. font-size: 30rpx;
  1614. margin-right: 31rpx;
  1615. }
  1616. .yhjLefts > .yhbq {
  1617. font-size: 24rpx;
  1618. color: #ff9500;
  1619. border-radius: 18rpx;
  1620. background-color: rgba(255, 149, 0, 0.2);
  1621. border: 2rpx solid #ff9500;
  1622. height: 38rpx;
  1623. line-height: 38rpx;
  1624. padding: 0rpx 16rpx;
  1625. }
  1626. .ts {
  1627. font-size: 24rpx;
  1628. color: #999;
  1629. margin: 14rpx 0rpx;
  1630. padding-right: 29rpx;
  1631. padding-left: 34rpx;
  1632. }
  1633. .yh {
  1634. padding-top: 20rpx;
  1635. }
  1636. .yh > .yhtitle {
  1637. display: flex;
  1638. align-items: center;
  1639. justify-content: space-between;
  1640. padding-right: 29rpx;
  1641. padding-left: 34rpx;
  1642. }
  1643. .priceBxs {
  1644. display: flex;
  1645. align-items: center;
  1646. }
  1647. .priceBxs > .pricleft {
  1648. border-radius: 24rpx;
  1649. border: 1rpx solid #e91313;
  1650. background-color: rgba(233, 19, 19, 0.1);
  1651. padding: 0rpx 18rpx;
  1652. height: 49rpx;
  1653. line-height: 49rpx;
  1654. text-align: center;
  1655. font-size: 30rpx;
  1656. font-weight: 500;
  1657. color: #e91313;
  1658. margin-right: 13rpx;
  1659. }
  1660. .topBox {
  1661. padding: 32rpx 32rpx 24rpx;
  1662. border-bottom: 1rpx solid #eeeeee;
  1663. }
  1664. .topBox > .boldFonstType {
  1665. font-weight: 500;
  1666. font-size: 30rpx;
  1667. margin: 16rpx 0rpx 23rpx;
  1668. }
  1669. .topBox > .firstTopL {
  1670. display: flex;
  1671. align-items: center;
  1672. }
  1673. .topBox > .firstTopL > .imageBs {
  1674. width: 331rpx;
  1675. height: 160rpx;
  1676. border-radius: 6rpx;
  1677. overflow: hidden;
  1678. margin-right: 8rpx;
  1679. box-shadow: 0rpx 6rpx 6rpx 0rpx rgba(47, 67, 121, 0.08);
  1680. }
  1681. .topBox > .firstTopL > .imageBs > image {
  1682. width: 100%;
  1683. height: 100%;
  1684. }
  1685. .topBox > .firstTopL > .textBs {
  1686. font-size: 30rpx;
  1687. font-weight: bold;
  1688. color: #0c141f;
  1689. }
  1690. .content {
  1691. padding: 24rpx;
  1692. text-align: left;
  1693. }
  1694. .catalogBox {
  1695. display: flex;
  1696. align-items: center;
  1697. flex-wrap: nowrap;
  1698. overflow-x: auto;
  1699. padding-left: 38rpx;
  1700. max-height: 305rpx;
  1701. overflow-y: auto;
  1702. transition: all 0.4s;
  1703. }
  1704. .catalogBox > .catalogA {
  1705. min-width: 200rpx;
  1706. height: 48rpx;
  1707. line-height: 48rpx;
  1708. // text-align: center;
  1709. border: 2rpx solid transparent;
  1710. white-space: nowrap;
  1711. text-overflow: ellipsis;
  1712. overflow: hidden;
  1713. word-break: break-all;
  1714. border-radius: 10rpx;
  1715. background: rgba(22, 119, 255, 0.05);
  1716. padding-left: 19rpx;
  1717. box-sizing: border-box;
  1718. padding-right: 15rpx;
  1719. margin-right: 16rpx;
  1720. margin-bottom: 20rpx;
  1721. margin-top: 15rpx;
  1722. font-size: 24rpx;
  1723. color: #666;
  1724. }
  1725. .catalogBox > .activesq {
  1726. border-color: #1677ff;
  1727. }
  1728. .changeCatalogBox {
  1729. display: block;
  1730. }
  1731. .catalogBox::-webkit-scrollbar {
  1732. display: none; /* Chrome Safari */
  1733. }
  1734. .box {
  1735. position: relative;
  1736. top: 650rpx;
  1737. padding-bottom: 88rpx;
  1738. margin: 20rpx;
  1739. }
  1740. .price_t2 {
  1741. font-size: 18rpx;
  1742. font-family: PingFang SC;
  1743. font-weight: 500;
  1744. text-decoration: line-through;
  1745. color: #999999;
  1746. }
  1747. .price_t1 {
  1748. font-size: 33rpx;
  1749. font-family: PingFang SC;
  1750. font-weight: bold;
  1751. color: #e91313;
  1752. }
  1753. .sc_t {
  1754. font-size: 22rpx;
  1755. color: #000000;
  1756. }
  1757. .sc {
  1758. width: 29rpx;
  1759. height: 29rpx;
  1760. }
  1761. .buy {
  1762. width: 138rpx;
  1763. height: 48rpx;
  1764. line-height: 48rpx;
  1765. background: #32467b;
  1766. border-radius: 10rpx;
  1767. color: #ffffff;
  1768. font-size: 28rpx;
  1769. text-align: center;
  1770. vertical-align: middle;
  1771. position: absolute;
  1772. right: 30rpx;
  1773. }
  1774. .video_body {
  1775. padding-bottom: 96rpx;
  1776. }
  1777. .footer_tab {
  1778. position: fixed;
  1779. bottom: 0;
  1780. height: 96rpx;
  1781. width: 100%;
  1782. background-color: #ffffff;
  1783. }
  1784. .tj_box {
  1785. width: 50%;
  1786. display: inline-block;
  1787. text-align: center;
  1788. margin: 10rpx 0;
  1789. }
  1790. .teacher_t {
  1791. font-size: 24rpx;
  1792. font-family: PingFang SC;
  1793. font-weight: 400;
  1794. color: #666666;
  1795. line-height: 36rpx;
  1796. margin-left: 15rpx;
  1797. }
  1798. .teacher_img {
  1799. width: 87rpx;
  1800. height: 129rpx;
  1801. }
  1802. .t2 {
  1803. font-size: 24rpx;
  1804. font-family: PingFang SC;
  1805. color: #666666;
  1806. line-height: 36rpx;
  1807. margin: 15rpx;
  1808. }
  1809. .r_t2 {
  1810. width: 201rpx;
  1811. height: 49rpx;
  1812. background: rgba(22, 119, 255, 0.05);
  1813. border: 1rpx solid #32467b;
  1814. border-radius: 16rpx;
  1815. color: #666666;
  1816. font-size: 23rpx;
  1817. text-align: center;
  1818. display: flex;
  1819. align-items: center;
  1820. padding: 5rpx;
  1821. }
  1822. .scroll_box {
  1823. width: 100%;
  1824. height: 60rpx;
  1825. background: #ffffff;
  1826. box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(145, 156, 178, 0.1);
  1827. white-space: nowrap;
  1828. overflow: hidden;
  1829. margin: 15rpx 0;
  1830. }
  1831. .r_sliper {
  1832. padding: 0 20rpx;
  1833. }
  1834. .top_line {
  1835. width: 6rpx;
  1836. height: 22rpx;
  1837. background: #32467b;
  1838. margin-right: 10rpx;
  1839. }
  1840. .video_t2 {
  1841. font-size: 24rpx;
  1842. font-family: PingFang SC;
  1843. font-weight: 500;
  1844. color: #666666;
  1845. }
  1846. .video_t1 {
  1847. height: 80rpx;
  1848. color: #333333;
  1849. line-height: 80rpx;
  1850. font-size: 30rpx;
  1851. font-family: PingFang SC;
  1852. font-weight: bold;
  1853. color: #333333;
  1854. overflow: hidden;
  1855. text-overflow: ellipsis;
  1856. white-space: nowrap;
  1857. }
  1858. .video_t1_t {
  1859. display: flex;
  1860. flex-direction: column;
  1861. height: 80rpx;
  1862. color: #333333;
  1863. text-align: center;
  1864. align-items: center;
  1865. border-left: solid 1px #d6d6db;
  1866. }
  1867. .video_play {
  1868. position: absolute;
  1869. width: 95rpx;
  1870. height: 95rpx;
  1871. top: 0;
  1872. left: 0;
  1873. right: 0;
  1874. bottom: 0;
  1875. margin: auto;
  1876. }
  1877. .video_box {
  1878. position: relative;
  1879. }
  1880. .rotoct {
  1881. transform: rotate(90deg);
  1882. }
  1883. </style>