detail.vue 33 KB

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