detail.vue 32 KB

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