detail.vue 50 KB

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