detail.vue 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259
  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 class="video_box" style="width: 100%;height: 460rpx;">
  9. <polyv-player
  10. id="playerVideo"
  11. playerId="playerVideo"
  12. height="460rpx"
  13. :vid="vid"
  14. :showSettingBtn="true"
  15. :enablePlayGesture="true"
  16. @statechange="onStateChange"
  17. :autoplay="autoplay"
  18. :isAllowSeek="isAllowSeek"
  19. :playbackRate="playbackRate"
  20. :startTime="startTime"
  21. ></polyv-player>
  22. </view>
  23. <view>
  24. <u-row>
  25. <u-col span="10">
  26. <view class="video_t1">{{ detail.courseName }}</view>
  27. </u-col>
  28. <u-col span="2">
  29. <view class="video_t1_t" @click="openPhoto">
  30. <image src="/static/icon/jy_icon.png" style="width: 40rpx;height: 40rpx;"></image>
  31. 讲义
  32. </view>
  33. </u-col>
  34. </u-row>
  35. </view>
  36. <u-line color="#D6D6DB" />
  37. <view style="display: flex;justify-content: center;">
  38. <view style="width: 280px;"><u-tabs :list="list" font-size="24" bar-width="80" :current="current" @change="change" active-color="#007AFF"></u-tabs></view>
  39. </view>
  40. <u-line color="#D6D6DB" />
  41. </view>
  42. <view class="box">
  43. <!--目录 -->
  44. <view v-show="current == 0">
  45. <view class="menuBox" v-for="(item, index) in reMenuList">
  46. <!--模块 -->
  47. <view v-if="item.type == 1"><courseModule :gradeId="gradeId" :isRebuild="true" :isBuy="true" :menuItem="item" :levelId="item.menuId"></courseModule></view>
  48. <!--章 -->
  49. <view v-if="item.type == 2">
  50. <courseChapter :gradeId="gradeId" :isRebuild="true" :isBuy="true" :menuItem="item" :levelId="'0-' + item.menuId"></courseChapter>
  51. </view>
  52. <!--节 -->
  53. <view v-if="item.type == 3">
  54. <courseSection :gradeId="gradeId" :isRebuild="true" :isBuy="true" :menuItem="item" :levelId="'0-0-' + item.menuId"></courseSection>
  55. </view>
  56. </view>
  57. </view>
  58. <!--目录 -->
  59. <view v-show="current == 1">
  60. <view class="menuBox" v-for="(item, index) in menuList">
  61. <!--模块 -->
  62. <view v-if="item.type == 1"><courseModule :gradeId="gradeId" :isBuy="true" :menuItem="item" :levelId="item.menuId"></courseModule></view>
  63. <!--章 -->
  64. <view v-if="item.type == 2"><courseChapter :gradeId="gradeId" :isBuy="true" :menuItem="item" :levelId="'0-' + item.menuId"></courseChapter></view>
  65. <!--节 -->
  66. <view v-if="item.type == 3"><courseSection :gradeId="gradeId" :isBuy="true" :menuItem="item" :levelId="'0-0-' + item.menuId"></courseSection></view>
  67. </view>
  68. </view>
  69. <!--笔记 -->
  70. <view v-show="current == 2">
  71. <view v-if="noteList.length == 0" style="text-align: center;">暂无笔记</view>
  72. <view class="inputBottom">
  73. <view style="width: 10%;"><image src="/static/icon/note3.png" style="width: 39rpx;height: 39rpx;margin:0 29rpx;"></image></view>
  74. <view style="width: 73%;height: 88rpx;margin-bottom: 15rpx;">
  75. <u-input height="78" fixed="true" placeholder="您可以在这里输入笔记内容" type="textarea" :custom-style="inputStyle" v-model="noteValue" />
  76. </view>
  77. <view style="color: #007AFF;font-size: 30rpx;font-weight: bold;width: 15%;text-align: center;" @click="postNote">提交</view>
  78. </view>
  79. <view v-for="(item, index) in noteList">
  80. <view class="dateBox">{{ $method.timestampToTime(item.dateNote) }}</view>
  81. <view class="noteBox">
  82. <view v-for="(item1, index1) in item.userNotes" style="margin-top: 30rpx;" @click="jumpNote(item1)">
  83. <view style="display: flex;">
  84. <view>
  85. <view>
  86. <image src="/static/icon/note2.png" v-if="noteId != item1.noteId" style="width: 39rpx;height: 39rpx;margin:0 29rpx;"></image>
  87. <image src="/static/icon/note1.png" v-if="noteId == item1.noteId" style="width: 39rpx;height: 39rpx;margin:0 29rpx;"></image>
  88. </view>
  89. <view class="title" style="width: 39rpx;height: 39rpx;margin:0 29rpx;">{{ $method.secondToDate(item1.noteSecond) }}</view>
  90. </view>
  91. <view style="margin-left: 10rpx;">
  92. <view class="t2Content leftPadding">{{ item1.sectionName }}</view>
  93. <view class="tBox2">{{ item1.noteText }}</view>
  94. </view>
  95. </view>
  96. </view>
  97. </view>
  98. </view>
  99. </view>
  100. <!--答疑 -->
  101. <view v-show="current == 3">
  102. <view class="inputBottom">
  103. <view style="width: 73%;height: 88rpx;margin-bottom: 15rpx;margin-left: 10% ;">
  104. <u-input height="78" fixed="true" :placeholder="placeholder" type="textarea" :custom-style="inputStyle" v-model="ctxValue" />
  105. </view>
  106. <view style="color: #007AFF;font-size: 30rpx;font-weight: bold;width: 15%;text-align: center;" @click="postContent">提交</view>
  107. </view>
  108. <view v-for="(item, index) in answerList" style="background-color: #FFFFFF;margin-bottom: 20rpx;">
  109. <view class="chat_box" @click.stop="clearCtx">
  110. <view style="display: flex;">
  111. <view><image :src="$method.splitImgHost(item.avatar)" style="width: 64rpx;height: 64rpx;"></image></view>
  112. <view style="margin-left: 15rpx;">
  113. <view class="chat1">{{ item.realname }}</view>
  114. <view class="chat2">{{ $method.timestampToTime(item.createTime) }}</view>
  115. <view class="chat3">
  116. <text v-if="item.assignUserId > 0">回复</text>
  117. <text v-if="item.assignUserId > 0" style="color: #007AFF;">@{{ item.assignRealname }}</text>
  118. {{ item.answerText }}
  119. </view>
  120. </view>
  121. </view>
  122. <view class="btnReply" @click.stop="replyContent(item)" v-if="item.userId != userInfo.userId">回复</view>
  123. <view v-else class="btnDel" @click.stop="delContent(item)">删除</view>
  124. </view>
  125. <u-line color="#D6D6DB" />
  126. </view>
  127. <view v-if="answerList.length == 0" style="text-align: center;">暂无记录</view>
  128. </view>
  129. </view>
  130. <!-- 播放前拍照start -->
  131. <u-popup v-model="photoPopup" mode="bottom" border-radius="32" :mask-close-able="false">
  132. <view class="photoBox">
  133. <view class="photoTop">
  134. <view class="sqzz" v-if="false"><u-icon name="close" color="#333333" size="30" @click="closePhoto"></u-icon></view>
  135. <view class="centersq">请正视手机屏幕</view>
  136. <view class="sqzz"></view>
  137. </view>
  138. <view class="photoCenter">
  139. <camera device-position="front" flash="off" @error="error" style="width: 100%; height: 100%" v-if="photoPopup"></camera>
  140. <view class="custom"><image src="@/pages2/static/zhezhao.png" mode=""></image></view>
  141. </view>
  142. <view class="btnResult" @click="takePhoto">拍照</view>
  143. </view>
  144. </u-popup>
  145. <!-- 播放前拍照end -->
  146. </view>
  147. </template>
  148. <script>
  149. import courseModule from '@/components/course/courseModule.vue';
  150. import courseChapter from '@/components/course/courseChapter.vue';
  151. import courseSection from '@/components/course/courseSection.vue';
  152. import { mapGetters } from 'vuex';
  153. export default {
  154. components: {
  155. courseModule,
  156. courseChapter,
  157. courseSection
  158. },
  159. data() {
  160. return {
  161. startStatus: false,
  162. detail: {},
  163. courseId: 0,
  164. placeholder: '您可以在这里输入笔记内容\n还可以点击左侧图标为笔记加上时间标记',
  165. inputStyle: {
  166. background: 'rgba(244, 244, 244, 0.98)',
  167. borderRadius: '24rpx',
  168. padding: '8rpx',
  169. marginBottom: '10rpx'
  170. },
  171. playbackRate: [0.5, 0.8, 1.0],
  172. list: [
  173. {
  174. name: '重修目录'
  175. },
  176. {
  177. name: '目录'
  178. },
  179. {
  180. name: '笔记'
  181. },
  182. {
  183. name: '答疑'
  184. }
  185. ],
  186. menuList: [],
  187. current: 1,
  188. vid: '',
  189. goodsId: 0,
  190. goodsData: {},
  191. photoPopup: false,
  192. goodsPlayConfig: null,
  193. autoplay: false,
  194. isAllowSeek: 'no',
  195. playbackRate: [1.0],
  196. timer: null,
  197. goodsPhotographConfig: null,
  198. intervalTimeList: [], // 间隔拍照时长
  199. intervalTimeIndex: 0, //当前处于哪个时间段拍照
  200. playTime: 0, //页面播放时长,不含暂停
  201. currentTime: 0,
  202. avatarUrl: '',
  203. ossAvatarUrl: '',
  204. studyDuration: 0, // 当前视频时长
  205. gradeId: 0,
  206. chapterId: 0,
  207. moduleId: 0,
  208. reMenuList: [],
  209. answerList: [],
  210. assignUserId: 0,
  211. placeholder: '您可以在这里输入答疑内容',
  212. ctxValue: '',
  213. noteList: [],
  214. noteValue: '',
  215. noteId: 0,
  216. recordObj: 0,
  217. needSeek: false //第一次播放是否需要跳转
  218. };
  219. },
  220. computed: { ...mapGetters(['userInfo', 'playSectionId']) },
  221. onLoad(option) {
  222. this.courseId = Number(option.id);
  223. this.goodsId = Number(option.goodsId);
  224. this.courseDetail();
  225. this.getGoodsDetail();
  226. this.getAnswerList();
  227. },
  228. onShow() {
  229. var self = this;
  230. this.$api.getbaseprofiletplists({ goodsId: self.goodsId }).then(res => {
  231. if (res.data.code === 200 && res.data.rows.length) {
  232. if (res.data.rows[0].keyValue) {
  233. self.$api.getbaseprofiletpgetInfo({ goodsId: self.goodsId }).then(result => {
  234. if (result.data.code === 200) {
  235. if (!result.data.data || (result.data.data.status === 3 && result.data.data.changeStatus === 1)) {
  236. if (!result.data.data) {
  237. uni.showModal({
  238. content: '请前往填写资料',
  239. cancelText: '返回',
  240. success: function(resultst) {
  241. if (resultst.confirm) {
  242. self.$navTo.togo('/pages2/verify/input', {
  243. id: self.goodsId
  244. });
  245. }
  246. if (resultst.cancel) {
  247. uni.navigateBack();
  248. }
  249. }
  250. });
  251. } else {
  252. uni.showModal({
  253. content: '资料审核不通过,请前往重新填写',
  254. cancelText: '返回',
  255. success: function(resultst) {
  256. if (resultst.confirm) {
  257. self.$navTo.togo('/pages2/verify/input', {
  258. id: self.goodsId
  259. });
  260. }
  261. if (resultst.cancel) {
  262. uni.navigateBack();
  263. }
  264. }
  265. });
  266. }
  267. } else if (result.data.data.status === 1 && res.data.rows[0].keyValue2) {
  268. self.$api.getbaseprofileStampgetInfo({ goodsId: self.goodsId }).then(k => {
  269. if (k.data.code === 200) {
  270. if (!k.data.data || (k.data.data.status === 3 && k.data.data.changeStatus === 1)) {
  271. if (!k.data.data) {
  272. uni.showModal({
  273. cancelText: '返回',
  274. content: '请前往填写盖章资料',
  275. success: function(resultst) {
  276. if (resultst.confirm) {
  277. self.$navTo.togo('/pages2/verify/input2', {
  278. id: self.goodsId
  279. });
  280. }
  281. if (resultst.cancel) {
  282. uni.navigateBack();
  283. }
  284. }
  285. });
  286. } else {
  287. uni.showModal({
  288. cancelText: '返回',
  289. content: '资料盖章审核不通过,请前往重新填写',
  290. success: function(resultst) {
  291. if (resultst.confirm) {
  292. self.$navTo.togo('/pages2/verify/input2', {
  293. id: self.goodsId
  294. });
  295. }
  296. if (resultst.cancel) {
  297. uni.navigateBack();
  298. }
  299. }
  300. });
  301. }
  302. }
  303. }
  304. });
  305. }
  306. }
  307. });
  308. }
  309. }
  310. });
  311. },
  312. onUnload() {
  313. if (this.playSectionId > 0) {
  314. //退出提交记录
  315. this.ossAvatarUrl = '';
  316. this.postStudyRecord();
  317. //清除正在播放的节ID
  318. this.$store.commit('setPlaySectionId', { playSectionId: 0 });
  319. //移除所有的事件监听器
  320. uni.$off();
  321. }
  322. },
  323. mounted() {
  324. uni.$on('changeSection', oldSectionId => {
  325. this.ossAvatarUrl = '';
  326. this.postStudyRecord(0, oldSectionId);
  327. });
  328. uni.$on('getSection', item => {
  329. this.playVideo(item);
  330. });
  331. uni.$on('levelId', item => {
  332. let arr = item.split('-');
  333. //点击节获取的各层级ID
  334. this.moduleId = arr[0];
  335. this.chapterId = arr[1];
  336. console.log(item, 99);
  337. });
  338. },
  339. methods: {
  340. async playVideo(item) {
  341. if (this.timer) {
  342. clearInterval(this.timer);
  343. }
  344. if (this.vid) {
  345. //切换视频
  346. var polyvPlayerContext = this.selectComponent('#playerVideo');
  347. polyvPlayerContext.changeVid(item.recordingUrl);
  348. } else {
  349. this.vid = item.recordingUrl;
  350. }
  351. this.recordObj = await this.getRecordLast();
  352. if (this.recordObj.studyDuration) {
  353. this.needSeek = true; //需要跳转到播放记录
  354. }
  355. console.log(this.startTime, 789);
  356. this.startStatus = true;
  357. //获取节笔记
  358. this.getNoteList();
  359. },
  360. getRecordLast() {
  361. let self = this;
  362. return new Promise(resolve => {
  363. let data = {
  364. gradeId: Number(self.gradeId),
  365. goodsId: Number(self.goodsId),
  366. sectionId: Number(self.playSectionId),
  367. courseId: Number(self.courseId)
  368. };
  369. self.$api.recordLast(data).then(res => {
  370. resolve(res.data.data);
  371. });
  372. });
  373. },
  374. jumpNote(item) {
  375. this.noteId = item.noteId;
  376. this.$u.toast('即将跳到笔记位置');
  377. //跳到笔记时刻
  378. var polyvPlayerContext = this.selectComponent('#playerVideo');
  379. polyvPlayerContext.seek(item.noteSecond);
  380. polyvPlayerContext.play();
  381. },
  382. postNote() {
  383. let self = this;
  384. if (!(this.playSectionId > 0)) {
  385. this.$u.toast('目前无播放视频');
  386. return;
  387. }
  388. if (!this.noteValue) {
  389. this.$u.toast('请输入内容');
  390. return;
  391. }
  392. var polyvPlayerContext = this.selectComponent('#playerVideo');
  393. let noteDate = this.$method.getZeroTime();
  394. let noteSecond = polyvPlayerContext.getCurrentTime();
  395. if (!noteSecond) {
  396. this.$u.toast('视频暂未开始');
  397. return;
  398. }
  399. let data = {
  400. gradeId: this.gradeId,
  401. goodsId: this.goodsId,
  402. sectionId: this.playSectionId,
  403. courseId: this.courseId,
  404. noteText: this.noteValue,
  405. noteDate: noteDate,
  406. noteSecond: noteSecond
  407. };
  408. this.$api.postNote(data).then(res => {
  409. if (res.data.code == 200) {
  410. this.$u.toast('发布成功');
  411. self.getNoteList();
  412. this.noteValue = '';
  413. }
  414. });
  415. },
  416. getNoteList() {
  417. let self = this;
  418. this.$api.noteList({ sectionId: this.playSectionId, courseId: this.courseId, gradeId: this.gradeId, goodsId: this.goodsId }).then(res => {
  419. if (res.data.code == 200) {
  420. self.noteList = res.data.rows;
  421. }
  422. });
  423. },
  424. delAnswer(answerId) {
  425. let self = this;
  426. let data = { answerId: answerId, status: -1 };
  427. this.$api.delAnswer(data).then(res => {
  428. if (res.data.code == 200) {
  429. self.getAnswerList();
  430. }
  431. });
  432. },
  433. clearCtx() {
  434. console.log(4234);
  435. this.placeholder = '您可以在这里输入答疑内容';
  436. this.ctxValue = '';
  437. this.assignUserId = 0;
  438. },
  439. replyContent(item) {
  440. this.assignUserId = item.userId;
  441. this.placeholder = '@' + item.realname;
  442. },
  443. delContent(item) {
  444. this.delAnswer(item.answerId);
  445. },
  446. postAnswer() {
  447. let self = this;
  448. let data = { courseId: this.courseId, answerText: this.ctxValue };
  449. if (this.assignUserId > 0) {
  450. data.assignUserId = this.assignUserId;
  451. }
  452. this.$api.postAnswer(data).then(res => {
  453. if (res.data.code == 200) {
  454. this.$u.toast('发布成功');
  455. self.getAnswerList();
  456. this.placeholder = '您可以在这里输入答疑内容';
  457. this.ctxValue = '';
  458. this.assignUserId = 0;
  459. }
  460. });
  461. },
  462. postContent() {
  463. if (!this.ctxValue) {
  464. this.$u.toast('请输入内容');
  465. }
  466. this.postAnswer();
  467. },
  468. postStudyRecord(status = 0, sectionId = this.playSectionId) {
  469. let currentTime = 0;
  470. var polyvPlayerContext = this.selectComponent('#playerVideo');
  471. if (polyvPlayerContext) {
  472. currentTime = polyvPlayerContext.getCurrentTime();
  473. }
  474. let self = this;
  475. let data = {
  476. photo: self.ossAvatarUrl,
  477. sectionId: parseInt(sectionId),
  478. goodsId: parseInt(self.goodsId),
  479. courseId: parseInt(self.courseId),
  480. studyDuration: parseInt(currentTime > 0 ? currentTime : self.studyDuration),
  481. gradeId: parseInt(self.gradeId),
  482. chapterId: parseInt(self.chapterId),
  483. moduleId: parseInt(self.moduleId)
  484. };
  485. if (data.studyDuration <= 5) {
  486. //5秒内不上传记录
  487. return;
  488. }
  489. if (status > 0) {
  490. data.status = status;
  491. }
  492. console.log('提交接口', data);
  493. this.$api.studyRecord(data).then(res => {
  494. console.log(res);
  495. });
  496. },
  497. uploadFile(options, int) {
  498. var self = this;
  499. return new Promise((resolve, reject) => {
  500. var data = {
  501. imageStatus: int
  502. };
  503. self.$api.aliyunpolicy(data).then(res => {
  504. if (res.data.code != 200) {
  505. self.$method.showToast('签名错误' + JSON.stringify(res.data));
  506. return;
  507. }
  508. var ossToken = res.data.data.resultContent;
  509. if (ossToken.host == null || ossToken.host == undefined) {
  510. self.$method.showToast('上传路径报错' + JSON.stringify(res.data));
  511. return;
  512. }
  513. uni.uploadFile({
  514. url: ossToken.host,
  515. name: 'file',
  516. filePath: options,
  517. fileType: 'image',
  518. header: {
  519. AuthorizationToken: 'WX ' + uni.getStorageSync('token')
  520. },
  521. formData: {
  522. key: ossToken.dir,
  523. OSSAccessKeyId: ossToken.accessid,
  524. policy: ossToken.policy,
  525. Signature: ossToken.signature,
  526. callback: ossToken.callback,
  527. success_action_status: 200
  528. },
  529. success: result => {
  530. if (result.statusCode === 200) {
  531. self.ossAvatarUrl = ossToken.dir;
  532. resolve();
  533. } else {
  534. uni.showToast({
  535. title: '上传失败',
  536. icon: 'none'
  537. });
  538. return;
  539. }
  540. },
  541. fail: error => {
  542. uni.showToast({
  543. title: '上传接口报错' + error,
  544. icon: 'none'
  545. });
  546. return;
  547. }
  548. });
  549. });
  550. });
  551. },
  552. imageInfos() {
  553. var self = this;
  554. return new Promise((resolve, reject) => {
  555. uni.getImageInfo({
  556. src: self.avatarUrl,
  557. success: async res => {
  558. let canvasWidth = res.width; //图片原始长宽
  559. let canvasHeight = res.height;
  560. if (canvasWidth > 1000 || canvasHeight > 1000) {
  561. uni.compressImage({
  562. src: self.avatarUrl,
  563. quality: 75,
  564. width: '50%',
  565. height: '50%',
  566. success: async rest => {
  567. const waitUpload = await self.uploadFile(rest.tempFilePath, 0);
  568. resolve();
  569. }
  570. });
  571. } else {
  572. console.log('无需压缩');
  573. const waitUpload = await self.uploadFile(self.avatarUrl, 0);
  574. resolve();
  575. }
  576. }
  577. });
  578. });
  579. },
  580. timeEvent() {
  581. let self = this;
  582. var polyvPlayerContext = this.selectComponent('#playerVideo');
  583. if (polyvPlayerContext != null) {
  584. let PlayCurrentTime = polyvPlayerContext.getVideoPlayDuration();
  585. this.studyDuration = PlayCurrentTime;
  586. if (this.currentTime < PlayCurrentTime) {
  587. this.playTime += PlayCurrentTime - this.currentTime;
  588. this.currentTime = PlayCurrentTime;
  589. } else {
  590. this.currentTime = PlayCurrentTime;
  591. }
  592. //判断是否需要拍照
  593. if (this.intervalTimeList.length > this.intervalTimeIndex) {
  594. let photoTime = Number(this.intervalTimeList[this.intervalTimeIndex]) * 60; //获取拍照秒数
  595. if (photoTime < this.playTime) {
  596. //启动拍照
  597. //暂停
  598. polyvPlayerContext.exitFullScreen();
  599. polyvPlayerContext.pause();
  600. this.openPhoto();
  601. this.intervalTimeIndex++;
  602. }
  603. }
  604. }
  605. },
  606. onStateChange(newstate, oldstate) {
  607. console.log(newstate, 6989);
  608. if (newstate.detail.newstate == 'playing') {
  609. if (this.needSeek) {
  610. var polyvPlayerContext = this.selectComponent('#playerVideo');
  611. polyvPlayerContext.seek(this.recordObj.studyDuration);
  612. polyvPlayerContext.play();
  613. this.needSeek = false;
  614. }
  615. //开始播放
  616. if (this.timer) {
  617. clearInterval(this.timer);
  618. }
  619. this.timer = setInterval(this.timeEvent, 1500); //定时器
  620. }
  621. if (newstate.detail.newstate == 'pause') {
  622. //暂停提交记录
  623. /* this.ossAvatarUrl = ""
  624. this.postStudyRecord() */
  625. }
  626. if (newstate.detail.newstate == 'ended') {
  627. this.ossAvatarUrl = '';
  628. this.postStudyRecord(1);
  629. }
  630. },
  631. //拍照
  632. openPhoto() {
  633. this.photoPopup = true;
  634. },
  635. async submit() {
  636. const waitYS = await this.imageInfos();
  637. this.postStudyRecord(); //提交记录
  638. //恢复播放
  639. var polyvPlayerContext = this.selectComponent('#playerVideo');
  640. if (polyvPlayerContext != null) {
  641. polyvPlayerContext.play();
  642. }
  643. console.log(this.ossAvatarUrl, '拍照完成456');
  644. },
  645. //确认拍照
  646. takePhoto() {
  647. var self = this;
  648. const ctx = uni.createCameraContext();
  649. ctx.takePhoto({
  650. quality: 'high',
  651. success: res => {
  652. console.log(res.tempImagePath);
  653. self.avatarUrl = res.tempImagePath;
  654. self.submit();
  655. self.photoPopup = false;
  656. },
  657. fail: err => {
  658. console.log(err);
  659. }
  660. });
  661. },
  662. //拍照报错
  663. error(e) {
  664. console.log(e.detail);
  665. },
  666. //关闭相机
  667. closePhoto() {
  668. this.photoPopup = false;
  669. },
  670. getGoodsDetail() {
  671. let self = this;
  672. this.$api.goodsDetail(this.goodsId).then(res => {
  673. self.goodsData = res.data.data;
  674. self.gradeId = self.goodsData.gradeId;
  675. console.log(self.gradeId, 698);
  676. self.getMenuList();
  677. self.getReMenuList(); //获取重修目录
  678. if (self.goodsData.goodsPlayConfig) {
  679. self.goodsPlayConfig = JSON.parse(self.goodsData.goodsPlayConfig);
  680. if (self.goodsPlayConfig.autoPlay > 0) {
  681. self.autoplay = true;
  682. }
  683. if (self.goodsPlayConfig.drag > 0) {
  684. self.isAllowSeek = 'yes';
  685. }
  686. if (self.goodsPlayConfig.speed > 0) {
  687. self.playbackRate = [0.5, 0.8, 1.0, 1.25, 1.5, 2.0];
  688. }
  689. }
  690. if (self.goodsData.goodsPhotographConfig) {
  691. self.goodsPhotographConfig = JSON.parse(self.goodsData.goodsPhotographConfig);
  692. if (self.goodsPhotographConfig.intervalTime) {
  693. self.intervalTimeList = self.goodsPhotographConfig.intervalTime.split(',');
  694. }
  695. }
  696. });
  697. },
  698. startVideo() {
  699. this.startStatus = true;
  700. },
  701. getAnswerList() {
  702. let self = this;
  703. this.$api.answerList({ courseId: this.courseId }).then(res => {
  704. if (res.data.code == 200) {
  705. self.answerList = res.data.rows;
  706. }
  707. });
  708. },
  709. getReMenuList() {
  710. let self = this;
  711. this.$api.reMenuList({ courseId: this.courseId, rebuild: 1, gradeId: this.gradeId }).then(res => {
  712. if (res.data.code == 200) {
  713. for (let i = 0; i < res.data.rows.length; i++) {
  714. let item = res.data.rows[i];
  715. item.down = true;
  716. item.id = item.menuId;
  717. item.name = item.menuName;
  718. }
  719. self.reMenuList = res.data.rows;
  720. }
  721. });
  722. },
  723. getMenuList() {
  724. let self = this;
  725. this.$api.reMenuList({ courseId: this.courseId, gradeId: this.gradeId }).then(res => {
  726. if (res.data.code == 200) {
  727. for (let i = 0; i < res.data.rows.length; i++) {
  728. let item = res.data.rows[i];
  729. item.down = true;
  730. item.id = item.menuId;
  731. item.name = item.menuName;
  732. }
  733. self.menuList = res.data.rows;
  734. }
  735. });
  736. },
  737. courseDetail() {
  738. let self = this;
  739. this.$api.courseDetail(this.courseId).then(res => {
  740. if (res.data.code == 200) {
  741. self.detail = res.data.data;
  742. self.gradeId = self.detail.gradeId;
  743. }
  744. });
  745. },
  746. open(item) {
  747. item.showChildren = !item.showChildren;
  748. },
  749. change(index) {
  750. this.current = index;
  751. }
  752. }
  753. };
  754. </script>
  755. <style lang="scss" scope>
  756. .btnReply {
  757. width: 80rpx;
  758. height: 40rpx;
  759. background: #e3f0ff;
  760. border-radius: 16rpx;
  761. text-align: center;
  762. color: #007aff;
  763. }
  764. .btnDel {
  765. width: 80rpx;
  766. height: 40rpx;
  767. background: #ffedf0;
  768. border-radius: 16rpx;
  769. text-align: center;
  770. color: #ff2d55;
  771. }
  772. .btnReply {
  773. width: 80rpx;
  774. height: 40rpx;
  775. background: #e3f0ff;
  776. border-radius: 16rpx;
  777. font-size: 24rpx;
  778. }
  779. .photoBox {
  780. .photoTop {
  781. height: 74upx;
  782. display: flex;
  783. align-items: center;
  784. justify-content: space-between;
  785. padding: 0upx 38upx;
  786. .sqzz {
  787. width: 28upx;
  788. height: 28upx;
  789. display: flex;
  790. align-items: center;
  791. justify-content: center;
  792. }
  793. .centersq {
  794. color: #333;
  795. font-size: 30upx;
  796. font-weight: 500;
  797. }
  798. }
  799. .photoCenter {
  800. width: 750upx;
  801. height: 979upx;
  802. position: relative;
  803. .custom {
  804. width: 750upx;
  805. height: 979upx;
  806. position: absolute;
  807. top: 0;
  808. left: 0;
  809. image {
  810. width: 100%;
  811. height: 100%;
  812. }
  813. }
  814. }
  815. .btnResult {
  816. height: 100upx;
  817. width: 100%;
  818. background-color: #07c160;
  819. text-align: center;
  820. line-height: 100upx;
  821. color: #fff;
  822. font-size: 32upx;
  823. font-weight: bold;
  824. }
  825. }
  826. .chat_box {
  827. display: flex;
  828. padding: 20rpx;
  829. justify-content: space-between;
  830. }
  831. .chat3 {
  832. font-size: 30rpx;
  833. font-family: PingFang SC;
  834. font-weight: 500;
  835. color: #666666;
  836. margin-top: 10rpx;
  837. }
  838. .chat2 {
  839. font-size: 20rpx;
  840. font-family: PingFang SC;
  841. font-weight: 500;
  842. color: #999999;
  843. margin-top: 10rpx;
  844. }
  845. .chat1 {
  846. font-size: 24rpx;
  847. font-family: PingFang SC;
  848. font-weight: 500;
  849. color: #333333;
  850. }
  851. .leftPadding {
  852. margin-left: 8rpx;
  853. }
  854. .t2Content {
  855. font-size: 28rpx;
  856. font-family: PingFang SC;
  857. font-weight: bold;
  858. color: #999999;
  859. line-height: 48rpx;
  860. }
  861. .tBox2 {
  862. display: flex;
  863. padding-top: 10rpx;
  864. color: #333333;
  865. font-size: 30rpx;
  866. }
  867. .tBox {
  868. display: flex;
  869. align-items: center;
  870. padding-top: 10rpx;
  871. }
  872. .title {
  873. font-size: 24rpx;
  874. color: #999999;
  875. }
  876. page {
  877. padding-top: 10px;
  878. padding-top: constant(safe-area-inset-top);
  879. padding-top: env(safe-area-inset-top);
  880. }
  881. .inputBottom {
  882. position: fixed;
  883. left: 0;
  884. bottom: 0;
  885. background: #ffffff;
  886. height: 98rpx;
  887. display: flex;
  888. align-items: center;
  889. width: 100%;
  890. }
  891. .noteBox {
  892. width: 100%;
  893. background: #ffffff;
  894. padding: 10rpx;
  895. border-radius: 16rpx;
  896. }
  897. .dateBox {
  898. width: 216rpx;
  899. height: 48rpx;
  900. background: #ffffff;
  901. border-radius: 24rpx;
  902. font-size: 24rpx;
  903. color: #666666;
  904. text-align: center;
  905. line-height: 48rpx;
  906. margin: 20rpx 0;
  907. }
  908. .t_content1 {
  909. color: #007aff;
  910. margin-left: 10rpx;
  911. }
  912. .tag1 {
  913. border: 2rpx solid #007aff;
  914. border-radius: 8rpx;
  915. font-size: 20rpx;
  916. color: #007aff;
  917. padding: 5rpx;
  918. }
  919. .b_title {
  920. color: #333333;
  921. font-size: 30rpx;
  922. font-weight: bold;
  923. }
  924. page {
  925. background: #eaeef1;
  926. }
  927. .menuBox {
  928. width: 100%;
  929. background: #ffffff;
  930. border-radius: 16rpx;
  931. padding: 20rpx;
  932. margin-bottom: 20rpx;
  933. }
  934. .btnspric {
  935. border-top: 1rpx solid #eee;
  936. display: flex;
  937. align-items: center;
  938. justify-content: space-between;
  939. height: 108rpx;
  940. padding-left: 43rpx;
  941. padding-right: 32rpx;
  942. }
  943. .btnspric > .lefprL {
  944. font-size: 36rpx;
  945. color: #0c141f;
  946. font-weight: bold;
  947. }
  948. .btnspric > .lefprR {
  949. padding: 0rpx 24rpx;
  950. height: 60rpx;
  951. line-height: 60rpx;
  952. text-align: center;
  953. color: #fff;
  954. background: #32467b;
  955. border-radius: 24rpx;
  956. box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(145, 156, 178, 0.1);
  957. }
  958. .yhj,
  959. .hdyhj {
  960. padding: 24rpx 29rpx 24rpx 34rpx;
  961. }
  962. .yhj {
  963. border-bottom: 16rpx solid #f9f9f9;
  964. }
  965. .yhjtit {
  966. font-size: 30rpx;
  967. color: #0c141f;
  968. font-weight: 500;
  969. margin-bottom: 14rpx;
  970. }
  971. .yhjList {
  972. display: flex;
  973. align-items: center;
  974. justify-content: space-between;
  975. margin-bottom: 14rpx;
  976. }
  977. .yhjList > .yhjLefts {
  978. display: flex;
  979. align-items: center;
  980. }
  981. .yhjLefts > .yhl {
  982. color: #32467b;
  983. font-size: 30rpx;
  984. margin-right: 31rpx;
  985. }
  986. .yhjLefts > .yhbq {
  987. font-size: 24rpx;
  988. color: #ff9500;
  989. border-radius: 18rpx;
  990. background-color: rgba(255, 149, 0, 0.2);
  991. border: 2rpx solid #ff9500;
  992. height: 38rpx;
  993. line-height: 38rpx;
  994. padding: 0rpx 16rpx;
  995. }
  996. .ts {
  997. font-size: 24rpx;
  998. color: #999;
  999. margin: 14rpx 0rpx;
  1000. padding-right: 29rpx;
  1001. padding-left: 34rpx;
  1002. }
  1003. .yh {
  1004. padding-top: 20rpx;
  1005. }
  1006. .yh > .yhtitle {
  1007. display: flex;
  1008. align-items: center;
  1009. justify-content: space-between;
  1010. padding-right: 29rpx;
  1011. padding-left: 34rpx;
  1012. }
  1013. .priceBxs {
  1014. display: flex;
  1015. align-items: center;
  1016. }
  1017. .priceBxs > .pricleft {
  1018. border-radius: 24rpx;
  1019. border: 1rpx solid #e91313;
  1020. background-color: rgba(233, 19, 19, 0.1);
  1021. padding: 0rpx 18rpx;
  1022. height: 49rpx;
  1023. line-height: 49rpx;
  1024. text-align: center;
  1025. font-size: 30rpx;
  1026. font-weight: 500;
  1027. color: #e91313;
  1028. margin-right: 13rpx;
  1029. }
  1030. .topBox {
  1031. padding: 32rpx 32rpx 24rpx;
  1032. border-bottom: 1rpx solid #eeeeee;
  1033. }
  1034. .topBox > .boldFonstType {
  1035. font-weight: 500;
  1036. font-size: 30rpx;
  1037. margin: 16rpx 0rpx 23rpx;
  1038. }
  1039. .topBox > .firstTopL {
  1040. display: flex;
  1041. align-items: center;
  1042. }
  1043. .topBox > .firstTopL > .imageBs {
  1044. width: 331rpx;
  1045. height: 160rpx;
  1046. border-radius: 6rpx;
  1047. overflow: hidden;
  1048. margin-right: 8rpx;
  1049. box-shadow: 0rpx 6rpx 6rpx 0rpx rgba(47, 67, 121, 0.08);
  1050. }
  1051. .topBox > .firstTopL > .imageBs > image {
  1052. width: 100%;
  1053. height: 100%;
  1054. }
  1055. .topBox > .firstTopL > .textBs {
  1056. font-size: 30rpx;
  1057. font-weight: bold;
  1058. color: #0c141f;
  1059. }
  1060. .content {
  1061. padding: 24rpx;
  1062. text-align: left;
  1063. }
  1064. .catalogBox {
  1065. display: flex;
  1066. align-items: center;
  1067. flex-wrap: nowrap;
  1068. overflow-x: auto;
  1069. padding-left: 38rpx;
  1070. max-height: 305rpx;
  1071. overflow-y: auto;
  1072. transition: all 0.4s;
  1073. }
  1074. .catalogBox > .catalogA {
  1075. min-width: 200rpx;
  1076. height: 48rpx;
  1077. line-height: 48rpx;
  1078. // text-align: center;
  1079. border: 2rpx solid transparent;
  1080. white-space: nowrap;
  1081. text-overflow: ellipsis;
  1082. overflow: hidden;
  1083. word-break: break-all;
  1084. border-radius: 10rpx;
  1085. background: rgba(22, 119, 255, 0.05);
  1086. padding-left: 19rpx;
  1087. box-sizing: border-box;
  1088. padding-right: 15rpx;
  1089. margin-right: 16rpx;
  1090. margin-bottom: 20rpx;
  1091. margin-top: 15rpx;
  1092. font-size: 24rpx;
  1093. color: #666;
  1094. }
  1095. .catalogBox > .activesq {
  1096. border-color: #1677ff;
  1097. }
  1098. .changeCatalogBox {
  1099. display: block;
  1100. }
  1101. .catalogBox::-webkit-scrollbar {
  1102. display: none; /* Chrome Safari */
  1103. }
  1104. .box {
  1105. position: relative;
  1106. top: 650rpx;
  1107. padding-bottom: 88rpx;
  1108. margin: 20rpx;
  1109. }
  1110. .price_t2 {
  1111. font-size: 18rpx;
  1112. font-family: PingFang SC;
  1113. font-weight: 500;
  1114. text-decoration: line-through;
  1115. color: #999999;
  1116. }
  1117. .price_t1 {
  1118. font-size: 33rpx;
  1119. font-family: PingFang SC;
  1120. font-weight: bold;
  1121. color: #e91313;
  1122. }
  1123. .sc_t {
  1124. font-size: 22rpx;
  1125. color: #000000;
  1126. }
  1127. .sc {
  1128. width: 29rpx;
  1129. height: 29rpx;
  1130. }
  1131. .buy {
  1132. width: 138rpx;
  1133. height: 48rpx;
  1134. line-height: 48rpx;
  1135. background: #32467b;
  1136. border-radius: 10rpx;
  1137. color: #ffffff;
  1138. font-size: 28rpx;
  1139. text-align: center;
  1140. vertical-align: middle;
  1141. position: absolute;
  1142. right: 30rpx;
  1143. }
  1144. .video_body {
  1145. padding-bottom: 96rpx;
  1146. }
  1147. .footer_tab {
  1148. position: fixed;
  1149. bottom: 0;
  1150. height: 96rpx;
  1151. width: 100%;
  1152. background-color: #ffffff;
  1153. }
  1154. .tj_box {
  1155. width: 50%;
  1156. display: inline-block;
  1157. text-align: center;
  1158. margin: 10rpx 0;
  1159. }
  1160. .teacher_t {
  1161. font-size: 24rpx;
  1162. font-family: PingFang SC;
  1163. font-weight: 400;
  1164. color: #666666;
  1165. line-height: 36rpx;
  1166. margin-left: 15rpx;
  1167. }
  1168. .teacher_img {
  1169. width: 87rpx;
  1170. height: 129rpx;
  1171. }
  1172. .t2 {
  1173. font-size: 24rpx;
  1174. font-family: PingFang SC;
  1175. color: #666666;
  1176. line-height: 36rpx;
  1177. margin: 15rpx;
  1178. }
  1179. .r_t2 {
  1180. width: 201rpx;
  1181. height: 49rpx;
  1182. background: rgba(22, 119, 255, 0.05);
  1183. border: 1rpx solid #32467b;
  1184. border-radius: 16rpx;
  1185. color: #666666;
  1186. font-size: 23rpx;
  1187. text-align: center;
  1188. display: flex;
  1189. align-items: center;
  1190. padding: 5rpx;
  1191. }
  1192. .scroll_box {
  1193. width: 100%;
  1194. height: 60rpx;
  1195. background: #ffffff;
  1196. box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(145, 156, 178, 0.1);
  1197. white-space: nowrap;
  1198. overflow: hidden;
  1199. margin: 15rpx 0;
  1200. }
  1201. .r_sliper {
  1202. padding: 0 20rpx;
  1203. }
  1204. .top_line {
  1205. width: 6rpx;
  1206. height: 22rpx;
  1207. background: #32467b;
  1208. margin-right: 10rpx;
  1209. }
  1210. .video_t2 {
  1211. font-size: 24rpx;
  1212. font-family: PingFang SC;
  1213. font-weight: 500;
  1214. color: #666666;
  1215. }
  1216. .video_t1 {
  1217. height: 80rpx;
  1218. color: #333333;
  1219. line-height: 80rpx;
  1220. font-size: 30rpx;
  1221. font-family: PingFang SC;
  1222. font-weight: bold;
  1223. color: #333333;
  1224. overflow: hidden;
  1225. text-overflow: ellipsis;
  1226. white-space: nowrap;
  1227. }
  1228. .video_t1_t {
  1229. display: flex;
  1230. flex-direction: column;
  1231. height: 80rpx;
  1232. color: #333333;
  1233. text-align: center;
  1234. align-items: center;
  1235. border-left: solid 1px #d6d6db;
  1236. }
  1237. .video_play {
  1238. position: absolute;
  1239. width: 95rpx;
  1240. height: 95rpx;
  1241. top: 0;
  1242. left: 0;
  1243. right: 0;
  1244. bottom: 0;
  1245. margin: auto;
  1246. }
  1247. .video_box {
  1248. position: relative;
  1249. }
  1250. .rotoct {
  1251. transform: rotate(90deg);
  1252. }
  1253. </style>