detail.vue 33 KB

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