detail.vue 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297
  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 class="input" 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 class="flex_auto">
  89. <u-input height="60" fixed="true" :placeholder="placeholder" type="textarea" :custom-style="inputStyle" v-model="ctxValue" />
  90. </view>
  91. <view class="btn" @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. });
  334. },
  335. methods: {
  336. openJY(){
  337. uni.authorize({
  338. scope: 'scope.camera',
  339. success() {
  340. }
  341. })
  342. this.$u.toast('此功能正在开发中');
  343. },
  344. async playVideo(item) {
  345. if (this.timer) {
  346. clearInterval(this.timer);
  347. }
  348. if (this.vid) {
  349. //切换视频
  350. var polyvPlayerContext = this.selectComponent('#playerVideo');
  351. polyvPlayerContext.changeVid(item.recordingUrl);
  352. } else {
  353. this.vid = item.recordingUrl;
  354. }
  355. this.recordObj = await this.getRecordLast();
  356. if (this.recordObj.studyDuration) {
  357. this.needSeek = true; //需要跳转到播放记录
  358. }
  359. console.log(this.startTime, 789);
  360. this.startStatus = true;
  361. //获取节笔记
  362. this.getNoteList();
  363. },
  364. getRecordLast() {
  365. let self = this;
  366. return new Promise(resolve => {
  367. let data = {
  368. gradeId: Number(self.gradeId),
  369. goodsId: Number(self.goodsId),
  370. sectionId: Number(self.playSectionId),
  371. courseId: Number(self.courseId)
  372. };
  373. self.$api.recordLast(data).then(res => {
  374. resolve(res.data.data);
  375. });
  376. });
  377. },
  378. jumpNote(item) {
  379. this.noteId = item.noteId;
  380. this.$u.toast('即将跳到笔记位置');
  381. //跳到笔记时刻
  382. var polyvPlayerContext = this.selectComponent('#playerVideo');
  383. polyvPlayerContext.seek(item.noteSecond);
  384. polyvPlayerContext.play();
  385. },
  386. postNote() {
  387. let self = this;
  388. if (!(this.playSectionId > 0)) {
  389. this.$u.toast('目前无播放视频');
  390. return;
  391. }
  392. if (!this.noteValue) {
  393. this.$u.toast('请输入内容');
  394. return;
  395. }
  396. var polyvPlayerContext = this.selectComponent('#playerVideo');
  397. let noteDate = this.$method.getZeroTime();
  398. let noteSecond = polyvPlayerContext.getCurrentTime();
  399. console.log(noteSecond,698)
  400. if (!noteSecond) {
  401. if(noteSecond==0){
  402. //播放结束
  403. noteSecond = polyvPlayerContext.getDuration();
  404. console.log(noteSecond,63398)
  405. }
  406. if(!noteSecond){
  407. this.$u.toast('视频暂未开始');
  408. return;
  409. }
  410. }
  411. let data = {
  412. gradeId: this.gradeId,
  413. goodsId: this.goodsId,
  414. sectionId: this.playSectionId,
  415. courseId: this.courseId,
  416. noteText: this.noteValue,
  417. noteDate: noteDate,
  418. noteSecond: noteSecond
  419. };
  420. this.$api.postNote(data).then(res => {
  421. if (res.data.code == 200) {
  422. this.$u.toast('发布成功');
  423. self.getNoteList();
  424. this.noteValue = '';
  425. }
  426. });
  427. },
  428. getNoteList() {
  429. let self = this;
  430. this.$api.noteList({ sectionId: this.playSectionId, courseId: this.courseId, gradeId: this.gradeId, goodsId: this.goodsId }).then(res => {
  431. if (res.data.code == 200) {
  432. self.noteList = res.data.rows;
  433. }
  434. });
  435. },
  436. delAnswer(answerId) {
  437. let self = this;
  438. let data = { answerId: answerId, status: -1 };
  439. this.$api.delAnswer(data).then(res => {
  440. if (res.data.code == 200) {
  441. self.getAnswerList();
  442. }
  443. });
  444. },
  445. clearCtx() {
  446. console.log(4234);
  447. this.placeholder = '您可以在这里输入答疑内容';
  448. this.ctxValue = '';
  449. this.assignUserId = 0;
  450. },
  451. replyContent(item) {
  452. this.assignUserId = item.userId;
  453. this.placeholder = '@' + item.realname;
  454. },
  455. delContent(item) {
  456. this.delAnswer(item.answerId);
  457. },
  458. postAnswer() {
  459. let self = this;
  460. let data = { courseId: this.courseId, answerText: this.ctxValue };
  461. if (this.assignUserId > 0) {
  462. data.assignUserId = this.assignUserId;
  463. }
  464. this.$api.postAnswer(data).then(res => {
  465. if (res.data.code == 200) {
  466. this.$u.toast('发布成功');
  467. self.getAnswerList();
  468. this.placeholder = '您可以在这里输入答疑内容';
  469. this.ctxValue = '';
  470. this.assignUserId = 0;
  471. }
  472. });
  473. },
  474. postContent() {
  475. if (!this.ctxValue) {
  476. this.$u.toast('请输入内容');
  477. }
  478. this.postAnswer();
  479. },
  480. postStudyRecord(status = 0, sectionId = this.playSectionId) {
  481. let currentTime = 0;
  482. var polyvPlayerContext = this.selectComponent('#playerVideo');
  483. if (polyvPlayerContext) {
  484. currentTime = polyvPlayerContext.getCurrentTime();
  485. }
  486. let self = this;
  487. let data = {
  488. photo: self.ossAvatarUrl,
  489. sectionId: parseInt(sectionId),
  490. goodsId: parseInt(self.goodsId),
  491. courseId: parseInt(self.courseId),
  492. studyDuration: parseInt(currentTime > 0 ? currentTime : self.studyDuration),
  493. gradeId: parseInt(self.gradeId),
  494. chapterId: parseInt(self.chapterId),
  495. moduleId: parseInt(self.moduleId)
  496. };
  497. if (data.studyDuration <= 5) {
  498. //5秒内不上传记录
  499. return;
  500. }
  501. if (status > 0) {
  502. data.status = status;
  503. }
  504. console.log('提交接口', data);
  505. this.$api.studyRecord(data).then(res => {
  506. console.log(res);
  507. });
  508. },
  509. uploadFile(options, int) {
  510. var self = this;
  511. return new Promise((resolve, reject) => {
  512. var data = {
  513. imageStatus: int
  514. };
  515. self.$api.aliyunpolicy(data).then(res => {
  516. if (res.data.code != 200) {
  517. self.$method.showToast('签名错误' + JSON.stringify(res.data));
  518. return;
  519. }
  520. var ossToken = res.data.data.resultContent;
  521. if (ossToken.host == null || ossToken.host == undefined) {
  522. self.$method.showToast('上传路径报错' + JSON.stringify(res.data));
  523. return;
  524. }
  525. uni.uploadFile({
  526. url: ossToken.host,
  527. name: 'file',
  528. filePath: options,
  529. fileType: 'image',
  530. header: {
  531. AuthorizationToken: 'WX ' + uni.getStorageSync('token')
  532. },
  533. formData: {
  534. key: ossToken.dir,
  535. OSSAccessKeyId: ossToken.accessid,
  536. policy: ossToken.policy,
  537. Signature: ossToken.signature,
  538. callback: ossToken.callback,
  539. success_action_status: 200
  540. },
  541. success: result => {
  542. if (result.statusCode === 200) {
  543. self.ossAvatarUrl = ossToken.dir;
  544. resolve();
  545. } else {
  546. uni.showToast({
  547. title: '上传失败',
  548. icon: 'none'
  549. });
  550. return;
  551. }
  552. },
  553. fail: error => {
  554. uni.showToast({
  555. title: '上传接口报错' + error,
  556. icon: 'none'
  557. });
  558. return;
  559. }
  560. });
  561. });
  562. });
  563. },
  564. imageInfos() {
  565. var self = this;
  566. return new Promise((resolve, reject) => {
  567. uni.getImageInfo({
  568. src: self.avatarUrl,
  569. success: async res => {
  570. let canvasWidth = res.width; //图片原始长宽
  571. let canvasHeight = res.height;
  572. if (canvasWidth > 1000 || canvasHeight > 1000) {
  573. uni.compressImage({
  574. src: self.avatarUrl,
  575. quality: 75,
  576. width: '50%',
  577. height: '50%',
  578. success: async rest => {
  579. const waitUpload = await self.uploadFile(rest.tempFilePath, 0);
  580. resolve();
  581. }
  582. });
  583. } else {
  584. console.log('无需压缩');
  585. const waitUpload = await self.uploadFile(self.avatarUrl, 0);
  586. resolve();
  587. }
  588. }
  589. });
  590. });
  591. },
  592. timeEvent() {
  593. let self = this;
  594. var polyvPlayerContext = this.selectComponent('#playerVideo');
  595. if (polyvPlayerContext != null) {
  596. let PlayCurrentTime = polyvPlayerContext.getVideoPlayDuration();
  597. console.log(PlayCurrentTime,996)
  598. this.studyDuration = PlayCurrentTime;
  599. if (this.currentTime < PlayCurrentTime) {
  600. this.playTime += PlayCurrentTime - this.currentTime;
  601. this.currentTime = PlayCurrentTime;
  602. } else {
  603. this.currentTime = PlayCurrentTime;
  604. }
  605. //判断是否需要拍照
  606. if (this.intervalTimeList.length > this.intervalTimeIndex) {
  607. let photoTime = Number(this.intervalTimeList[this.intervalTimeIndex]) * 60; //获取拍照秒数
  608. if (photoTime < this.playTime) {
  609. //启动拍照
  610. //暂停
  611. polyvPlayerContext.exitFullScreen();
  612. polyvPlayerContext.pause();
  613. this.openPhoto();
  614. this.intervalTimeIndex++;
  615. }
  616. }
  617. }
  618. },
  619. onStateChange(newstate, oldstate) {
  620. if (newstate.detail.newstate == 'playing') {
  621. if (this.needSeek) {
  622. var polyvPlayerContext = this.selectComponent('#playerVideo');
  623. polyvPlayerContext.seek(this.recordObj.studyDuration);
  624. polyvPlayerContext.play();
  625. this.needSeek = false;
  626. }
  627. //开始播放
  628. if (this.timer) {
  629. clearInterval(this.timer);
  630. }
  631. this.timer = setInterval(this.timeEvent, 1500); //定时器
  632. }
  633. if (newstate.detail.newstate == 'pause') {
  634. //暂停提交记录
  635. /* this.ossAvatarUrl = ""
  636. this.postStudyRecord() */
  637. }
  638. if (newstate.detail.newstate == 'ended') {
  639. this.ossAvatarUrl = '';
  640. this.postStudyRecord(1);
  641. }
  642. },
  643. //拍照
  644. openPhoto() {
  645. this.photoPopup = true;
  646. uni.authorize({
  647. scope: 'scope.camera',
  648. success() {
  649. }
  650. })
  651. },
  652. async submit() {
  653. const waitYS = await this.imageInfos();
  654. this.postStudyRecord(); //提交记录
  655. //恢复播放
  656. var polyvPlayerContext = this.selectComponent('#playerVideo');
  657. if (polyvPlayerContext != null) {
  658. polyvPlayerContext.play();
  659. }
  660. console.log(this.ossAvatarUrl, '拍照完成456');
  661. },
  662. //确认拍照
  663. takePhoto() {
  664. var self = this;
  665. const ctx = uni.createCameraContext();
  666. ctx.takePhoto({
  667. quality: 'high',
  668. success: res => {
  669. console.log(res.tempImagePath);
  670. self.avatarUrl = res.tempImagePath;
  671. self.submit();
  672. self.photoPopup = false;
  673. },
  674. fail: err => {
  675. console.log(err);
  676. }
  677. });
  678. },
  679. //拍照报错
  680. error(e) {
  681. console.log(e.detail);
  682. },
  683. //关闭相机
  684. closePhoto() {
  685. this.photoPopup = false;
  686. },
  687. getGoodsDetail() {
  688. let self = this;
  689. this.$api.goodsDetail(this.goodsId).then(res => {
  690. self.goodsData = res.data.data;
  691. self.gradeId = self.goodsData.gradeId;
  692. console.log(self.gradeId, 698);
  693. self.getMenuList();
  694. self.getReMenuList(); //获取重修目录
  695. if (self.goodsData.goodsPlayConfig) {
  696. self.goodsPlayConfig = JSON.parse(self.goodsData.goodsPlayConfig);
  697. if (self.goodsPlayConfig.autoPlay > 0) {
  698. self.autoplay = true;
  699. }
  700. if (self.goodsPlayConfig.drag > 0) {
  701. self.isAllowSeek = 'yes';
  702. }
  703. if (self.goodsPlayConfig.speed > 0) {
  704. self.playbackRate = [0.5, 0.8, 1.0, 1.25, 1.5, 2.0];
  705. }
  706. }
  707. if (self.goodsData.goodsPhotographConfig) {
  708. self.goodsPhotographConfig = JSON.parse(self.goodsData.goodsPhotographConfig);
  709. if (self.goodsPhotographConfig.intervalTime) {
  710. self.intervalTimeList = self.goodsPhotographConfig.intervalTime.split(',');
  711. }
  712. }
  713. });
  714. },
  715. startVideo() {
  716. this.startStatus = true;
  717. },
  718. getAnswerList() {
  719. let self = this;
  720. this.$api.answerList({ courseId: this.courseId }).then(res => {
  721. if (res.data.code == 200) {
  722. self.answerList = res.data.rows;
  723. }
  724. });
  725. },
  726. getReMenuList() {
  727. let self = this;
  728. this.$api.reMenuList({ courseId: this.courseId, rebuild: 1, 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.reMenuList = res.data.rows;
  737. if(self.reMenuList.length>0){
  738. self.list.push({name:'重修目录'})
  739. }
  740. }
  741. });
  742. },
  743. getMenuList() {
  744. let self = this;
  745. this.$api.reMenuList({ courseId: this.courseId, gradeId: this.gradeId }).then(res => {
  746. if (res.data.code == 200) {
  747. for (let i = 0; i < res.data.rows.length; i++) {
  748. let item = res.data.rows[i];
  749. item.down = true;
  750. item.id = item.menuId;
  751. item.name = item.menuName;
  752. }
  753. self.menuList = res.data.rows;
  754. }
  755. });
  756. },
  757. courseDetail() {
  758. let self = this;
  759. this.$api.courseDetail(this.courseId).then(res => {
  760. if (res.data.code == 200) {
  761. self.detail = res.data.data;
  762. self.gradeId = self.detail.gradeId;
  763. }
  764. });
  765. },
  766. open(item) {
  767. item.showChildren = !item.showChildren;
  768. },
  769. change(index) {
  770. this.current = index;
  771. }
  772. }
  773. };
  774. </script>
  775. <style lang="scss" scope>
  776. .btnReply {
  777. width: 80rpx;
  778. height: 40rpx;
  779. background: #e3f0ff;
  780. border-radius: 16rpx;
  781. text-align: center;
  782. color: #007aff;
  783. }
  784. .btnDel {
  785. width: 80rpx;
  786. height: 40rpx;
  787. background: #ffedf0;
  788. border-radius: 16rpx;
  789. text-align: center;
  790. color: #ff2d55;
  791. }
  792. .btnReply {
  793. width: 80rpx;
  794. height: 40rpx;
  795. background: #e3f0ff;
  796. border-radius: 16rpx;
  797. font-size: 24rpx;
  798. }
  799. .photoBox {
  800. .photoTop {
  801. height: 74upx;
  802. display: flex;
  803. align-items: center;
  804. justify-content: space-between;
  805. padding: 0upx 38upx;
  806. .sqzz {
  807. width: 28upx;
  808. height: 28upx;
  809. display: flex;
  810. align-items: center;
  811. justify-content: center;
  812. }
  813. .centersq {
  814. color: #333;
  815. font-size: 30upx;
  816. font-weight: 500;
  817. }
  818. }
  819. .photoCenter {
  820. width: 750upx;
  821. height: 979upx;
  822. position: relative;
  823. .custom {
  824. width: 750upx;
  825. height: 979upx;
  826. position: absolute;
  827. top: 0;
  828. left: 0;
  829. image {
  830. width: 100%;
  831. height: 100%;
  832. }
  833. }
  834. }
  835. .btnResult {
  836. height: 100upx;
  837. width: 100%;
  838. background-color: #07c160;
  839. text-align: center;
  840. line-height: 100upx;
  841. color: #fff;
  842. font-size: 32upx;
  843. font-weight: bold;
  844. }
  845. }
  846. .chat_box {
  847. display: flex;
  848. padding: 20rpx;
  849. justify-content: space-between;
  850. }
  851. .chat3 {
  852. font-size: 30rpx;
  853. font-family: PingFang SC;
  854. font-weight: 500;
  855. color: #666666;
  856. margin-top: 10rpx;
  857. }
  858. .chat2 {
  859. font-size: 20rpx;
  860. font-family: PingFang SC;
  861. font-weight: 500;
  862. color: #999999;
  863. margin-top: 10rpx;
  864. }
  865. .chat1 {
  866. font-size: 24rpx;
  867. font-family: PingFang SC;
  868. font-weight: 500;
  869. color: #333333;
  870. }
  871. .leftPadding {
  872. margin-left: 8rpx;
  873. }
  874. .t2Content {
  875. font-size: 28rpx;
  876. font-family: PingFang SC;
  877. font-weight: bold;
  878. color: #999999;
  879. line-height: 48rpx;
  880. }
  881. .tBox2 {
  882. display: flex;
  883. padding-top: 10rpx;
  884. color: #333333;
  885. font-size: 30rpx;
  886. }
  887. .tBox {
  888. display: flex;
  889. align-items: center;
  890. padding-top: 10rpx;
  891. }
  892. .title {
  893. font-size: 24rpx;
  894. color: #999999;
  895. }
  896. page {
  897. padding-top: 10px;
  898. padding-top: constant(safe-area-inset-top);
  899. padding-top: env(safe-area-inset-top);
  900. }
  901. .inputBottom {
  902. position: fixed;
  903. left: 0;
  904. bottom: 0;
  905. background: #ffffff;
  906. height: 98rpx;
  907. display: flex;
  908. align-items: center;
  909. width: 100%;
  910. .flex_auto {
  911. flex:1;
  912. margin-left: 10% ;
  913. .input {
  914. height:60rpx;
  915. }
  916. }
  917. .btn {
  918. color: #007AFF;font-size: 30rpx;font-weight: bold;width: 15%;text-align: center;
  919. }
  920. }
  921. .noteBox {
  922. width: 100%;
  923. background: #ffffff;
  924. padding: 10rpx;
  925. border-radius: 16rpx;
  926. }
  927. .dateBox {
  928. width: 216rpx;
  929. height: 48rpx;
  930. background: #ffffff;
  931. border-radius: 24rpx;
  932. font-size: 24rpx;
  933. color: #666666;
  934. text-align: center;
  935. line-height: 48rpx;
  936. margin: 20rpx 0;
  937. }
  938. .t_content1 {
  939. color: #007aff;
  940. margin-left: 10rpx;
  941. }
  942. .tag1 {
  943. border: 2rpx solid #007aff;
  944. border-radius: 8rpx;
  945. font-size: 20rpx;
  946. color: #007aff;
  947. padding: 5rpx;
  948. }
  949. .b_title {
  950. color: #333333;
  951. font-size: 30rpx;
  952. font-weight: bold;
  953. }
  954. page {
  955. background: #eaeef1;
  956. }
  957. .menuBox {
  958. width: 100%;
  959. background: #ffffff;
  960. border-radius: 16rpx;
  961. padding: 20rpx;
  962. margin-bottom: 20rpx;
  963. }
  964. .btnspric {
  965. border-top: 1rpx solid #eee;
  966. display: flex;
  967. align-items: center;
  968. justify-content: space-between;
  969. height: 108rpx;
  970. padding-left: 43rpx;
  971. padding-right: 32rpx;
  972. }
  973. .btnspric > .lefprL {
  974. font-size: 36rpx;
  975. color: #0c141f;
  976. font-weight: bold;
  977. }
  978. .btnspric > .lefprR {
  979. padding: 0rpx 24rpx;
  980. height: 60rpx;
  981. line-height: 60rpx;
  982. text-align: center;
  983. color: #fff;
  984. background: #32467b;
  985. border-radius: 24rpx;
  986. box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(145, 156, 178, 0.1);
  987. }
  988. .yhj,
  989. .hdyhj {
  990. padding: 24rpx 29rpx 24rpx 34rpx;
  991. }
  992. .yhj {
  993. border-bottom: 16rpx solid #f9f9f9;
  994. }
  995. .yhjtit {
  996. font-size: 30rpx;
  997. color: #0c141f;
  998. font-weight: 500;
  999. margin-bottom: 14rpx;
  1000. }
  1001. .yhjList {
  1002. display: flex;
  1003. align-items: center;
  1004. justify-content: space-between;
  1005. margin-bottom: 14rpx;
  1006. }
  1007. .yhjList > .yhjLefts {
  1008. display: flex;
  1009. align-items: center;
  1010. }
  1011. .yhjLefts > .yhl {
  1012. color: #32467b;
  1013. font-size: 30rpx;
  1014. margin-right: 31rpx;
  1015. }
  1016. .yhjLefts > .yhbq {
  1017. font-size: 24rpx;
  1018. color: #ff9500;
  1019. border-radius: 18rpx;
  1020. background-color: rgba(255, 149, 0, 0.2);
  1021. border: 2rpx solid #ff9500;
  1022. height: 38rpx;
  1023. line-height: 38rpx;
  1024. padding: 0rpx 16rpx;
  1025. }
  1026. .ts {
  1027. font-size: 24rpx;
  1028. color: #999;
  1029. margin: 14rpx 0rpx;
  1030. padding-right: 29rpx;
  1031. padding-left: 34rpx;
  1032. }
  1033. .yh {
  1034. padding-top: 20rpx;
  1035. }
  1036. .yh > .yhtitle {
  1037. display: flex;
  1038. align-items: center;
  1039. justify-content: space-between;
  1040. padding-right: 29rpx;
  1041. padding-left: 34rpx;
  1042. }
  1043. .priceBxs {
  1044. display: flex;
  1045. align-items: center;
  1046. }
  1047. .priceBxs > .pricleft {
  1048. border-radius: 24rpx;
  1049. border: 1rpx solid #e91313;
  1050. background-color: rgba(233, 19, 19, 0.1);
  1051. padding: 0rpx 18rpx;
  1052. height: 49rpx;
  1053. line-height: 49rpx;
  1054. text-align: center;
  1055. font-size: 30rpx;
  1056. font-weight: 500;
  1057. color: #e91313;
  1058. margin-right: 13rpx;
  1059. }
  1060. .topBox {
  1061. padding: 32rpx 32rpx 24rpx;
  1062. border-bottom: 1rpx solid #eeeeee;
  1063. }
  1064. .topBox > .boldFonstType {
  1065. font-weight: 500;
  1066. font-size: 30rpx;
  1067. margin: 16rpx 0rpx 23rpx;
  1068. }
  1069. .topBox > .firstTopL {
  1070. display: flex;
  1071. align-items: center;
  1072. }
  1073. .topBox > .firstTopL > .imageBs {
  1074. width: 331rpx;
  1075. height: 160rpx;
  1076. border-radius: 6rpx;
  1077. overflow: hidden;
  1078. margin-right: 8rpx;
  1079. box-shadow: 0rpx 6rpx 6rpx 0rpx rgba(47, 67, 121, 0.08);
  1080. }
  1081. .topBox > .firstTopL > .imageBs > image {
  1082. width: 100%;
  1083. height: 100%;
  1084. }
  1085. .topBox > .firstTopL > .textBs {
  1086. font-size: 30rpx;
  1087. font-weight: bold;
  1088. color: #0c141f;
  1089. }
  1090. .content {
  1091. padding: 24rpx;
  1092. text-align: left;
  1093. }
  1094. .catalogBox {
  1095. display: flex;
  1096. align-items: center;
  1097. flex-wrap: nowrap;
  1098. overflow-x: auto;
  1099. padding-left: 38rpx;
  1100. max-height: 305rpx;
  1101. overflow-y: auto;
  1102. transition: all 0.4s;
  1103. }
  1104. .catalogBox > .catalogA {
  1105. min-width: 200rpx;
  1106. height: 48rpx;
  1107. line-height: 48rpx;
  1108. // text-align: center;
  1109. border: 2rpx solid transparent;
  1110. white-space: nowrap;
  1111. text-overflow: ellipsis;
  1112. overflow: hidden;
  1113. word-break: break-all;
  1114. border-radius: 10rpx;
  1115. background: rgba(22, 119, 255, 0.05);
  1116. padding-left: 19rpx;
  1117. box-sizing: border-box;
  1118. padding-right: 15rpx;
  1119. margin-right: 16rpx;
  1120. margin-bottom: 20rpx;
  1121. margin-top: 15rpx;
  1122. font-size: 24rpx;
  1123. color: #666;
  1124. }
  1125. .catalogBox > .activesq {
  1126. border-color: #1677ff;
  1127. }
  1128. .changeCatalogBox {
  1129. display: block;
  1130. }
  1131. .catalogBox::-webkit-scrollbar {
  1132. display: none; /* Chrome Safari */
  1133. }
  1134. .box {
  1135. position: relative;
  1136. top: 650rpx;
  1137. padding-bottom: 88rpx;
  1138. margin: 20rpx;
  1139. }
  1140. .price_t2 {
  1141. font-size: 18rpx;
  1142. font-family: PingFang SC;
  1143. font-weight: 500;
  1144. text-decoration: line-through;
  1145. color: #999999;
  1146. }
  1147. .price_t1 {
  1148. font-size: 33rpx;
  1149. font-family: PingFang SC;
  1150. font-weight: bold;
  1151. color: #e91313;
  1152. }
  1153. .sc_t {
  1154. font-size: 22rpx;
  1155. color: #000000;
  1156. }
  1157. .sc {
  1158. width: 29rpx;
  1159. height: 29rpx;
  1160. }
  1161. .buy {
  1162. width: 138rpx;
  1163. height: 48rpx;
  1164. line-height: 48rpx;
  1165. background: #32467b;
  1166. border-radius: 10rpx;
  1167. color: #ffffff;
  1168. font-size: 28rpx;
  1169. text-align: center;
  1170. vertical-align: middle;
  1171. position: absolute;
  1172. right: 30rpx;
  1173. }
  1174. .video_body {
  1175. padding-bottom: 96rpx;
  1176. }
  1177. .footer_tab {
  1178. position: fixed;
  1179. bottom: 0;
  1180. height: 96rpx;
  1181. width: 100%;
  1182. background-color: #ffffff;
  1183. }
  1184. .tj_box {
  1185. width: 50%;
  1186. display: inline-block;
  1187. text-align: center;
  1188. margin: 10rpx 0;
  1189. }
  1190. .teacher_t {
  1191. font-size: 24rpx;
  1192. font-family: PingFang SC;
  1193. font-weight: 400;
  1194. color: #666666;
  1195. line-height: 36rpx;
  1196. margin-left: 15rpx;
  1197. }
  1198. .teacher_img {
  1199. width: 87rpx;
  1200. height: 129rpx;
  1201. }
  1202. .t2 {
  1203. font-size: 24rpx;
  1204. font-family: PingFang SC;
  1205. color: #666666;
  1206. line-height: 36rpx;
  1207. margin: 15rpx;
  1208. }
  1209. .r_t2 {
  1210. width: 201rpx;
  1211. height: 49rpx;
  1212. background: rgba(22, 119, 255, 0.05);
  1213. border: 1rpx solid #32467b;
  1214. border-radius: 16rpx;
  1215. color: #666666;
  1216. font-size: 23rpx;
  1217. text-align: center;
  1218. display: flex;
  1219. align-items: center;
  1220. padding: 5rpx;
  1221. }
  1222. .scroll_box {
  1223. width: 100%;
  1224. height: 60rpx;
  1225. background: #ffffff;
  1226. box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(145, 156, 178, 0.1);
  1227. white-space: nowrap;
  1228. overflow: hidden;
  1229. margin: 15rpx 0;
  1230. }
  1231. .r_sliper {
  1232. padding: 0 20rpx;
  1233. }
  1234. .top_line {
  1235. width: 6rpx;
  1236. height: 22rpx;
  1237. background: #32467b;
  1238. margin-right: 10rpx;
  1239. }
  1240. .video_t2 {
  1241. font-size: 24rpx;
  1242. font-family: PingFang SC;
  1243. font-weight: 500;
  1244. color: #666666;
  1245. }
  1246. .video_t1 {
  1247. height: 80rpx;
  1248. color: #333333;
  1249. line-height: 80rpx;
  1250. font-size: 30rpx;
  1251. font-family: PingFang SC;
  1252. font-weight: bold;
  1253. color: #333333;
  1254. overflow: hidden;
  1255. text-overflow: ellipsis;
  1256. white-space: nowrap;
  1257. }
  1258. .video_t1_t {
  1259. display: flex;
  1260. flex-direction: column;
  1261. height: 80rpx;
  1262. color: #333333;
  1263. text-align: center;
  1264. align-items: center;
  1265. border-left: solid 1px #d6d6db;
  1266. }
  1267. .video_play {
  1268. position: absolute;
  1269. width: 95rpx;
  1270. height: 95rpx;
  1271. top: 0;
  1272. left: 0;
  1273. right: 0;
  1274. bottom: 0;
  1275. margin: auto;
  1276. }
  1277. .video_box {
  1278. position: relative;
  1279. }
  1280. .rotoct {
  1281. transform: rotate(90deg);
  1282. }
  1283. </style>