detail.vue 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928
  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
  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. console.log(this.photoIndex,789)
  1069. //判断是否需要拍照
  1070. if (this.photoNum > 0) {
  1071. this.configPhoto()
  1072. let photoTime =0; //获取拍照秒数
  1073. for(let i=0;i<this.photoList.length;i++){
  1074. photoTime = Number(this.photoList[i]); //获取拍照秒数
  1075. if (photoTime < this.playTime&&photoTime>this.playTime-4) { //3秒区间内才触发拍照,避免拉动滚动条
  1076. if(this.photoHistoryList.indexOf(i)<0){ //不存在拍照历史则拍照
  1077. //启动拍照
  1078. //暂停
  1079. polyvPlayerContext.exitFullScreen();
  1080. polyvPlayerContext.pause();
  1081. this.photoHistoryList.push(i)
  1082. this.photoIndex = i
  1083. this.openPhoto();
  1084. }
  1085. }
  1086. }
  1087. }
  1088. }
  1089. },
  1090. onStateChange(newstate, oldstate) {
  1091. if (newstate.detail.newstate == 'playing') {
  1092. if (this.needSeek) {
  1093. var polyvPlayerContext = this.selectComponent('#playerVideo');
  1094. if(this.recordObj.videoCurrentTime){
  1095. polyvPlayerContext.seek(this.recordObj.videoCurrentTime);
  1096. }else{
  1097. polyvPlayerContext.seek(1);//避免相同节继续播放
  1098. }
  1099. polyvPlayerContext.play();
  1100. this.needSeek = false;
  1101. }
  1102. //开始播放
  1103. if (this.timer) {
  1104. clearInterval(this.timer);
  1105. }
  1106. this.timer = setInterval(this.timeEvent, 1000); //定时器
  1107. }
  1108. if (newstate.detail.newstate == 'pause') {
  1109. //暂停提交记录
  1110. /* this.ossAvatarUrl = ""
  1111. this.postStudyRecord() */
  1112. }
  1113. if (newstate.detail.newstate == 'ended') {
  1114. this.postStudyRecord(1);
  1115. uni.$emit('playNext') //播放重修下一节
  1116. }
  1117. },
  1118. //拍照
  1119. openPhoto() {
  1120. this.photoPopup = true;
  1121. uni.authorize({
  1122. scope: 'scope.camera',
  1123. success() {
  1124. }
  1125. })
  1126. },
  1127. async submit() {
  1128. const waitYS = await this.imageInfos();
  1129. this.postCoursePhotoRecord()
  1130. this.postStudyRecord(); //提交记录
  1131. //恢复播放
  1132. var polyvPlayerContext = this.selectComponent('#playerVideo');
  1133. if (polyvPlayerContext != null) {
  1134. polyvPlayerContext.play();
  1135. }
  1136. },
  1137. //确认拍照
  1138. takePhoto() {
  1139. var self = this;
  1140. const ctx = uni.createCameraContext();
  1141. ctx.takePhoto({
  1142. quality: 'high',
  1143. success: res => {
  1144. console.log(res.tempImagePath);
  1145. self.avatarUrl = res.tempImagePath;
  1146. self.submit();
  1147. self.photoPopup = false;
  1148. },
  1149. fail: err => {
  1150. console.log(err);
  1151. }
  1152. });
  1153. },
  1154. //拍照报错
  1155. error(e) {
  1156. console.log(e.detail);
  1157. },
  1158. //关闭相机
  1159. closePhoto() {
  1160. this.photoPopup = false;
  1161. },
  1162. getGoodsDetail() {
  1163. let self = this;
  1164. this.$api.goodsDetail(this.goodsId).then(res => {
  1165. self.goodsData = res.data.data;
  1166. self.gradeId = self.goodsData.gradeId;
  1167. console.log(self.gradeId, "班级ID");
  1168. this.courseBusiness()
  1169. this.courseHandouts();
  1170. self.getMenuList();
  1171. self.getReMenuList(); //获取重修目录
  1172. setTimeout(function(){
  1173. if(!self.needProfileModal){
  1174. self.getGradeInfo()
  1175. }
  1176. },500)
  1177. //获取节笔记
  1178. this.getNoteList();
  1179. if (self.goodsData.goodsPlayConfig) {
  1180. self.goodsPlayConfig = JSON.parse(self.goodsData.goodsPlayConfig);
  1181. if (self.goodsPlayConfig.autoPlay > 0) {
  1182. self.autoplay = true;
  1183. }
  1184. if (self.goodsPlayConfig.drag > 0) {
  1185. self.isAllowSeek = 'yes';
  1186. }
  1187. if (self.goodsPlayConfig.speed > 0) {
  1188. self.playbackRate = [0.5, 0.8, 1.0, 1.25, 1.5, 2.0];
  1189. }
  1190. }
  1191. if (self.goodsData.goodsPhotographConfig) {
  1192. self.goodsPhotographConfig = JSON.parse(self.goodsData.goodsPhotographConfig);
  1193. if (self.goodsPhotographConfig.photoNum>0) {
  1194. self.photoNum = self.goodsPhotographConfig.photoNum
  1195. console.log(self.photoNum,777777)
  1196. }
  1197. }
  1198. });
  1199. },
  1200. startVideo() {
  1201. this.startStatus = true;
  1202. },
  1203. getAnswerList() {
  1204. let self = this;
  1205. this.$api.answerList({ courseId: this.courseId,goodsId: this.goodsId }).then(res => {
  1206. if (res.data.code == 200) {
  1207. self.answerList = res.data.rows;
  1208. }
  1209. });
  1210. },
  1211. getReMenuList() {
  1212. let self = this;
  1213. this.$api.reMenuList({ courseId: this.courseId, rebuild: 1, gradeId: this.gradeId }).then(res => {
  1214. if (res.data.code == 200) {
  1215. for (let i = 0; i < res.data.rows.length; i++) {
  1216. let item = res.data.rows[i];
  1217. item.down = true;
  1218. item.id = item.menuId;
  1219. item.name = item.menuName;
  1220. }
  1221. self.reMenuList = res.data.rows;
  1222. if(self.reMenuList.length>0){
  1223. self.list = [
  1224. {
  1225. name: '目录'
  1226. },
  1227. {
  1228. name: '讲义'
  1229. },
  1230. {
  1231. name: '笔记'
  1232. },
  1233. {
  1234. name: '答疑'
  1235. },
  1236. {name:'重修目录'}
  1237. ];
  1238. this.current = 0;
  1239. } else {
  1240. self.list = [
  1241. {
  1242. name: '目录'
  1243. },
  1244. {
  1245. name: '讲义'
  1246. },
  1247. {
  1248. name: '笔记'
  1249. },
  1250. {
  1251. name: '答疑'
  1252. }
  1253. ];
  1254. this.current = 0;
  1255. }
  1256. }
  1257. });
  1258. },
  1259. getMenuList() {
  1260. let self = this;
  1261. this.$api.reMenuList({ courseId: this.courseId, gradeId: this.gradeId }).then(res => {
  1262. if (res.data.code == 200) {
  1263. for (let i = 0; i < res.data.rows.length; i++) {
  1264. let item = res.data.rows[i];
  1265. item.down = true;
  1266. item.id = item.menuId;
  1267. item.name = item.menuName;
  1268. }
  1269. self.menuList = res.data.rows;
  1270. }
  1271. });
  1272. },
  1273. courseDetail() {
  1274. let self = this;
  1275. this.$api.courseDetail(this.courseId).then(res => {
  1276. if (res.data.code == 200) {
  1277. self.detail = res.data.data;
  1278. uni.setNavigationBarTitle({
  1279. title:self.detail.courseName
  1280. })
  1281. }
  1282. });
  1283. },
  1284. open(item) {
  1285. item.showChildren = !item.showChildren;
  1286. },
  1287. change(index) {
  1288. this.current = index;
  1289. },
  1290. openDocument() {
  1291. let self = this;
  1292. let url = this.$method.splitImgHost(this.courseHandoutsData.handoutsUrl)
  1293. console.log(url)
  1294. uni.downloadFile({
  1295. url: url,
  1296. success: function (res) {
  1297. console.log(999)
  1298. var filePath = res.tempFilePath;
  1299. uni.openDocument({
  1300. filePath: filePath,
  1301. showMenu: self.courseHandoutsData.canDownload == 1 ? true : false,
  1302. success: function (res) {
  1303. console.log(res,'打开文档成功');
  1304. },
  1305. fail:function(err) {
  1306. console.log(err)
  1307. uni.showToast({
  1308. icon:'none',
  1309. title:'文档地址错误'
  1310. })
  1311. }
  1312. });
  1313. },
  1314. fail:(err) => {
  1315. uni.showModal({
  1316. title:'提示',
  1317. content:'文档错误,'+err.errMsg,
  1318. showCancel:false
  1319. })
  1320. }
  1321. });
  1322. }
  1323. }
  1324. };
  1325. </script>
  1326. <style lang="scss" scope>
  1327. .btnSet{
  1328. width: 440rpx;
  1329. height: 80rpx;
  1330. background: #007AFF;
  1331. border-radius: 40rpx;
  1332. color: #FFFFFF;
  1333. font-size: 28rpx;
  1334. line-height: 80rpx;
  1335. }
  1336. .btnReply {
  1337. width: 80rpx;
  1338. height: 40rpx;
  1339. background: #e3f0ff;
  1340. border-radius: 16rpx;
  1341. text-align: center;
  1342. color: #007aff;
  1343. }
  1344. .btnDel {
  1345. width: 80rpx;
  1346. height: 40rpx;
  1347. background: #ffedf0;
  1348. border-radius: 16rpx;
  1349. text-align: center;
  1350. color: #ff2d55;
  1351. }
  1352. .btnReply {
  1353. width: 80rpx;
  1354. height: 40rpx;
  1355. background: #e3f0ff;
  1356. border-radius: 16rpx;
  1357. font-size: 24rpx;
  1358. }
  1359. .lecture-box {
  1360. display: flex;
  1361. align-items: center;
  1362. height: 80rpx;
  1363. background: #FFFFFF;
  1364. border-radius: 16rpx 16rpx 16rpx 16rpx;
  1365. .title {
  1366. padding:10rpx;
  1367. flex:1;
  1368. overflow: hidden;
  1369. text-overflow: ellipsis;
  1370. white-space: nowrap;
  1371. color:#333;
  1372. font-weight: bold;
  1373. font-size: 32rpx;
  1374. }
  1375. .btn {
  1376. display: flex;
  1377. align-items: center;
  1378. justify-content: center;
  1379. width:80rpx;
  1380. height:80rpx;
  1381. background: #FFFFFF;
  1382. box-shadow: -4rpx 0rpx 4rpx 0rpx rgba(0,0,0,0.1);
  1383. border-radius: 16rpx 16rpx 16rpx 16rpx;
  1384. }
  1385. }
  1386. .lecture-content {
  1387. background:#fff;
  1388. margin-top:10rpx;
  1389. padding:10rpx;
  1390. border-radius:16rpx;
  1391. }
  1392. .photoBox {
  1393. background-color: #FFFFFF;
  1394. border-radius: 32px 32px 0px 0px;
  1395. .photoTop {
  1396. height: 74upx;
  1397. display: flex;
  1398. align-items: center;
  1399. justify-content: space-between;
  1400. padding: 0upx 38upx;
  1401. .sqzz {
  1402. width: 28upx;
  1403. height: 28upx;
  1404. display: flex;
  1405. align-items: center;
  1406. justify-content: center;
  1407. }
  1408. .centersq {
  1409. color: #333;
  1410. font-size: 30upx;
  1411. font-weight: 500;
  1412. }
  1413. }
  1414. .photoCenter {
  1415. width: 750upx;
  1416. height: 979upx;
  1417. position: relative;
  1418. .custom {
  1419. width: 750upx;
  1420. height: 979upx;
  1421. position: absolute;
  1422. z-index: 1000;
  1423. top: 0;
  1424. left: 0;
  1425. image {
  1426. width: 100%;
  1427. height: 100%;
  1428. }
  1429. }
  1430. }
  1431. .btnResult {
  1432. height: 100rpx;
  1433. width: 100%;
  1434. background-color: #07c160;
  1435. text-align: center;
  1436. line-height: 100upx;
  1437. color: #fff;
  1438. font-size: 32upx;
  1439. font-weight: bold;
  1440. }
  1441. }
  1442. .chat_box {
  1443. display: flex;
  1444. padding: 20rpx;
  1445. justify-content: space-between;
  1446. }
  1447. .chat3 {
  1448. font-size: 30rpx;
  1449. font-family: PingFang SC;
  1450. font-weight: 500;
  1451. color: #666666;
  1452. margin-top: 10rpx;
  1453. }
  1454. .chat2 {
  1455. font-size: 20rpx;
  1456. font-family: PingFang SC;
  1457. font-weight: 500;
  1458. color: #999999;
  1459. margin-top: 10rpx;
  1460. }
  1461. .chat1 {
  1462. font-size: 24rpx;
  1463. font-family: PingFang SC;
  1464. font-weight: 500;
  1465. color: #333333;
  1466. }
  1467. .leftPadding {
  1468. margin-left: 8rpx;
  1469. }
  1470. .t2Content {
  1471. font-size: 28rpx;
  1472. font-family: PingFang SC;
  1473. font-weight: bold;
  1474. color: #999999;
  1475. line-height: 48rpx;
  1476. }
  1477. .tBox2 {
  1478. display: flex;
  1479. padding-top: 10rpx;
  1480. color: #333333;
  1481. font-size: 30rpx;
  1482. }
  1483. .tBox {
  1484. display: flex;
  1485. align-items: center;
  1486. padding-top: 10rpx;
  1487. }
  1488. .title {
  1489. font-size: 24rpx;
  1490. color: #999999;
  1491. }
  1492. page {
  1493. padding-top: 10px;
  1494. padding-top: constant(safe-area-inset-top);
  1495. padding-top: env(safe-area-inset-top);
  1496. }
  1497. .inputBottom {
  1498. position: fixed;
  1499. left: 0;
  1500. bottom: 0;
  1501. background: #ffffff;
  1502. height: 98rpx;
  1503. display: flex;
  1504. align-items: center;
  1505. width: 100%;
  1506. .flex_auto {
  1507. flex:1;
  1508. margin-left: 10% ;
  1509. .input {
  1510. height:60rpx;
  1511. }
  1512. }
  1513. .btn {
  1514. color: #007AFF;font-size: 30rpx;font-weight: bold;width: 15%;text-align: center;
  1515. }
  1516. }
  1517. .noteBox {
  1518. width: 100%;
  1519. background: #ffffff;
  1520. padding: 10rpx;
  1521. border-radius: 16rpx;
  1522. }
  1523. .dateBox {
  1524. width: 216rpx;
  1525. height: 48rpx;
  1526. background: #ffffff;
  1527. border-radius: 24rpx;
  1528. font-size: 24rpx;
  1529. color: #666666;
  1530. text-align: center;
  1531. line-height: 48rpx;
  1532. margin: 20rpx 0;
  1533. }
  1534. .t_content1 {
  1535. color: #007aff;
  1536. margin-left: 10rpx;
  1537. }
  1538. .tag1 {
  1539. border: 2rpx solid #007aff;
  1540. border-radius: 8rpx;
  1541. font-size: 20rpx;
  1542. color: #007aff;
  1543. padding: 5rpx;
  1544. }
  1545. .b_title {
  1546. color: #333333;
  1547. font-size: 30rpx;
  1548. font-weight: bold;
  1549. }
  1550. page {
  1551. background: #eaeef1;
  1552. }
  1553. .menuBox {
  1554. width: 100%;
  1555. background: #ffffff;
  1556. border-radius: 16rpx;
  1557. padding: 20rpx;
  1558. margin-bottom: 20rpx;
  1559. }
  1560. .btnspric {
  1561. border-top: 1rpx solid #eee;
  1562. display: flex;
  1563. align-items: center;
  1564. justify-content: space-between;
  1565. height: 108rpx;
  1566. padding-left: 43rpx;
  1567. padding-right: 32rpx;
  1568. }
  1569. .btnspric > .lefprL {
  1570. font-size: 36rpx;
  1571. color: #0c141f;
  1572. font-weight: bold;
  1573. }
  1574. .btnspric > .lefprR {
  1575. padding: 0rpx 24rpx;
  1576. height: 60rpx;
  1577. line-height: 60rpx;
  1578. text-align: center;
  1579. color: #fff;
  1580. background: #32467b;
  1581. border-radius: 24rpx;
  1582. box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(145, 156, 178, 0.1);
  1583. }
  1584. .yhj,
  1585. .hdyhj {
  1586. padding: 24rpx 29rpx 24rpx 34rpx;
  1587. }
  1588. .yhj {
  1589. border-bottom: 16rpx solid #f9f9f9;
  1590. }
  1591. .yhjtit {
  1592. font-size: 30rpx;
  1593. color: #0c141f;
  1594. font-weight: 500;
  1595. margin-bottom: 14rpx;
  1596. }
  1597. .yhjList {
  1598. display: flex;
  1599. align-items: center;
  1600. justify-content: space-between;
  1601. margin-bottom: 14rpx;
  1602. }
  1603. .yhjList > .yhjLefts {
  1604. display: flex;
  1605. align-items: center;
  1606. }
  1607. .yhjLefts > .yhl {
  1608. color: #32467b;
  1609. font-size: 30rpx;
  1610. margin-right: 31rpx;
  1611. }
  1612. .yhjLefts > .yhbq {
  1613. font-size: 24rpx;
  1614. color: #ff9500;
  1615. border-radius: 18rpx;
  1616. background-color: rgba(255, 149, 0, 0.2);
  1617. border: 2rpx solid #ff9500;
  1618. height: 38rpx;
  1619. line-height: 38rpx;
  1620. padding: 0rpx 16rpx;
  1621. }
  1622. .ts {
  1623. font-size: 24rpx;
  1624. color: #999;
  1625. margin: 14rpx 0rpx;
  1626. padding-right: 29rpx;
  1627. padding-left: 34rpx;
  1628. }
  1629. .yh {
  1630. padding-top: 20rpx;
  1631. }
  1632. .yh > .yhtitle {
  1633. display: flex;
  1634. align-items: center;
  1635. justify-content: space-between;
  1636. padding-right: 29rpx;
  1637. padding-left: 34rpx;
  1638. }
  1639. .priceBxs {
  1640. display: flex;
  1641. align-items: center;
  1642. }
  1643. .priceBxs > .pricleft {
  1644. border-radius: 24rpx;
  1645. border: 1rpx solid #e91313;
  1646. background-color: rgba(233, 19, 19, 0.1);
  1647. padding: 0rpx 18rpx;
  1648. height: 49rpx;
  1649. line-height: 49rpx;
  1650. text-align: center;
  1651. font-size: 30rpx;
  1652. font-weight: 500;
  1653. color: #e91313;
  1654. margin-right: 13rpx;
  1655. }
  1656. .topBox {
  1657. padding: 32rpx 32rpx 24rpx;
  1658. border-bottom: 1rpx solid #eeeeee;
  1659. }
  1660. .topBox > .boldFonstType {
  1661. font-weight: 500;
  1662. font-size: 30rpx;
  1663. margin: 16rpx 0rpx 23rpx;
  1664. }
  1665. .topBox > .firstTopL {
  1666. display: flex;
  1667. align-items: center;
  1668. }
  1669. .topBox > .firstTopL > .imageBs {
  1670. width: 331rpx;
  1671. height: 160rpx;
  1672. border-radius: 6rpx;
  1673. overflow: hidden;
  1674. margin-right: 8rpx;
  1675. box-shadow: 0rpx 6rpx 6rpx 0rpx rgba(47, 67, 121, 0.08);
  1676. }
  1677. .topBox > .firstTopL > .imageBs > image {
  1678. width: 100%;
  1679. height: 100%;
  1680. }
  1681. .topBox > .firstTopL > .textBs {
  1682. font-size: 30rpx;
  1683. font-weight: bold;
  1684. color: #0c141f;
  1685. }
  1686. .content {
  1687. padding: 24rpx;
  1688. text-align: left;
  1689. }
  1690. .catalogBox {
  1691. display: flex;
  1692. align-items: center;
  1693. flex-wrap: nowrap;
  1694. overflow-x: auto;
  1695. padding-left: 38rpx;
  1696. max-height: 305rpx;
  1697. overflow-y: auto;
  1698. transition: all 0.4s;
  1699. }
  1700. .catalogBox > .catalogA {
  1701. min-width: 200rpx;
  1702. height: 48rpx;
  1703. line-height: 48rpx;
  1704. // text-align: center;
  1705. border: 2rpx solid transparent;
  1706. white-space: nowrap;
  1707. text-overflow: ellipsis;
  1708. overflow: hidden;
  1709. word-break: break-all;
  1710. border-radius: 10rpx;
  1711. background: rgba(22, 119, 255, 0.05);
  1712. padding-left: 19rpx;
  1713. box-sizing: border-box;
  1714. padding-right: 15rpx;
  1715. margin-right: 16rpx;
  1716. margin-bottom: 20rpx;
  1717. margin-top: 15rpx;
  1718. font-size: 24rpx;
  1719. color: #666;
  1720. }
  1721. .catalogBox > .activesq {
  1722. border-color: #1677ff;
  1723. }
  1724. .changeCatalogBox {
  1725. display: block;
  1726. }
  1727. .catalogBox::-webkit-scrollbar {
  1728. display: none; /* Chrome Safari */
  1729. }
  1730. .box {
  1731. position: relative;
  1732. top: 650rpx;
  1733. padding-bottom: 88rpx;
  1734. margin: 20rpx;
  1735. }
  1736. .price_t2 {
  1737. font-size: 18rpx;
  1738. font-family: PingFang SC;
  1739. font-weight: 500;
  1740. text-decoration: line-through;
  1741. color: #999999;
  1742. }
  1743. .price_t1 {
  1744. font-size: 33rpx;
  1745. font-family: PingFang SC;
  1746. font-weight: bold;
  1747. color: #e91313;
  1748. }
  1749. .sc_t {
  1750. font-size: 22rpx;
  1751. color: #000000;
  1752. }
  1753. .sc {
  1754. width: 29rpx;
  1755. height: 29rpx;
  1756. }
  1757. .buy {
  1758. width: 138rpx;
  1759. height: 48rpx;
  1760. line-height: 48rpx;
  1761. background: #32467b;
  1762. border-radius: 10rpx;
  1763. color: #ffffff;
  1764. font-size: 28rpx;
  1765. text-align: center;
  1766. vertical-align: middle;
  1767. position: absolute;
  1768. right: 30rpx;
  1769. }
  1770. .video_body {
  1771. padding-bottom: 96rpx;
  1772. }
  1773. .footer_tab {
  1774. position: fixed;
  1775. bottom: 0;
  1776. height: 96rpx;
  1777. width: 100%;
  1778. background-color: #ffffff;
  1779. }
  1780. .tj_box {
  1781. width: 50%;
  1782. display: inline-block;
  1783. text-align: center;
  1784. margin: 10rpx 0;
  1785. }
  1786. .teacher_t {
  1787. font-size: 24rpx;
  1788. font-family: PingFang SC;
  1789. font-weight: 400;
  1790. color: #666666;
  1791. line-height: 36rpx;
  1792. margin-left: 15rpx;
  1793. }
  1794. .teacher_img {
  1795. width: 87rpx;
  1796. height: 129rpx;
  1797. }
  1798. .t2 {
  1799. font-size: 24rpx;
  1800. font-family: PingFang SC;
  1801. color: #666666;
  1802. line-height: 36rpx;
  1803. margin: 15rpx;
  1804. }
  1805. .r_t2 {
  1806. width: 201rpx;
  1807. height: 49rpx;
  1808. background: rgba(22, 119, 255, 0.05);
  1809. border: 1rpx solid #32467b;
  1810. border-radius: 16rpx;
  1811. color: #666666;
  1812. font-size: 23rpx;
  1813. text-align: center;
  1814. display: flex;
  1815. align-items: center;
  1816. padding: 5rpx;
  1817. }
  1818. .scroll_box {
  1819. width: 100%;
  1820. height: 60rpx;
  1821. background: #ffffff;
  1822. box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(145, 156, 178, 0.1);
  1823. white-space: nowrap;
  1824. overflow: hidden;
  1825. margin: 15rpx 0;
  1826. }
  1827. .r_sliper {
  1828. padding: 0 20rpx;
  1829. }
  1830. .top_line {
  1831. width: 6rpx;
  1832. height: 22rpx;
  1833. background: #32467b;
  1834. margin-right: 10rpx;
  1835. }
  1836. .video_t2 {
  1837. font-size: 24rpx;
  1838. font-family: PingFang SC;
  1839. font-weight: 500;
  1840. color: #666666;
  1841. }
  1842. .video_t1 {
  1843. height: 80rpx;
  1844. color: #333333;
  1845. line-height: 80rpx;
  1846. font-size: 30rpx;
  1847. font-family: PingFang SC;
  1848. font-weight: bold;
  1849. color: #333333;
  1850. overflow: hidden;
  1851. text-overflow: ellipsis;
  1852. white-space: nowrap;
  1853. }
  1854. .video_t1_t {
  1855. display: flex;
  1856. flex-direction: column;
  1857. height: 80rpx;
  1858. color: #333333;
  1859. text-align: center;
  1860. align-items: center;
  1861. border-left: solid 1px #d6d6db;
  1862. }
  1863. .video_play {
  1864. position: absolute;
  1865. width: 95rpx;
  1866. height: 95rpx;
  1867. top: 0;
  1868. left: 0;
  1869. right: 0;
  1870. bottom: 0;
  1871. margin: auto;
  1872. }
  1873. .video_box {
  1874. position: relative;
  1875. }
  1876. .rotoct {
  1877. transform: rotate(90deg);
  1878. }
  1879. </style>