detail.vue 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284
  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 height="78" 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 style="width: 73%;height: 88rpx;margin-bottom: 15rpx;margin-left: 10% ;">
  89. <u-input height="78" fixed="true" :placeholder="placeholder" type="textarea" :custom-style="inputStyle" v-model="ctxValue" />
  90. </view>
  91. <view style="color: #007AFF;font-size: 30rpx;font-weight: bold;width: 15%;text-align: center;" @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. console.log(newstate, 6989);
  620. if (newstate.detail.newstate == 'playing') {
  621. if (this.needSeek) {
  622. var polyvPlayerContext = this.selectComponent('#playerVideo');
  623. polyvPlayerContext.seek(this.recordObj.studyDuration);
  624. polyvPlayerContext.play();
  625. this.needSeek = false;
  626. }
  627. //开始播放
  628. if (this.timer) {
  629. clearInterval(this.timer);
  630. }
  631. this.timer = setInterval(this.timeEvent, 1500); //定时器
  632. }
  633. if (newstate.detail.newstate == 'pause') {
  634. //暂停提交记录
  635. /* this.ossAvatarUrl = ""
  636. this.postStudyRecord() */
  637. }
  638. if (newstate.detail.newstate == 'ended') {
  639. this.ossAvatarUrl = '';
  640. this.postStudyRecord(1);
  641. }
  642. },
  643. //拍照
  644. openPhoto() {
  645. this.photoPopup = true;
  646. uni.authorize({
  647. scope: 'scope.camera',
  648. success() {
  649. }
  650. })
  651. },
  652. async submit() {
  653. const waitYS = await this.imageInfos();
  654. this.postStudyRecord(); //提交记录
  655. //恢复播放
  656. var polyvPlayerContext = this.selectComponent('#playerVideo');
  657. if (polyvPlayerContext != null) {
  658. polyvPlayerContext.play();
  659. }
  660. console.log(this.ossAvatarUrl, '拍照完成456');
  661. },
  662. //确认拍照
  663. takePhoto() {
  664. var self = this;
  665. const ctx = uni.createCameraContext();
  666. ctx.takePhoto({
  667. quality: 'high',
  668. success: res => {
  669. console.log(res.tempImagePath);
  670. self.avatarUrl = res.tempImagePath;
  671. self.submit();
  672. self.photoPopup = false;
  673. },
  674. fail: err => {
  675. console.log(err);
  676. }
  677. });
  678. },
  679. //拍照报错
  680. error(e) {
  681. console.log(e.detail);
  682. },
  683. //关闭相机
  684. closePhoto() {
  685. this.photoPopup = false;
  686. },
  687. getGoodsDetail() {
  688. let self = this;
  689. this.$api.goodsDetail(this.goodsId).then(res => {
  690. self.goodsData = res.data.data;
  691. self.gradeId = self.goodsData.gradeId;
  692. console.log(self.gradeId, 698);
  693. self.getMenuList();
  694. self.getReMenuList(); //获取重修目录
  695. if (self.goodsData.goodsPlayConfig) {
  696. self.goodsPlayConfig = JSON.parse(self.goodsData.goodsPlayConfig);
  697. if (self.goodsPlayConfig.autoPlay > 0) {
  698. self.autoplay = true;
  699. }
  700. if (self.goodsPlayConfig.drag > 0) {
  701. self.isAllowSeek = 'yes';
  702. }
  703. if (self.goodsPlayConfig.speed > 0) {
  704. self.playbackRate = [0.5, 0.8, 1.0, 1.25, 1.5, 2.0];
  705. }
  706. }
  707. if (self.goodsData.goodsPhotographConfig) {
  708. self.goodsPhotographConfig = JSON.parse(self.goodsData.goodsPhotographConfig);
  709. if (self.goodsPhotographConfig.intervalTime) {
  710. self.intervalTimeList = self.goodsPhotographConfig.intervalTime.split(',');
  711. }
  712. }
  713. });
  714. },
  715. startVideo() {
  716. this.startStatus = true;
  717. },
  718. getAnswerList() {
  719. let self = this;
  720. this.$api.answerList({ courseId: this.courseId }).then(res => {
  721. if (res.data.code == 200) {
  722. self.answerList = res.data.rows;
  723. }
  724. });
  725. },
  726. getReMenuList() {
  727. let self = this;
  728. this.$api.reMenuList({ courseId: this.courseId, rebuild: 1, gradeId: this.gradeId }).then(res => {
  729. if (res.data.code == 200) {
  730. for (let i = 0; i < res.data.rows.length; i++) {
  731. let item = res.data.rows[i];
  732. item.down = true;
  733. item.id = item.menuId;
  734. item.name = item.menuName;
  735. }
  736. self.reMenuList = res.data.rows;
  737. if(self.reMenuList.length>0){
  738. self.list.push({name:'重修目录'})
  739. }
  740. }
  741. });
  742. },
  743. getMenuList() {
  744. let self = this;
  745. this.$api.reMenuList({ courseId: this.courseId, gradeId: this.gradeId }).then(res => {
  746. if (res.data.code == 200) {
  747. for (let i = 0; i < res.data.rows.length; i++) {
  748. let item = res.data.rows[i];
  749. item.down = true;
  750. item.id = item.menuId;
  751. item.name = item.menuName;
  752. }
  753. self.menuList = res.data.rows;
  754. }
  755. });
  756. },
  757. courseDetail() {
  758. let self = this;
  759. this.$api.courseDetail(this.courseId).then(res => {
  760. if (res.data.code == 200) {
  761. self.detail = res.data.data;
  762. self.gradeId = self.detail.gradeId;
  763. }
  764. });
  765. },
  766. open(item) {
  767. item.showChildren = !item.showChildren;
  768. },
  769. change(index) {
  770. this.current = index;
  771. }
  772. }
  773. };
  774. </script>
  775. <style lang="scss" scope>
  776. .btnReply {
  777. width: 80rpx;
  778. height: 40rpx;
  779. background: #e3f0ff;
  780. border-radius: 16rpx;
  781. text-align: center;
  782. color: #007aff;
  783. }
  784. .btnDel {
  785. width: 80rpx;
  786. height: 40rpx;
  787. background: #ffedf0;
  788. border-radius: 16rpx;
  789. text-align: center;
  790. color: #ff2d55;
  791. }
  792. .btnReply {
  793. width: 80rpx;
  794. height: 40rpx;
  795. background: #e3f0ff;
  796. border-radius: 16rpx;
  797. font-size: 24rpx;
  798. }
  799. .photoBox {
  800. .photoTop {
  801. height: 74upx;
  802. display: flex;
  803. align-items: center;
  804. justify-content: space-between;
  805. padding: 0upx 38upx;
  806. .sqzz {
  807. width: 28upx;
  808. height: 28upx;
  809. display: flex;
  810. align-items: center;
  811. justify-content: center;
  812. }
  813. .centersq {
  814. color: #333;
  815. font-size: 30upx;
  816. font-weight: 500;
  817. }
  818. }
  819. .photoCenter {
  820. width: 750upx;
  821. height: 979upx;
  822. position: relative;
  823. .custom {
  824. width: 750upx;
  825. height: 979upx;
  826. position: absolute;
  827. top: 0;
  828. left: 0;
  829. image {
  830. width: 100%;
  831. height: 100%;
  832. }
  833. }
  834. }
  835. .btnResult {
  836. height: 100upx;
  837. width: 100%;
  838. background-color: #07c160;
  839. text-align: center;
  840. line-height: 100upx;
  841. color: #fff;
  842. font-size: 32upx;
  843. font-weight: bold;
  844. }
  845. }
  846. .chat_box {
  847. display: flex;
  848. padding: 20rpx;
  849. justify-content: space-between;
  850. }
  851. .chat3 {
  852. font-size: 30rpx;
  853. font-family: PingFang SC;
  854. font-weight: 500;
  855. color: #666666;
  856. margin-top: 10rpx;
  857. }
  858. .chat2 {
  859. font-size: 20rpx;
  860. font-family: PingFang SC;
  861. font-weight: 500;
  862. color: #999999;
  863. margin-top: 10rpx;
  864. }
  865. .chat1 {
  866. font-size: 24rpx;
  867. font-family: PingFang SC;
  868. font-weight: 500;
  869. color: #333333;
  870. }
  871. .leftPadding {
  872. margin-left: 8rpx;
  873. }
  874. .t2Content {
  875. font-size: 28rpx;
  876. font-family: PingFang SC;
  877. font-weight: bold;
  878. color: #999999;
  879. line-height: 48rpx;
  880. }
  881. .tBox2 {
  882. display: flex;
  883. padding-top: 10rpx;
  884. color: #333333;
  885. font-size: 30rpx;
  886. }
  887. .tBox {
  888. display: flex;
  889. align-items: center;
  890. padding-top: 10rpx;
  891. }
  892. .title {
  893. font-size: 24rpx;
  894. color: #999999;
  895. }
  896. page {
  897. padding-top: 10px;
  898. padding-top: constant(safe-area-inset-top);
  899. padding-top: env(safe-area-inset-top);
  900. }
  901. .inputBottom {
  902. position: fixed;
  903. left: 0;
  904. bottom: 0;
  905. background: #ffffff;
  906. height: 98rpx;
  907. display: flex;
  908. align-items: center;
  909. width: 100%;
  910. }
  911. .noteBox {
  912. width: 100%;
  913. background: #ffffff;
  914. padding: 10rpx;
  915. border-radius: 16rpx;
  916. }
  917. .dateBox {
  918. width: 216rpx;
  919. height: 48rpx;
  920. background: #ffffff;
  921. border-radius: 24rpx;
  922. font-size: 24rpx;
  923. color: #666666;
  924. text-align: center;
  925. line-height: 48rpx;
  926. margin: 20rpx 0;
  927. }
  928. .t_content1 {
  929. color: #007aff;
  930. margin-left: 10rpx;
  931. }
  932. .tag1 {
  933. border: 2rpx solid #007aff;
  934. border-radius: 8rpx;
  935. font-size: 20rpx;
  936. color: #007aff;
  937. padding: 5rpx;
  938. }
  939. .b_title {
  940. color: #333333;
  941. font-size: 30rpx;
  942. font-weight: bold;
  943. }
  944. page {
  945. background: #eaeef1;
  946. }
  947. .menuBox {
  948. width: 100%;
  949. background: #ffffff;
  950. border-radius: 16rpx;
  951. padding: 20rpx;
  952. margin-bottom: 20rpx;
  953. }
  954. .btnspric {
  955. border-top: 1rpx solid #eee;
  956. display: flex;
  957. align-items: center;
  958. justify-content: space-between;
  959. height: 108rpx;
  960. padding-left: 43rpx;
  961. padding-right: 32rpx;
  962. }
  963. .btnspric > .lefprL {
  964. font-size: 36rpx;
  965. color: #0c141f;
  966. font-weight: bold;
  967. }
  968. .btnspric > .lefprR {
  969. padding: 0rpx 24rpx;
  970. height: 60rpx;
  971. line-height: 60rpx;
  972. text-align: center;
  973. color: #fff;
  974. background: #32467b;
  975. border-radius: 24rpx;
  976. box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(145, 156, 178, 0.1);
  977. }
  978. .yhj,
  979. .hdyhj {
  980. padding: 24rpx 29rpx 24rpx 34rpx;
  981. }
  982. .yhj {
  983. border-bottom: 16rpx solid #f9f9f9;
  984. }
  985. .yhjtit {
  986. font-size: 30rpx;
  987. color: #0c141f;
  988. font-weight: 500;
  989. margin-bottom: 14rpx;
  990. }
  991. .yhjList {
  992. display: flex;
  993. align-items: center;
  994. justify-content: space-between;
  995. margin-bottom: 14rpx;
  996. }
  997. .yhjList > .yhjLefts {
  998. display: flex;
  999. align-items: center;
  1000. }
  1001. .yhjLefts > .yhl {
  1002. color: #32467b;
  1003. font-size: 30rpx;
  1004. margin-right: 31rpx;
  1005. }
  1006. .yhjLefts > .yhbq {
  1007. font-size: 24rpx;
  1008. color: #ff9500;
  1009. border-radius: 18rpx;
  1010. background-color: rgba(255, 149, 0, 0.2);
  1011. border: 2rpx solid #ff9500;
  1012. height: 38rpx;
  1013. line-height: 38rpx;
  1014. padding: 0rpx 16rpx;
  1015. }
  1016. .ts {
  1017. font-size: 24rpx;
  1018. color: #999;
  1019. margin: 14rpx 0rpx;
  1020. padding-right: 29rpx;
  1021. padding-left: 34rpx;
  1022. }
  1023. .yh {
  1024. padding-top: 20rpx;
  1025. }
  1026. .yh > .yhtitle {
  1027. display: flex;
  1028. align-items: center;
  1029. justify-content: space-between;
  1030. padding-right: 29rpx;
  1031. padding-left: 34rpx;
  1032. }
  1033. .priceBxs {
  1034. display: flex;
  1035. align-items: center;
  1036. }
  1037. .priceBxs > .pricleft {
  1038. border-radius: 24rpx;
  1039. border: 1rpx solid #e91313;
  1040. background-color: rgba(233, 19, 19, 0.1);
  1041. padding: 0rpx 18rpx;
  1042. height: 49rpx;
  1043. line-height: 49rpx;
  1044. text-align: center;
  1045. font-size: 30rpx;
  1046. font-weight: 500;
  1047. color: #e91313;
  1048. margin-right: 13rpx;
  1049. }
  1050. .topBox {
  1051. padding: 32rpx 32rpx 24rpx;
  1052. border-bottom: 1rpx solid #eeeeee;
  1053. }
  1054. .topBox > .boldFonstType {
  1055. font-weight: 500;
  1056. font-size: 30rpx;
  1057. margin: 16rpx 0rpx 23rpx;
  1058. }
  1059. .topBox > .firstTopL {
  1060. display: flex;
  1061. align-items: center;
  1062. }
  1063. .topBox > .firstTopL > .imageBs {
  1064. width: 331rpx;
  1065. height: 160rpx;
  1066. border-radius: 6rpx;
  1067. overflow: hidden;
  1068. margin-right: 8rpx;
  1069. box-shadow: 0rpx 6rpx 6rpx 0rpx rgba(47, 67, 121, 0.08);
  1070. }
  1071. .topBox > .firstTopL > .imageBs > image {
  1072. width: 100%;
  1073. height: 100%;
  1074. }
  1075. .topBox > .firstTopL > .textBs {
  1076. font-size: 30rpx;
  1077. font-weight: bold;
  1078. color: #0c141f;
  1079. }
  1080. .content {
  1081. padding: 24rpx;
  1082. text-align: left;
  1083. }
  1084. .catalogBox {
  1085. display: flex;
  1086. align-items: center;
  1087. flex-wrap: nowrap;
  1088. overflow-x: auto;
  1089. padding-left: 38rpx;
  1090. max-height: 305rpx;
  1091. overflow-y: auto;
  1092. transition: all 0.4s;
  1093. }
  1094. .catalogBox > .catalogA {
  1095. min-width: 200rpx;
  1096. height: 48rpx;
  1097. line-height: 48rpx;
  1098. // text-align: center;
  1099. border: 2rpx solid transparent;
  1100. white-space: nowrap;
  1101. text-overflow: ellipsis;
  1102. overflow: hidden;
  1103. word-break: break-all;
  1104. border-radius: 10rpx;
  1105. background: rgba(22, 119, 255, 0.05);
  1106. padding-left: 19rpx;
  1107. box-sizing: border-box;
  1108. padding-right: 15rpx;
  1109. margin-right: 16rpx;
  1110. margin-bottom: 20rpx;
  1111. margin-top: 15rpx;
  1112. font-size: 24rpx;
  1113. color: #666;
  1114. }
  1115. .catalogBox > .activesq {
  1116. border-color: #1677ff;
  1117. }
  1118. .changeCatalogBox {
  1119. display: block;
  1120. }
  1121. .catalogBox::-webkit-scrollbar {
  1122. display: none; /* Chrome Safari */
  1123. }
  1124. .box {
  1125. position: relative;
  1126. top: 650rpx;
  1127. padding-bottom: 88rpx;
  1128. margin: 20rpx;
  1129. }
  1130. .price_t2 {
  1131. font-size: 18rpx;
  1132. font-family: PingFang SC;
  1133. font-weight: 500;
  1134. text-decoration: line-through;
  1135. color: #999999;
  1136. }
  1137. .price_t1 {
  1138. font-size: 33rpx;
  1139. font-family: PingFang SC;
  1140. font-weight: bold;
  1141. color: #e91313;
  1142. }
  1143. .sc_t {
  1144. font-size: 22rpx;
  1145. color: #000000;
  1146. }
  1147. .sc {
  1148. width: 29rpx;
  1149. height: 29rpx;
  1150. }
  1151. .buy {
  1152. width: 138rpx;
  1153. height: 48rpx;
  1154. line-height: 48rpx;
  1155. background: #32467b;
  1156. border-radius: 10rpx;
  1157. color: #ffffff;
  1158. font-size: 28rpx;
  1159. text-align: center;
  1160. vertical-align: middle;
  1161. position: absolute;
  1162. right: 30rpx;
  1163. }
  1164. .video_body {
  1165. padding-bottom: 96rpx;
  1166. }
  1167. .footer_tab {
  1168. position: fixed;
  1169. bottom: 0;
  1170. height: 96rpx;
  1171. width: 100%;
  1172. background-color: #ffffff;
  1173. }
  1174. .tj_box {
  1175. width: 50%;
  1176. display: inline-block;
  1177. text-align: center;
  1178. margin: 10rpx 0;
  1179. }
  1180. .teacher_t {
  1181. font-size: 24rpx;
  1182. font-family: PingFang SC;
  1183. font-weight: 400;
  1184. color: #666666;
  1185. line-height: 36rpx;
  1186. margin-left: 15rpx;
  1187. }
  1188. .teacher_img {
  1189. width: 87rpx;
  1190. height: 129rpx;
  1191. }
  1192. .t2 {
  1193. font-size: 24rpx;
  1194. font-family: PingFang SC;
  1195. color: #666666;
  1196. line-height: 36rpx;
  1197. margin: 15rpx;
  1198. }
  1199. .r_t2 {
  1200. width: 201rpx;
  1201. height: 49rpx;
  1202. background: rgba(22, 119, 255, 0.05);
  1203. border: 1rpx solid #32467b;
  1204. border-radius: 16rpx;
  1205. color: #666666;
  1206. font-size: 23rpx;
  1207. text-align: center;
  1208. display: flex;
  1209. align-items: center;
  1210. padding: 5rpx;
  1211. }
  1212. .scroll_box {
  1213. width: 100%;
  1214. height: 60rpx;
  1215. background: #ffffff;
  1216. box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(145, 156, 178, 0.1);
  1217. white-space: nowrap;
  1218. overflow: hidden;
  1219. margin: 15rpx 0;
  1220. }
  1221. .r_sliper {
  1222. padding: 0 20rpx;
  1223. }
  1224. .top_line {
  1225. width: 6rpx;
  1226. height: 22rpx;
  1227. background: #32467b;
  1228. margin-right: 10rpx;
  1229. }
  1230. .video_t2 {
  1231. font-size: 24rpx;
  1232. font-family: PingFang SC;
  1233. font-weight: 500;
  1234. color: #666666;
  1235. }
  1236. .video_t1 {
  1237. height: 80rpx;
  1238. color: #333333;
  1239. line-height: 80rpx;
  1240. font-size: 30rpx;
  1241. font-family: PingFang SC;
  1242. font-weight: bold;
  1243. color: #333333;
  1244. overflow: hidden;
  1245. text-overflow: ellipsis;
  1246. white-space: nowrap;
  1247. }
  1248. .video_t1_t {
  1249. display: flex;
  1250. flex-direction: column;
  1251. height: 80rpx;
  1252. color: #333333;
  1253. text-align: center;
  1254. align-items: center;
  1255. border-left: solid 1px #d6d6db;
  1256. }
  1257. .video_play {
  1258. position: absolute;
  1259. width: 95rpx;
  1260. height: 95rpx;
  1261. top: 0;
  1262. left: 0;
  1263. right: 0;
  1264. bottom: 0;
  1265. margin: auto;
  1266. }
  1267. .video_box {
  1268. position: relative;
  1269. }
  1270. .rotoct {
  1271. transform: rotate(90deg);
  1272. }
  1273. </style>