detail.vue 33 KB

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