detail.vue 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264
  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="openJY">
  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><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 menuList">
  46. <!--模块 -->
  47. <view v-if="item.type == 1"><courseModule :gradeId="gradeId" :isBuy="true" :menuItem="item" :levelId="item.menuId"></courseModule></view>
  48. <!--章 -->
  49. <view v-if="item.type == 2"><courseChapter :gradeId="gradeId" :isBuy="true" :menuItem="item" :levelId="'0-' + item.menuId"></courseChapter></view>
  50. <!--节 -->
  51. <view v-if="item.type == 3"><courseSection :gradeId="gradeId" :isBuy="true" :menuItem="item" :levelId="'0-0-' + item.menuId"></courseSection></view>
  52. </view>
  53. </view>
  54. <!--笔记 -->
  55. <view v-show="current == 1">
  56. <view v-if="noteList.length == 0" style="text-align: center;">暂无笔记</view>
  57. <view class="inputBottom">
  58. <view style="width: 10%;"><image src="/static/icon/note3.png" style="width: 39rpx;height: 39rpx;margin:0 29rpx;"></image></view>
  59. <view style="width: 73%;height: 88rpx;margin-bottom: 15rpx;">
  60. <u-input height="78" fixed="true" placeholder="您可以在这里输入笔记内容" type="textarea" :custom-style="inputStyle" v-model="noteValue" />
  61. </view>
  62. <view style="color: #007AFF;font-size: 30rpx;font-weight: bold;width: 15%;text-align: center;" @click="postNote">提交</view>
  63. </view>
  64. <view v-for="(item, index) in noteList">
  65. <view class="dateBox">{{ $method.timestampToTime(item.dateNote) }}</view>
  66. <view class="noteBox">
  67. <view v-for="(item1, index1) in item.userNotes" style="margin-top: 30rpx;" @click="jumpNote(item1)">
  68. <view style="display: flex;">
  69. <view>
  70. <view>
  71. <image src="/static/icon/note2.png" v-if="noteId != item1.noteId" style="width: 39rpx;height: 39rpx;margin:0 29rpx;"></image>
  72. <image src="/static/icon/note1.png" v-if="noteId == item1.noteId" style="width: 39rpx;height: 39rpx;margin:0 29rpx;"></image>
  73. </view>
  74. <view class="title" style="width: 39rpx;height: 39rpx;margin:0 29rpx;">{{ $method.secondToDate(item1.noteSecond) }}</view>
  75. </view>
  76. <view style="margin-left: 10rpx;">
  77. <view class="t2Content leftPadding">{{ item1.sectionName }}</view>
  78. <view class="tBox2">{{ item1.noteText }}</view>
  79. </view>
  80. </view>
  81. </view>
  82. </view>
  83. </view>
  84. </view>
  85. <!--答疑 -->
  86. <view v-show="current == 2">
  87. <view class="inputBottom">
  88. <view style="width: 73%;height: 88rpx;margin-bottom: 15rpx;margin-left: 10% ;">
  89. <u-input height="78" fixed="true" :placeholder="placeholder" type="textarea" :custom-style="inputStyle" v-model="ctxValue" />
  90. </view>
  91. <view style="color: #007AFF;font-size: 30rpx;font-weight: bold;width: 15%;text-align: center;" @click="postContent">提交</view>
  92. </view>
  93. <view v-for="(item, index) in answerList" style="background-color: #FFFFFF;margin-bottom: 20rpx;">
  94. <view class="chat_box" @click.stop="clearCtx">
  95. <view style="display: flex;">
  96. <view><image :src="$method.splitImgHost(item.avatar)" style="width: 64rpx;height: 64rpx;"></image></view>
  97. <view style="margin-left: 15rpx;">
  98. <view class="chat1">{{ item.realname }}</view>
  99. <view class="chat2">{{ $method.timestampToTime(item.createTime) }}</view>
  100. <view class="chat3">
  101. <text v-if="item.assignUserId > 0">回复</text>
  102. <text v-if="item.assignUserId > 0" style="color: #007AFF;">@{{ item.assignRealname }}</text>
  103. {{ item.answerText }}
  104. </view>
  105. </view>
  106. </view>
  107. <view class="btnReply" @click.stop="replyContent(item)" v-if="item.userId != userInfo.userId">回复</view>
  108. <view v-else class="btnDel" @click.stop="delContent(item)">删除</view>
  109. </view>
  110. <u-line color="#D6D6DB" />
  111. </view>
  112. <view v-if="answerList.length == 0" style="text-align: center;">暂无记录</view>
  113. </view>
  114. <!--目录 -->
  115. <view v-show="current == 3" >
  116. <view class="menuBox" v-for="(item, index) in reMenuList">
  117. <!--模块 -->
  118. <view v-if="item.type == 1"><courseModule :gradeId="gradeId" :isRebuild="true" :isBuy="true" :menuItem="item" :levelId="item.menuId"></courseModule></view>
  119. <!--章 -->
  120. <view v-if="item.type == 2">
  121. <courseChapter :gradeId="gradeId" :isRebuild="true" :isBuy="true" :menuItem="item" :levelId="'0-' + item.menuId"></courseChapter>
  122. </view>
  123. <!--节 -->
  124. <view v-if="item.type == 3">
  125. <courseSection :gradeId="gradeId" :isRebuild="true" :isBuy="true" :menuItem="item" :levelId="'0-0-' + item.menuId"></courseSection>
  126. </view>
  127. </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. menuList: [],
  184. current: 0,
  185. vid: '',
  186. goodsId: 0,
  187. goodsData: {},
  188. photoPopup: false,
  189. goodsPlayConfig: null,
  190. autoplay: false,
  191. isAllowSeek: 'no',
  192. playbackRate: [1.0],
  193. timer: null,
  194. goodsPhotographConfig: null,
  195. intervalTimeList: [], // 间隔拍照时长
  196. intervalTimeIndex: 0, //当前处于哪个时间段拍照
  197. playTime: 0, //页面播放时长,不含暂停
  198. currentTime: 0,
  199. avatarUrl: '',
  200. ossAvatarUrl: '',
  201. studyDuration: 0, // 当前视频时长
  202. gradeId: 0,
  203. chapterId: 0,
  204. moduleId: 0,
  205. reMenuList: [],
  206. answerList: [],
  207. assignUserId: 0,
  208. placeholder: '您可以在这里输入答疑内容',
  209. ctxValue: '',
  210. noteList: [],
  211. noteValue: '',
  212. noteId: 0,
  213. recordObj: 0,
  214. needSeek: false //第一次播放是否需要跳转
  215. };
  216. },
  217. computed: { ...mapGetters(['userInfo', 'playSectionId']) },
  218. onLoad(option) {
  219. this.courseId = Number(option.id);
  220. this.goodsId = Number(option.goodsId);
  221. this.courseDetail();
  222. this.getGoodsDetail();
  223. this.getAnswerList();
  224. },
  225. onShow() {
  226. var self = this;
  227. this.$api.getbaseprofiletplists({ goodsId: self.goodsId }).then(res => {
  228. if (res.data.code === 200 && res.data.rows.length) {
  229. if (res.data.rows[0].keyValue) {
  230. self.$api.getbaseprofiletpgetInfo({ goodsId: self.goodsId }).then(result => {
  231. if (result.data.code === 200) {
  232. if (!result.data.data || (result.data.data.status === 3 && result.data.data.changeStatus === 1)) {
  233. if (!result.data.data) {
  234. uni.showModal({
  235. content: '请前往填写资料',
  236. cancelText: '返回',
  237. success: function(resultst) {
  238. if (resultst.confirm) {
  239. self.$navTo.togo('/pages2/verify/input', {
  240. id: self.goodsId
  241. });
  242. }
  243. if (resultst.cancel) {
  244. uni.navigateBack();
  245. }
  246. }
  247. });
  248. } else {
  249. uni.showModal({
  250. content: '资料审核不通过,请前往重新填写',
  251. cancelText: '返回',
  252. success: function(resultst) {
  253. if (resultst.confirm) {
  254. self.$navTo.togo('/pages2/verify/input', {
  255. id: self.goodsId
  256. });
  257. }
  258. if (resultst.cancel) {
  259. uni.navigateBack();
  260. }
  261. }
  262. });
  263. }
  264. } else if (result.data.data.status === 1 && res.data.rows[0].keyValue2) {
  265. self.$api.getbaseprofileStampgetInfo({ goodsId: self.goodsId }).then(k => {
  266. if (k.data.code === 200) {
  267. if (!k.data.data || (k.data.data.status === 3 && k.data.data.changeStatus === 1)) {
  268. if (!k.data.data) {
  269. uni.showModal({
  270. cancelText: '返回',
  271. content: '请前往填写盖章资料',
  272. success: function(resultst) {
  273. if (resultst.confirm) {
  274. self.$navTo.togo('/pages2/verify/input2', {
  275. id: self.goodsId
  276. });
  277. }
  278. if (resultst.cancel) {
  279. uni.navigateBack();
  280. }
  281. }
  282. });
  283. } else {
  284. uni.showModal({
  285. cancelText: '返回',
  286. content: '资料盖章审核不通过,请前往重新填写',
  287. success: function(resultst) {
  288. if (resultst.confirm) {
  289. self.$navTo.togo('/pages2/verify/input2', {
  290. id: self.goodsId
  291. });
  292. }
  293. if (resultst.cancel) {
  294. uni.navigateBack();
  295. }
  296. }
  297. });
  298. }
  299. }
  300. }
  301. });
  302. }
  303. }
  304. });
  305. }
  306. }
  307. });
  308. },
  309. onUnload() {
  310. if (this.playSectionId > 0) {
  311. //退出提交记录
  312. this.ossAvatarUrl = '';
  313. this.postStudyRecord();
  314. //清除正在播放的节ID
  315. this.$store.commit('setPlaySectionId', { playSectionId: 0 });
  316. //移除所有的事件监听器
  317. uni.$off();
  318. }
  319. },
  320. mounted() {
  321. uni.$on('changeSection', oldSectionId => {
  322. this.ossAvatarUrl = '';
  323. this.postStudyRecord(0, oldSectionId);
  324. });
  325. uni.$on('getSection', item => {
  326. this.playVideo(item);
  327. });
  328. uni.$on('levelId', item => {
  329. let arr = item.split('-');
  330. //点击节获取的各层级ID
  331. this.moduleId = arr[0];
  332. this.chapterId = arr[1];
  333. console.log(item, 99);
  334. });
  335. },
  336. methods: {
  337. openJY(){
  338. this.$u.toast('此功能正在开发中');
  339. },
  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. if(self.reMenuList.length>0){
  721. self.list.push({name:'重修目录'})
  722. }
  723. }
  724. });
  725. },
  726. getMenuList() {
  727. let self = this;
  728. this.$api.reMenuList({ courseId: this.courseId, gradeId: this.gradeId }).then(res => {
  729. if (res.data.code == 200) {
  730. for (let i = 0; i < res.data.rows.length; i++) {
  731. let item = res.data.rows[i];
  732. item.down = true;
  733. item.id = item.menuId;
  734. item.name = item.menuName;
  735. }
  736. self.menuList = res.data.rows;
  737. }
  738. });
  739. },
  740. courseDetail() {
  741. let self = this;
  742. this.$api.courseDetail(this.courseId).then(res => {
  743. if (res.data.code == 200) {
  744. self.detail = res.data.data;
  745. self.gradeId = self.detail.gradeId;
  746. }
  747. });
  748. },
  749. open(item) {
  750. item.showChildren = !item.showChildren;
  751. },
  752. change(index) {
  753. this.current = index;
  754. }
  755. }
  756. };
  757. </script>
  758. <style lang="scss" scope>
  759. .btnReply {
  760. width: 80rpx;
  761. height: 40rpx;
  762. background: #e3f0ff;
  763. border-radius: 16rpx;
  764. text-align: center;
  765. color: #007aff;
  766. }
  767. .btnDel {
  768. width: 80rpx;
  769. height: 40rpx;
  770. background: #ffedf0;
  771. border-radius: 16rpx;
  772. text-align: center;
  773. color: #ff2d55;
  774. }
  775. .btnReply {
  776. width: 80rpx;
  777. height: 40rpx;
  778. background: #e3f0ff;
  779. border-radius: 16rpx;
  780. font-size: 24rpx;
  781. }
  782. .photoBox {
  783. .photoTop {
  784. height: 74upx;
  785. display: flex;
  786. align-items: center;
  787. justify-content: space-between;
  788. padding: 0upx 38upx;
  789. .sqzz {
  790. width: 28upx;
  791. height: 28upx;
  792. display: flex;
  793. align-items: center;
  794. justify-content: center;
  795. }
  796. .centersq {
  797. color: #333;
  798. font-size: 30upx;
  799. font-weight: 500;
  800. }
  801. }
  802. .photoCenter {
  803. width: 750upx;
  804. height: 979upx;
  805. position: relative;
  806. .custom {
  807. width: 750upx;
  808. height: 979upx;
  809. position: absolute;
  810. top: 0;
  811. left: 0;
  812. image {
  813. width: 100%;
  814. height: 100%;
  815. }
  816. }
  817. }
  818. .btnResult {
  819. height: 100upx;
  820. width: 100%;
  821. background-color: #07c160;
  822. text-align: center;
  823. line-height: 100upx;
  824. color: #fff;
  825. font-size: 32upx;
  826. font-weight: bold;
  827. }
  828. }
  829. .chat_box {
  830. display: flex;
  831. padding: 20rpx;
  832. justify-content: space-between;
  833. }
  834. .chat3 {
  835. font-size: 30rpx;
  836. font-family: PingFang SC;
  837. font-weight: 500;
  838. color: #666666;
  839. margin-top: 10rpx;
  840. }
  841. .chat2 {
  842. font-size: 20rpx;
  843. font-family: PingFang SC;
  844. font-weight: 500;
  845. color: #999999;
  846. margin-top: 10rpx;
  847. }
  848. .chat1 {
  849. font-size: 24rpx;
  850. font-family: PingFang SC;
  851. font-weight: 500;
  852. color: #333333;
  853. }
  854. .leftPadding {
  855. margin-left: 8rpx;
  856. }
  857. .t2Content {
  858. font-size: 28rpx;
  859. font-family: PingFang SC;
  860. font-weight: bold;
  861. color: #999999;
  862. line-height: 48rpx;
  863. }
  864. .tBox2 {
  865. display: flex;
  866. padding-top: 10rpx;
  867. color: #333333;
  868. font-size: 30rpx;
  869. }
  870. .tBox {
  871. display: flex;
  872. align-items: center;
  873. padding-top: 10rpx;
  874. }
  875. .title {
  876. font-size: 24rpx;
  877. color: #999999;
  878. }
  879. page {
  880. padding-top: 10px;
  881. padding-top: constant(safe-area-inset-top);
  882. padding-top: env(safe-area-inset-top);
  883. }
  884. .inputBottom {
  885. position: fixed;
  886. left: 0;
  887. bottom: 0;
  888. background: #ffffff;
  889. height: 98rpx;
  890. display: flex;
  891. align-items: center;
  892. width: 100%;
  893. }
  894. .noteBox {
  895. width: 100%;
  896. background: #ffffff;
  897. padding: 10rpx;
  898. border-radius: 16rpx;
  899. }
  900. .dateBox {
  901. width: 216rpx;
  902. height: 48rpx;
  903. background: #ffffff;
  904. border-radius: 24rpx;
  905. font-size: 24rpx;
  906. color: #666666;
  907. text-align: center;
  908. line-height: 48rpx;
  909. margin: 20rpx 0;
  910. }
  911. .t_content1 {
  912. color: #007aff;
  913. margin-left: 10rpx;
  914. }
  915. .tag1 {
  916. border: 2rpx solid #007aff;
  917. border-radius: 8rpx;
  918. font-size: 20rpx;
  919. color: #007aff;
  920. padding: 5rpx;
  921. }
  922. .b_title {
  923. color: #333333;
  924. font-size: 30rpx;
  925. font-weight: bold;
  926. }
  927. page {
  928. background: #eaeef1;
  929. }
  930. .menuBox {
  931. width: 100%;
  932. background: #ffffff;
  933. border-radius: 16rpx;
  934. padding: 20rpx;
  935. margin-bottom: 20rpx;
  936. }
  937. .btnspric {
  938. border-top: 1rpx solid #eee;
  939. display: flex;
  940. align-items: center;
  941. justify-content: space-between;
  942. height: 108rpx;
  943. padding-left: 43rpx;
  944. padding-right: 32rpx;
  945. }
  946. .btnspric > .lefprL {
  947. font-size: 36rpx;
  948. color: #0c141f;
  949. font-weight: bold;
  950. }
  951. .btnspric > .lefprR {
  952. padding: 0rpx 24rpx;
  953. height: 60rpx;
  954. line-height: 60rpx;
  955. text-align: center;
  956. color: #fff;
  957. background: #32467b;
  958. border-radius: 24rpx;
  959. box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(145, 156, 178, 0.1);
  960. }
  961. .yhj,
  962. .hdyhj {
  963. padding: 24rpx 29rpx 24rpx 34rpx;
  964. }
  965. .yhj {
  966. border-bottom: 16rpx solid #f9f9f9;
  967. }
  968. .yhjtit {
  969. font-size: 30rpx;
  970. color: #0c141f;
  971. font-weight: 500;
  972. margin-bottom: 14rpx;
  973. }
  974. .yhjList {
  975. display: flex;
  976. align-items: center;
  977. justify-content: space-between;
  978. margin-bottom: 14rpx;
  979. }
  980. .yhjList > .yhjLefts {
  981. display: flex;
  982. align-items: center;
  983. }
  984. .yhjLefts > .yhl {
  985. color: #32467b;
  986. font-size: 30rpx;
  987. margin-right: 31rpx;
  988. }
  989. .yhjLefts > .yhbq {
  990. font-size: 24rpx;
  991. color: #ff9500;
  992. border-radius: 18rpx;
  993. background-color: rgba(255, 149, 0, 0.2);
  994. border: 2rpx solid #ff9500;
  995. height: 38rpx;
  996. line-height: 38rpx;
  997. padding: 0rpx 16rpx;
  998. }
  999. .ts {
  1000. font-size: 24rpx;
  1001. color: #999;
  1002. margin: 14rpx 0rpx;
  1003. padding-right: 29rpx;
  1004. padding-left: 34rpx;
  1005. }
  1006. .yh {
  1007. padding-top: 20rpx;
  1008. }
  1009. .yh > .yhtitle {
  1010. display: flex;
  1011. align-items: center;
  1012. justify-content: space-between;
  1013. padding-right: 29rpx;
  1014. padding-left: 34rpx;
  1015. }
  1016. .priceBxs {
  1017. display: flex;
  1018. align-items: center;
  1019. }
  1020. .priceBxs > .pricleft {
  1021. border-radius: 24rpx;
  1022. border: 1rpx solid #e91313;
  1023. background-color: rgba(233, 19, 19, 0.1);
  1024. padding: 0rpx 18rpx;
  1025. height: 49rpx;
  1026. line-height: 49rpx;
  1027. text-align: center;
  1028. font-size: 30rpx;
  1029. font-weight: 500;
  1030. color: #e91313;
  1031. margin-right: 13rpx;
  1032. }
  1033. .topBox {
  1034. padding: 32rpx 32rpx 24rpx;
  1035. border-bottom: 1rpx solid #eeeeee;
  1036. }
  1037. .topBox > .boldFonstType {
  1038. font-weight: 500;
  1039. font-size: 30rpx;
  1040. margin: 16rpx 0rpx 23rpx;
  1041. }
  1042. .topBox > .firstTopL {
  1043. display: flex;
  1044. align-items: center;
  1045. }
  1046. .topBox > .firstTopL > .imageBs {
  1047. width: 331rpx;
  1048. height: 160rpx;
  1049. border-radius: 6rpx;
  1050. overflow: hidden;
  1051. margin-right: 8rpx;
  1052. box-shadow: 0rpx 6rpx 6rpx 0rpx rgba(47, 67, 121, 0.08);
  1053. }
  1054. .topBox > .firstTopL > .imageBs > image {
  1055. width: 100%;
  1056. height: 100%;
  1057. }
  1058. .topBox > .firstTopL > .textBs {
  1059. font-size: 30rpx;
  1060. font-weight: bold;
  1061. color: #0c141f;
  1062. }
  1063. .content {
  1064. padding: 24rpx;
  1065. text-align: left;
  1066. }
  1067. .catalogBox {
  1068. display: flex;
  1069. align-items: center;
  1070. flex-wrap: nowrap;
  1071. overflow-x: auto;
  1072. padding-left: 38rpx;
  1073. max-height: 305rpx;
  1074. overflow-y: auto;
  1075. transition: all 0.4s;
  1076. }
  1077. .catalogBox > .catalogA {
  1078. min-width: 200rpx;
  1079. height: 48rpx;
  1080. line-height: 48rpx;
  1081. // text-align: center;
  1082. border: 2rpx solid transparent;
  1083. white-space: nowrap;
  1084. text-overflow: ellipsis;
  1085. overflow: hidden;
  1086. word-break: break-all;
  1087. border-radius: 10rpx;
  1088. background: rgba(22, 119, 255, 0.05);
  1089. padding-left: 19rpx;
  1090. box-sizing: border-box;
  1091. padding-right: 15rpx;
  1092. margin-right: 16rpx;
  1093. margin-bottom: 20rpx;
  1094. margin-top: 15rpx;
  1095. font-size: 24rpx;
  1096. color: #666;
  1097. }
  1098. .catalogBox > .activesq {
  1099. border-color: #1677ff;
  1100. }
  1101. .changeCatalogBox {
  1102. display: block;
  1103. }
  1104. .catalogBox::-webkit-scrollbar {
  1105. display: none; /* Chrome Safari */
  1106. }
  1107. .box {
  1108. position: relative;
  1109. top: 650rpx;
  1110. padding-bottom: 88rpx;
  1111. margin: 20rpx;
  1112. }
  1113. .price_t2 {
  1114. font-size: 18rpx;
  1115. font-family: PingFang SC;
  1116. font-weight: 500;
  1117. text-decoration: line-through;
  1118. color: #999999;
  1119. }
  1120. .price_t1 {
  1121. font-size: 33rpx;
  1122. font-family: PingFang SC;
  1123. font-weight: bold;
  1124. color: #e91313;
  1125. }
  1126. .sc_t {
  1127. font-size: 22rpx;
  1128. color: #000000;
  1129. }
  1130. .sc {
  1131. width: 29rpx;
  1132. height: 29rpx;
  1133. }
  1134. .buy {
  1135. width: 138rpx;
  1136. height: 48rpx;
  1137. line-height: 48rpx;
  1138. background: #32467b;
  1139. border-radius: 10rpx;
  1140. color: #ffffff;
  1141. font-size: 28rpx;
  1142. text-align: center;
  1143. vertical-align: middle;
  1144. position: absolute;
  1145. right: 30rpx;
  1146. }
  1147. .video_body {
  1148. padding-bottom: 96rpx;
  1149. }
  1150. .footer_tab {
  1151. position: fixed;
  1152. bottom: 0;
  1153. height: 96rpx;
  1154. width: 100%;
  1155. background-color: #ffffff;
  1156. }
  1157. .tj_box {
  1158. width: 50%;
  1159. display: inline-block;
  1160. text-align: center;
  1161. margin: 10rpx 0;
  1162. }
  1163. .teacher_t {
  1164. font-size: 24rpx;
  1165. font-family: PingFang SC;
  1166. font-weight: 400;
  1167. color: #666666;
  1168. line-height: 36rpx;
  1169. margin-left: 15rpx;
  1170. }
  1171. .teacher_img {
  1172. width: 87rpx;
  1173. height: 129rpx;
  1174. }
  1175. .t2 {
  1176. font-size: 24rpx;
  1177. font-family: PingFang SC;
  1178. color: #666666;
  1179. line-height: 36rpx;
  1180. margin: 15rpx;
  1181. }
  1182. .r_t2 {
  1183. width: 201rpx;
  1184. height: 49rpx;
  1185. background: rgba(22, 119, 255, 0.05);
  1186. border: 1rpx solid #32467b;
  1187. border-radius: 16rpx;
  1188. color: #666666;
  1189. font-size: 23rpx;
  1190. text-align: center;
  1191. display: flex;
  1192. align-items: center;
  1193. padding: 5rpx;
  1194. }
  1195. .scroll_box {
  1196. width: 100%;
  1197. height: 60rpx;
  1198. background: #ffffff;
  1199. box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(145, 156, 178, 0.1);
  1200. white-space: nowrap;
  1201. overflow: hidden;
  1202. margin: 15rpx 0;
  1203. }
  1204. .r_sliper {
  1205. padding: 0 20rpx;
  1206. }
  1207. .top_line {
  1208. width: 6rpx;
  1209. height: 22rpx;
  1210. background: #32467b;
  1211. margin-right: 10rpx;
  1212. }
  1213. .video_t2 {
  1214. font-size: 24rpx;
  1215. font-family: PingFang SC;
  1216. font-weight: 500;
  1217. color: #666666;
  1218. }
  1219. .video_t1 {
  1220. height: 80rpx;
  1221. color: #333333;
  1222. line-height: 80rpx;
  1223. font-size: 30rpx;
  1224. font-family: PingFang SC;
  1225. font-weight: bold;
  1226. color: #333333;
  1227. overflow: hidden;
  1228. text-overflow: ellipsis;
  1229. white-space: nowrap;
  1230. }
  1231. .video_t1_t {
  1232. display: flex;
  1233. flex-direction: column;
  1234. height: 80rpx;
  1235. color: #333333;
  1236. text-align: center;
  1237. align-items: center;
  1238. border-left: solid 1px #d6d6db;
  1239. }
  1240. .video_play {
  1241. position: absolute;
  1242. width: 95rpx;
  1243. height: 95rpx;
  1244. top: 0;
  1245. left: 0;
  1246. right: 0;
  1247. bottom: 0;
  1248. margin: auto;
  1249. }
  1250. .video_box {
  1251. position: relative;
  1252. }
  1253. .rotoct {
  1254. transform: rotate(90deg);
  1255. }
  1256. </style>