detail.vue 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931
  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
  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. // console.log(this.playTime,789,this.photoHistoryList)
  1071. //判断是否需要拍照
  1072. if (this.photoNum > 0) {
  1073. this.configPhoto()
  1074. let photoTime =0; //获取拍照秒数
  1075. for(let i=0;i<this.photoList.length;i++){
  1076. photoTime = Number(this.photoList[i]); //获取拍照秒数
  1077. if (photoTime < this.playTime&&photoTime>this.playTime-8) { //3秒区间内才触发拍照,避免拉动滚动条
  1078. if(this.photoHistoryList.indexOf(i)<0){ //不存在拍照历史则拍照
  1079. //启动拍照
  1080. //暂停
  1081. polyvPlayerContext.exitFullScreen();
  1082. polyvPlayerContext.pause();
  1083. this.photoHistoryList.push(i)
  1084. this.photoIndex = i
  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>