detail.vue 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363
  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="height: 250rpx;display: flex;align-items:center;padding: 0 30rpx;">
  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. //相机授权
  238. this.getCameraSetting()
  239. this.$api.getbaseprofiletplists({ goodsId: self.goodsId }).then(res => {
  240. if (res.data.code === 200 && res.data.rows.length) {
  241. if (res.data.rows[0].keyValue) {
  242. self.$api.getbaseprofiletpgetInfo({ goodsId: self.goodsId }).then(result => {
  243. if (result.data.code === 200) {
  244. if (!result.data.data || (result.data.data.status === 3 && result.data.data.changeStatus === 1)) {
  245. if (!result.data.data) {
  246. uni.showModal({
  247. content: '请前往填写资料',
  248. cancelText: '返回',
  249. success: function(resultst) {
  250. if (resultst.confirm) {
  251. self.$navTo.togo('/pages2/verify/input', {
  252. id: self.goodsId
  253. });
  254. }
  255. if (resultst.cancel) {
  256. uni.navigateBack();
  257. }
  258. }
  259. });
  260. } else {
  261. uni.showModal({
  262. content: '资料审核不通过,请前往重新填写',
  263. cancelText: '返回',
  264. success: function(resultst) {
  265. if (resultst.confirm) {
  266. self.$navTo.togo('/pages2/verify/input', {
  267. id: self.goodsId
  268. });
  269. }
  270. if (resultst.cancel) {
  271. uni.navigateBack();
  272. }
  273. }
  274. });
  275. }
  276. } else if (result.data.data.status === 1 && res.data.rows[0].keyValue2) {
  277. self.$api.getbaseprofileStampgetInfo({ goodsId: self.goodsId }).then(k => {
  278. if (k.data.code === 200) {
  279. if (!k.data.data || (k.data.data.status === 3 && k.data.data.changeStatus === 1)) {
  280. if (!k.data.data) {
  281. uni.showModal({
  282. cancelText: '返回',
  283. content: '请前往填写盖章资料',
  284. success: function(resultst) {
  285. if (resultst.confirm) {
  286. self.$navTo.togo('/pages2/verify/input2', {
  287. id: self.goodsId
  288. });
  289. }
  290. if (resultst.cancel) {
  291. uni.navigateBack();
  292. }
  293. }
  294. });
  295. } else {
  296. uni.showModal({
  297. cancelText: '返回',
  298. content: '资料盖章审核不通过,请前往重新填写',
  299. success: function(resultst) {
  300. if (resultst.confirm) {
  301. self.$navTo.togo('/pages2/verify/input2', {
  302. id: self.goodsId
  303. });
  304. }
  305. if (resultst.cancel) {
  306. uni.navigateBack();
  307. }
  308. }
  309. });
  310. }
  311. }
  312. }
  313. });
  314. }
  315. }
  316. });
  317. }
  318. }
  319. });
  320. },
  321. onUnload() {
  322. if (this.playSectionId > 0) {
  323. //退出提交记录
  324. this.ossAvatarUrl = '';
  325. this.postStudyRecord();
  326. //清除正在播放的节ID
  327. this.$store.commit('setPlaySectionId', { playSectionId: 0 });
  328. //移除所有的事件监听器
  329. uni.$off();
  330. }
  331. },
  332. mounted() {
  333. uni.$on('changeSection', oldSectionId => {
  334. this.postStudyRecord(0, oldSectionId);
  335. });
  336. uni.$on('getSection', item => {
  337. this.playVideo(item);
  338. });
  339. uni.$on('levelId', item => {
  340. let arr = item.split('-');
  341. //点击节获取的各层级ID
  342. this.moduleId = arr[0];
  343. this.chapterId = arr[1];
  344. });
  345. },
  346. methods: {
  347. openSetting(res){
  348. console.log(res,98)
  349. },
  350. getCameraSetting () {
  351. const self = this
  352. wx.getSetting({
  353. success: res => {
  354. if (res.authSetting['scope.camera']) {
  355. // 用户已经授权
  356. self.showSet = false
  357. } else {
  358. // 用户还没有授权,向用户发起授权请求
  359. wx.authorize({
  360. scope: 'scope.camera',
  361. success() { // 用户同意授权
  362. self.showSet = false
  363. },
  364. fail() { // 用户不同意授权
  365. self.showSet = true
  366. /* wx.showToast({
  367. title: '摄像头授权失败',
  368. icon: 'none',
  369. duration: 3000
  370. }) */
  371. }
  372. })
  373. }
  374. },
  375. fail: res => {
  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. .btnSet{
  824. height: 50px;
  825. width: 400rpx;
  826. background: #007AFF;
  827. border-radius: 25rpx;
  828. color: #FFFFFF;
  829. font-size: 28rpx;
  830. line-height: 50px;
  831. }
  832. .btnReply {
  833. width: 80rpx;
  834. height: 40rpx;
  835. background: #e3f0ff;
  836. border-radius: 16rpx;
  837. text-align: center;
  838. color: #007aff;
  839. }
  840. .btnDel {
  841. width: 80rpx;
  842. height: 40rpx;
  843. background: #ffedf0;
  844. border-radius: 16rpx;
  845. text-align: center;
  846. color: #ff2d55;
  847. }
  848. .btnReply {
  849. width: 80rpx;
  850. height: 40rpx;
  851. background: #e3f0ff;
  852. border-radius: 16rpx;
  853. font-size: 24rpx;
  854. }
  855. .photoBox {
  856. background-color: #FFFFFF;
  857. border-radius: 32px 32px 0px 0px;
  858. .photoTop {
  859. height: 74upx;
  860. display: flex;
  861. align-items: center;
  862. justify-content: space-between;
  863. padding: 0upx 38upx;
  864. .sqzz {
  865. width: 28upx;
  866. height: 28upx;
  867. display: flex;
  868. align-items: center;
  869. justify-content: center;
  870. }
  871. .centersq {
  872. color: #333;
  873. font-size: 30upx;
  874. font-weight: 500;
  875. }
  876. }
  877. .photoCenter {
  878. width: 750upx;
  879. height: 979upx;
  880. position: relative;
  881. .custom {
  882. width: 750upx;
  883. height: 979upx;
  884. position: absolute;
  885. z-index: 1000;
  886. top: 0;
  887. left: 0;
  888. image {
  889. width: 100%;
  890. height: 100%;
  891. }
  892. }
  893. }
  894. .btnResult {
  895. height: 100rpx;
  896. width: 100%;
  897. background-color: #07c160;
  898. text-align: center;
  899. line-height: 100upx;
  900. color: #fff;
  901. font-size: 32upx;
  902. font-weight: bold;
  903. }
  904. }
  905. .chat_box {
  906. display: flex;
  907. padding: 20rpx;
  908. justify-content: space-between;
  909. }
  910. .chat3 {
  911. font-size: 30rpx;
  912. font-family: PingFang SC;
  913. font-weight: 500;
  914. color: #666666;
  915. margin-top: 10rpx;
  916. }
  917. .chat2 {
  918. font-size: 20rpx;
  919. font-family: PingFang SC;
  920. font-weight: 500;
  921. color: #999999;
  922. margin-top: 10rpx;
  923. }
  924. .chat1 {
  925. font-size: 24rpx;
  926. font-family: PingFang SC;
  927. font-weight: 500;
  928. color: #333333;
  929. }
  930. .leftPadding {
  931. margin-left: 8rpx;
  932. }
  933. .t2Content {
  934. font-size: 28rpx;
  935. font-family: PingFang SC;
  936. font-weight: bold;
  937. color: #999999;
  938. line-height: 48rpx;
  939. }
  940. .tBox2 {
  941. display: flex;
  942. padding-top: 10rpx;
  943. color: #333333;
  944. font-size: 30rpx;
  945. }
  946. .tBox {
  947. display: flex;
  948. align-items: center;
  949. padding-top: 10rpx;
  950. }
  951. .title {
  952. font-size: 24rpx;
  953. color: #999999;
  954. }
  955. page {
  956. padding-top: 10px;
  957. padding-top: constant(safe-area-inset-top);
  958. padding-top: env(safe-area-inset-top);
  959. }
  960. .inputBottom {
  961. position: fixed;
  962. left: 0;
  963. bottom: 0;
  964. background: #ffffff;
  965. height: 98rpx;
  966. display: flex;
  967. align-items: center;
  968. width: 100%;
  969. .flex_auto {
  970. flex:1;
  971. margin-left: 10% ;
  972. .input {
  973. height:60rpx;
  974. }
  975. }
  976. .btn {
  977. color: #007AFF;font-size: 30rpx;font-weight: bold;width: 15%;text-align: center;
  978. }
  979. }
  980. .noteBox {
  981. width: 100%;
  982. background: #ffffff;
  983. padding: 10rpx;
  984. border-radius: 16rpx;
  985. }
  986. .dateBox {
  987. width: 216rpx;
  988. height: 48rpx;
  989. background: #ffffff;
  990. border-radius: 24rpx;
  991. font-size: 24rpx;
  992. color: #666666;
  993. text-align: center;
  994. line-height: 48rpx;
  995. margin: 20rpx 0;
  996. }
  997. .t_content1 {
  998. color: #007aff;
  999. margin-left: 10rpx;
  1000. }
  1001. .tag1 {
  1002. border: 2rpx solid #007aff;
  1003. border-radius: 8rpx;
  1004. font-size: 20rpx;
  1005. color: #007aff;
  1006. padding: 5rpx;
  1007. }
  1008. .b_title {
  1009. color: #333333;
  1010. font-size: 30rpx;
  1011. font-weight: bold;
  1012. }
  1013. page {
  1014. background: #eaeef1;
  1015. }
  1016. .menuBox {
  1017. width: 100%;
  1018. background: #ffffff;
  1019. border-radius: 16rpx;
  1020. padding: 20rpx;
  1021. margin-bottom: 20rpx;
  1022. }
  1023. .btnspric {
  1024. border-top: 1rpx solid #eee;
  1025. display: flex;
  1026. align-items: center;
  1027. justify-content: space-between;
  1028. height: 108rpx;
  1029. padding-left: 43rpx;
  1030. padding-right: 32rpx;
  1031. }
  1032. .btnspric > .lefprL {
  1033. font-size: 36rpx;
  1034. color: #0c141f;
  1035. font-weight: bold;
  1036. }
  1037. .btnspric > .lefprR {
  1038. padding: 0rpx 24rpx;
  1039. height: 60rpx;
  1040. line-height: 60rpx;
  1041. text-align: center;
  1042. color: #fff;
  1043. background: #32467b;
  1044. border-radius: 24rpx;
  1045. box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(145, 156, 178, 0.1);
  1046. }
  1047. .yhj,
  1048. .hdyhj {
  1049. padding: 24rpx 29rpx 24rpx 34rpx;
  1050. }
  1051. .yhj {
  1052. border-bottom: 16rpx solid #f9f9f9;
  1053. }
  1054. .yhjtit {
  1055. font-size: 30rpx;
  1056. color: #0c141f;
  1057. font-weight: 500;
  1058. margin-bottom: 14rpx;
  1059. }
  1060. .yhjList {
  1061. display: flex;
  1062. align-items: center;
  1063. justify-content: space-between;
  1064. margin-bottom: 14rpx;
  1065. }
  1066. .yhjList > .yhjLefts {
  1067. display: flex;
  1068. align-items: center;
  1069. }
  1070. .yhjLefts > .yhl {
  1071. color: #32467b;
  1072. font-size: 30rpx;
  1073. margin-right: 31rpx;
  1074. }
  1075. .yhjLefts > .yhbq {
  1076. font-size: 24rpx;
  1077. color: #ff9500;
  1078. border-radius: 18rpx;
  1079. background-color: rgba(255, 149, 0, 0.2);
  1080. border: 2rpx solid #ff9500;
  1081. height: 38rpx;
  1082. line-height: 38rpx;
  1083. padding: 0rpx 16rpx;
  1084. }
  1085. .ts {
  1086. font-size: 24rpx;
  1087. color: #999;
  1088. margin: 14rpx 0rpx;
  1089. padding-right: 29rpx;
  1090. padding-left: 34rpx;
  1091. }
  1092. .yh {
  1093. padding-top: 20rpx;
  1094. }
  1095. .yh > .yhtitle {
  1096. display: flex;
  1097. align-items: center;
  1098. justify-content: space-between;
  1099. padding-right: 29rpx;
  1100. padding-left: 34rpx;
  1101. }
  1102. .priceBxs {
  1103. display: flex;
  1104. align-items: center;
  1105. }
  1106. .priceBxs > .pricleft {
  1107. border-radius: 24rpx;
  1108. border: 1rpx solid #e91313;
  1109. background-color: rgba(233, 19, 19, 0.1);
  1110. padding: 0rpx 18rpx;
  1111. height: 49rpx;
  1112. line-height: 49rpx;
  1113. text-align: center;
  1114. font-size: 30rpx;
  1115. font-weight: 500;
  1116. color: #e91313;
  1117. margin-right: 13rpx;
  1118. }
  1119. .topBox {
  1120. padding: 32rpx 32rpx 24rpx;
  1121. border-bottom: 1rpx solid #eeeeee;
  1122. }
  1123. .topBox > .boldFonstType {
  1124. font-weight: 500;
  1125. font-size: 30rpx;
  1126. margin: 16rpx 0rpx 23rpx;
  1127. }
  1128. .topBox > .firstTopL {
  1129. display: flex;
  1130. align-items: center;
  1131. }
  1132. .topBox > .firstTopL > .imageBs {
  1133. width: 331rpx;
  1134. height: 160rpx;
  1135. border-radius: 6rpx;
  1136. overflow: hidden;
  1137. margin-right: 8rpx;
  1138. box-shadow: 0rpx 6rpx 6rpx 0rpx rgba(47, 67, 121, 0.08);
  1139. }
  1140. .topBox > .firstTopL > .imageBs > image {
  1141. width: 100%;
  1142. height: 100%;
  1143. }
  1144. .topBox > .firstTopL > .textBs {
  1145. font-size: 30rpx;
  1146. font-weight: bold;
  1147. color: #0c141f;
  1148. }
  1149. .content {
  1150. padding: 24rpx;
  1151. text-align: left;
  1152. }
  1153. .catalogBox {
  1154. display: flex;
  1155. align-items: center;
  1156. flex-wrap: nowrap;
  1157. overflow-x: auto;
  1158. padding-left: 38rpx;
  1159. max-height: 305rpx;
  1160. overflow-y: auto;
  1161. transition: all 0.4s;
  1162. }
  1163. .catalogBox > .catalogA {
  1164. min-width: 200rpx;
  1165. height: 48rpx;
  1166. line-height: 48rpx;
  1167. // text-align: center;
  1168. border: 2rpx solid transparent;
  1169. white-space: nowrap;
  1170. text-overflow: ellipsis;
  1171. overflow: hidden;
  1172. word-break: break-all;
  1173. border-radius: 10rpx;
  1174. background: rgba(22, 119, 255, 0.05);
  1175. padding-left: 19rpx;
  1176. box-sizing: border-box;
  1177. padding-right: 15rpx;
  1178. margin-right: 16rpx;
  1179. margin-bottom: 20rpx;
  1180. margin-top: 15rpx;
  1181. font-size: 24rpx;
  1182. color: #666;
  1183. }
  1184. .catalogBox > .activesq {
  1185. border-color: #1677ff;
  1186. }
  1187. .changeCatalogBox {
  1188. display: block;
  1189. }
  1190. .catalogBox::-webkit-scrollbar {
  1191. display: none; /* Chrome Safari */
  1192. }
  1193. .box {
  1194. position: relative;
  1195. top: 650rpx;
  1196. padding-bottom: 88rpx;
  1197. margin: 20rpx;
  1198. }
  1199. .price_t2 {
  1200. font-size: 18rpx;
  1201. font-family: PingFang SC;
  1202. font-weight: 500;
  1203. text-decoration: line-through;
  1204. color: #999999;
  1205. }
  1206. .price_t1 {
  1207. font-size: 33rpx;
  1208. font-family: PingFang SC;
  1209. font-weight: bold;
  1210. color: #e91313;
  1211. }
  1212. .sc_t {
  1213. font-size: 22rpx;
  1214. color: #000000;
  1215. }
  1216. .sc {
  1217. width: 29rpx;
  1218. height: 29rpx;
  1219. }
  1220. .buy {
  1221. width: 138rpx;
  1222. height: 48rpx;
  1223. line-height: 48rpx;
  1224. background: #32467b;
  1225. border-radius: 10rpx;
  1226. color: #ffffff;
  1227. font-size: 28rpx;
  1228. text-align: center;
  1229. vertical-align: middle;
  1230. position: absolute;
  1231. right: 30rpx;
  1232. }
  1233. .video_body {
  1234. padding-bottom: 96rpx;
  1235. }
  1236. .footer_tab {
  1237. position: fixed;
  1238. bottom: 0;
  1239. height: 96rpx;
  1240. width: 100%;
  1241. background-color: #ffffff;
  1242. }
  1243. .tj_box {
  1244. width: 50%;
  1245. display: inline-block;
  1246. text-align: center;
  1247. margin: 10rpx 0;
  1248. }
  1249. .teacher_t {
  1250. font-size: 24rpx;
  1251. font-family: PingFang SC;
  1252. font-weight: 400;
  1253. color: #666666;
  1254. line-height: 36rpx;
  1255. margin-left: 15rpx;
  1256. }
  1257. .teacher_img {
  1258. width: 87rpx;
  1259. height: 129rpx;
  1260. }
  1261. .t2 {
  1262. font-size: 24rpx;
  1263. font-family: PingFang SC;
  1264. color: #666666;
  1265. line-height: 36rpx;
  1266. margin: 15rpx;
  1267. }
  1268. .r_t2 {
  1269. width: 201rpx;
  1270. height: 49rpx;
  1271. background: rgba(22, 119, 255, 0.05);
  1272. border: 1rpx solid #32467b;
  1273. border-radius: 16rpx;
  1274. color: #666666;
  1275. font-size: 23rpx;
  1276. text-align: center;
  1277. display: flex;
  1278. align-items: center;
  1279. padding: 5rpx;
  1280. }
  1281. .scroll_box {
  1282. width: 100%;
  1283. height: 60rpx;
  1284. background: #ffffff;
  1285. box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(145, 156, 178, 0.1);
  1286. white-space: nowrap;
  1287. overflow: hidden;
  1288. margin: 15rpx 0;
  1289. }
  1290. .r_sliper {
  1291. padding: 0 20rpx;
  1292. }
  1293. .top_line {
  1294. width: 6rpx;
  1295. height: 22rpx;
  1296. background: #32467b;
  1297. margin-right: 10rpx;
  1298. }
  1299. .video_t2 {
  1300. font-size: 24rpx;
  1301. font-family: PingFang SC;
  1302. font-weight: 500;
  1303. color: #666666;
  1304. }
  1305. .video_t1 {
  1306. height: 80rpx;
  1307. color: #333333;
  1308. line-height: 80rpx;
  1309. font-size: 30rpx;
  1310. font-family: PingFang SC;
  1311. font-weight: bold;
  1312. color: #333333;
  1313. overflow: hidden;
  1314. text-overflow: ellipsis;
  1315. white-space: nowrap;
  1316. }
  1317. .video_t1_t {
  1318. display: flex;
  1319. flex-direction: column;
  1320. height: 80rpx;
  1321. color: #333333;
  1322. text-align: center;
  1323. align-items: center;
  1324. border-left: solid 1px #d6d6db;
  1325. }
  1326. .video_play {
  1327. position: absolute;
  1328. width: 95rpx;
  1329. height: 95rpx;
  1330. top: 0;
  1331. left: 0;
  1332. right: 0;
  1333. bottom: 0;
  1334. margin: auto;
  1335. }
  1336. .video_box {
  1337. position: relative;
  1338. }
  1339. .rotoct {
  1340. transform: rotate(90deg);
  1341. }
  1342. </style>