detail.vue 34 KB

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