detail.vue 50 KB

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