courseSection.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783
  1. <template>
  2. <view style="display: flex;justify-content: space-between;align-items: center;" @click="getVideo">
  3. <view style="display: flex;justify-content: space-between;margin: 20rpx 0;width: 100%;">
  4. <view style="display: flex;align-items: center;flex:1;">
  5. <view class="tag tagColor1" v-if="menuItem.sectionType==1">录播</view>
  6. <view class="tag tagColor2" v-if="menuItem.sectionType==2">直播</view>
  7. <view class="tag tagColor3" v-if="menuItem.sectionType==3">回放</view>
  8. <view class="t_content">
  9. <view v-if="menuItem.sectionType==1" :class="playSectionId==newId && playNextId==playId?'color1':''">{{menuItem.name || ''}}</view>
  10. <view v-if="menuItem.sectionType==2" :class="playSectionId==newId && playNextId==playId?'color2':''">{{menuItem.name || ''}}</view>
  11. <view v-if="menuItem.sectionType==3" :class="playSectionId==newId && playNextId==playId?'color3':''">{{menuItem.name || ''}}</view>
  12. <view style="font-size: 20rpx;color: #FF3B30;" v-if="menuItem.sectionType==2 && menuItem.liveStartTime">
  13. <view v-if="menuItem.liveStartTime>nowTime || !isBuy">
  14. <text>{{$method.timestampToTime(menuItem.liveStartTime, isDay =false)}}</text>-
  15. <text>{{$method.timestampToTime(menuItem.liveEndTime, isDay =false)}}</text>
  16. </view>
  17. <template v-if="isLast()">
  18. <view v-if="liveLast.watchStatus == 'live'">
  19. <text>直播中</text>
  20. </view>
  21. <view v-if="liveLast.watchStatus == 'end'">
  22. <text>当前直播回放视频请稍后再查看</text>
  23. </view>
  24. </template>
  25. <!-- <view v-if="menuItem.liveStartTime<=nowTime&&menuItem.liveEndTime>nowTime">
  26. <text>直播中</text>
  27. </view>
  28. <view v-if="menuItem.liveEndTime<nowTime">
  29. <text>回放</text>
  30. </view> -->
  31. </view>
  32. <view style="font-size: 20rpx;color: #FF3B30;" v-if="menuItem.sectionType == 3">
  33. <view v-if="!menuItem.recordingUrl">
  34. <text>当前直播回放视频请稍后再查看</text>
  35. </view>
  36. <view v-else>
  37. 回放中
  38. </view>
  39. </view>
  40. </view>
  41. <view v-if="menuItem.sectionType==null">{{menuItem.name || ''}}</view>
  42. </view>
  43. <view style="font-size: 20rpx;color: #FF3B30;" v-if="menuItem.liveStartTime && menuItem.sectionType != 3 && isBuy">
  44. <template v-if="!isLast() && !isLive">
  45. <view class="tagWillPlay" v-if="menuItem.liveStartTime>nowTime">
  46. <text>待开播</text>
  47. </view>
  48. <view class="tagPlaying" v-if="menuItem.liveStartTime<=nowTime&&menuItem.liveEndTime>nowTime">
  49. <text>直播中</text>
  50. </view>
  51. <view class="tagPlayed" v-if="menuItem.liveEndTime<nowTime">
  52. <text>已结束</text>
  53. </view>
  54. </template>
  55. </view>
  56. <!-- 直播课程没有学习状态 -->
  57. <template v-if="!isLive">
  58. <view v-if="(isRebuild||menuItem.rebuild>0)" class="tagRe">待重修</view>
  59. <view v-else>
  60. <view v-if="menuItem.learning==1" class="tagGreen">已看完</view>
  61. </view>
  62. </template>
  63. <view v-if="checkTest()" class="exercises" @click.stop="toDoSectionExam()">
  64. <text class="exe_w">习题</text>
  65. <u-icon name="arrow-right" color="#498AFE" size="28"></u-icon>
  66. </view>
  67. </view>
  68. <view v-if="menuItem.tryListen&&!isBuy" class="tryBox">
  69. 试看
  70. </view>
  71. </view>
  72. </template>
  73. <script>
  74. import { mapGetters } from 'vuex';
  75. import {WEBVIEW_URL} from '@/common/request.js'
  76. export default {
  77. name: 'courseSection',
  78. props: {
  79. isLive:false, //是否是直播课
  80. orderGoodsId:{
  81. default:0
  82. },
  83. preItem:{
  84. default:undefined,
  85. },
  86. learningOrder:{ //是否设置学习顺序 1 章节顺序 0不设置 2从头学到尾顺序
  87. type:Number,
  88. default:0
  89. },
  90. courseId: {
  91. type: Number,
  92. default: 0
  93. },
  94. goodsId: {
  95. type: Number,
  96. default: 0
  97. },
  98. menuItem: {
  99. type: Object,
  100. default: {}
  101. },
  102. isBuy: {
  103. type: Boolean,
  104. default: false
  105. },
  106. levelId: {
  107. type: String,
  108. default: ""
  109. },
  110. isRebuild: {
  111. type: Boolean,
  112. default: false
  113. },
  114. gradeId: {
  115. type: Number,
  116. default: 0
  117. },
  118. nextMenuItem: {
  119. type: Object,
  120. default: {}
  121. },
  122. sectionMaxNum:{
  123. default:undefined,
  124. },
  125. // 章->所有节试卷列表
  126. ChapterSectionExam: {
  127. type: Array,
  128. default: () => [],
  129. },
  130. // 区分是模块试卷还是章试卷,3是模块试卷
  131. testType: {
  132. type: Number,
  133. default: 0,
  134. }
  135. },
  136. watch:{
  137. menuItem(val) {
  138. console.log(val,'val')
  139. }
  140. },
  141. data() {
  142. return {
  143. nowTime:0,
  144. newId:0,
  145. playId:'',
  146. clickLock:false, //点击锁,防止连续点击多次
  147. moduleSectionExam: [], // 模块下的所有节试卷列表
  148. chapterExams: {},
  149. moduleExams: {},
  150. };
  151. },
  152. onLoad() {
  153. },
  154. created() {
  155. if (this.testType == 3) {
  156. // 模块下的所有节试卷列表
  157. this.$api.reSectionExamList({
  158. chapterId: 0,
  159. courseId: this.courseId,
  160. gradeId: this.gradeId
  161. }).then((res) => {
  162. if (res.data.code == 200) {
  163. this.moduleSectionExam = res.data.data || []
  164. console.log(this.moduleSectionExam, 'this.moduleSectionExam');
  165. }
  166. })
  167. }
  168. },
  169. mounted() {
  170. this.nowTime = Number(new Date().getTime()/1000).toFixed(0)
  171. this.newId= this.menuItem.sectionId>0?this.menuItem.sectionId:this.menuItem.menuId
  172. // console.log(this.newId,'this.newId', this.playNextId)
  173. // console.log(this.playSectionId,'this.playSectionId')
  174. // console.log(this.isRebuild)
  175. // console.log(this.nextMenuItem,'nextMenuItem')
  176. // console.log(this.menuItem,'this.menuItem=======>',this.menuItem.recordingUrl, this.nowTime)
  177. let moduleId = this.menuItem.moduleId || 0;
  178. let chapterId = this.menuItem.chapterId || 0;
  179. let sectionId = this.menuItem.sectionId || this.menuItem.menuId;
  180. let playNextId = `moduleId${moduleId}chapterId${chapterId}sectionId${sectionId}${this.isRebuild?'isRebuild':''}`;
  181. this.playId = playNextId;
  182. // console.log('this.playId:', this.playId)
  183. uni.$off('playNext'+playNextId) //绑定前先移除之前的事件
  184. uni.$once('playNext'+playNextId, (data) => {
  185. //到时会触发每个节的监听事件,只允许当前节的接收
  186. let self = this
  187. if(this.nextMenuItem.recordingUrl&&this.isRebuild&&(this.newId==this.playSectionId) && data.fromRebuild){ // fromRebuild 来自重修目录的点击才弹出播放下一节
  188. //重修存在下一节
  189. uni.showModal({
  190. title: '提示',
  191. content: '是否播放下一节',
  192. success: function (res) {
  193. if (res.confirm) {
  194. let nextId= self.nextMenuItem.sectionId>0?self.nextMenuItem.sectionId:self.nextMenuItem.menuId
  195. //设置播放的节ID
  196. self.$store.commit('setPlaySectionId', {playSectionId :nextId});
  197. self.$store.commit('setPlayVID', {playVID :self.nextMenuItem.recordingUrl});
  198. let ids = self.levelId.split('-');
  199. ids[2] = nextId
  200. uni.$emit('levelId', ids.join('-'))
  201. uni.$emit('getSection', self.nextMenuItem)
  202. self.$emit('playEnd',{isRebuild:self.isRebuild})
  203. // uni.$off('playend')
  204. // uni.$on('playend',res => {
  205. // console.log('playend2')
  206. // this.$emit('playEnd',{isRebuild:this.isRebuild})
  207. // })
  208. } else {
  209. let nextId= self.nextMenuItem.sectionId>0?self.nextMenuItem.sectionId:self.nextMenuItem.menuId
  210. //设置播放的节ID
  211. self.$store.commit('setPlaySectionId', {playSectionId :nextId});
  212. self.$store.commit('setPlayVID', {playVID :self.nextMenuItem.recordingUrl});
  213. let ids = self.levelId.split('-');
  214. ids[2] = nextId
  215. self.$emit('playEnd',{isRebuild:self.isRebuild})
  216. }
  217. }
  218. });
  219. } else {
  220. this.$emit('playEnd',{isRebuild:this.isRebuild})
  221. }
  222. });
  223. },
  224. methods: {
  225. isLast() {
  226. // console.log(this.liveLast,'this.liveLast')
  227. if(this.liveLast) {
  228. let sectionASame = this.liveLast.sectionId == (this.menuItem.sectionId || this.menuItem.menuId)
  229. let chapterSame = this.liveLast.chapterId == (this.menuItem.chapterId || 0)
  230. let moduleSame = this.liveLast.moduleId == (this.menuItem.moduleId || 0);
  231. // console.log(sectionASame && chapterSame && moduleSame,'sectionASame && chapterSame && moduleSame')
  232. return sectionASame && chapterSame && moduleSame
  233. } else {
  234. return false;
  235. }
  236. },
  237. toDoSectionExam() {
  238. this.$emit('togoBack', 1)
  239. },
  240. checkTest() {
  241. let data = this.testType == 3 ? this.moduleSectionExam : this.ChapterSectionExam
  242. // console.log('data:',this.testType, data, this.moduleSectionExam, this.ChapterSectionExam)
  243. let id = this.testType == 3 ? this.menuItem.menuId : this.menuItem.sectionId
  244. if (!data) {
  245. return false
  246. }
  247. return data.some((e) => e.sectionId == id)
  248. },
  249. ChapterExam() {
  250. this.chapterExams = this.ChapterSectionExam.find((e) => e.sectionId == this.menuItem.sectionId)
  251. console.log('item', this.chapterExams)
  252. let moduleId = this.chapterExams.moduleId || 0
  253. let chapterId = this.chapterExams.chapterId || 0
  254. let sectionId = this.chapterExams.sectionId || this.chapterExams.menuId
  255. uni.navigateTo({
  256. url:
  257. "/pages2/class/questionBank?courseId=" +
  258. this.courseId +
  259. "&gradeId=" +
  260. this.gradeId +
  261. "&isFromVideo=1&id=" +
  262. this.chapterExams.typeId +
  263. "&goodsid=" +
  264. this.goodsId +
  265. "&moduleId=" +
  266. moduleId +
  267. "&chapterId=" +
  268. chapterId +
  269. "&sectionId=" +
  270. sectionId +
  271. "&orderGoodsId=" +
  272. this.orderGoodsId +
  273. "&type=2"
  274. ,
  275. });
  276. },
  277. ModuleExam() {
  278. let sectionId = this.menuItem.sectionId || this.menuItem.menuId
  279. console.log('this.moduleSectionExam: ', this.moduleSectionExam, sectionId)
  280. this.moduleExams = this.moduleSectionExam.find((e) => e.sectionId == sectionId)
  281. console.log('item--', this.moduleExams)
  282. let moduleId = this.moduleExams.moduleId || 0
  283. let chapterId = this.moduleExams.chapterId || 0
  284. uni.navigateTo({
  285. url:
  286. "/pages2/class/questionBank?courseId=" +
  287. this.courseId +
  288. "&gradeId=" +
  289. this.gradeId +
  290. "&isFromVideo=1&id=" +
  291. this.moduleExams.typeId +
  292. "&goodsid=" +
  293. this.goodsId +
  294. "&moduleId=" +
  295. moduleId +
  296. "&chapterId=" +
  297. chapterId +
  298. "&sectionId=" +
  299. sectionId +
  300. "&orderGoodsId=" +
  301. this.orderGoodsId +
  302. "&type=2"
  303. ,
  304. });
  305. },
  306. studyRecordMenuAllList() {
  307. return new Promise(resolve => {
  308. this.$api.studyRecordMenuAllList({
  309. courseId:this.courseId,
  310. gradeId:this.gradeId,
  311. goodsId:this.goodsId
  312. }).then(res => {
  313. if(res.data.code == 200) {
  314. resolve(res.data.data)
  315. }
  316. })
  317. })
  318. },
  319. gradeCheckGoodsStudy() {
  320. let moduleId = this.menuItem.moduleId || 0;
  321. let chapterId = this.menuItem.chapterId || 0;
  322. let sectionId = this.menuItem.sectionId || this.menuItem.menuId;
  323. return new Promise(resolve => {
  324. this.$api.gradeCheckGoodsStudy({
  325. goodsId:this.goodsId,
  326. gradeId:this.gradeId,
  327. moduleId:this.menuItem.moduleId || 0,
  328. chapterId:this.menuItem.chapterId || 0,
  329. sectionId:this.menuItem.sectionId || this.menuItem.menuId
  330. }).then( res => {
  331. resolve(res.data.data)
  332. })
  333. })
  334. },
  335. goodsTodayStudySectionNum() {
  336. return new Promise(resolve => {
  337. this.$api.goodsTodayStudySectionNum({goodsId:this.goodsId,gradeId:this.gradeId}).then(res => {
  338. if(res.data.code == 200) {
  339. resolve(res.data.data)
  340. }
  341. })
  342. })
  343. },
  344. async getVideo(){
  345. if(this.clickLock) {
  346. return;
  347. }
  348. this.clickLock = true;
  349. if(this.learningOrder == 2 && !this.menuItem.isRebuild && !this.isLive) { //要按从头到尾顺序学习, 且不是重修课程
  350. if(this.preItem) {
  351. let rows = await this.studyRecordMenuAllList();
  352. let newRows = [];
  353. for(let i = 0; i < rows.length; i++ ) {
  354. let moduleTrue = rows[i].moduleId == this.menuItem.moduleId || rows[i].moduleId == 0
  355. let chapterTrue = rows[i].chapterId == this.menuItem.chapterId || rows[i].chapterId == 0;
  356. let sectionTrue = (rows[i].sectionId == this.menuItem.sectionId) || (rows[i].sectionId == this.menuItem.menuId);
  357. if(moduleTrue && chapterTrue && sectionTrue) {
  358. break;
  359. } else {
  360. if(rows[i].sectionType != 2) {
  361. newRows.push(rows[i])
  362. }
  363. }
  364. }
  365. let isAllLearn = newRows.every(item => {
  366. return item.studyStatus == 1;
  367. })
  368. if(isAllLearn) {
  369. this.playVideo();
  370. } else {
  371. uni.showToast({
  372. icon:'none',
  373. title:'请按顺序学习视频课程'
  374. })
  375. }
  376. // if(this.preItem.menuType == 3) { //上一个是节
  377. // if(this.preItem.learning == 1) { //上一节学完
  378. // this.playVideo();
  379. // } else {
  380. // uni.showToast({
  381. // icon:'none',
  382. // title:'请按顺序学习视频课程'
  383. // })
  384. // }
  385. // } else if(this.preItem.menuType == 2) { //上一个是章
  386. // this.$api.reSectionList({chapterId: this.preItem.menuId || this.preItem.chapterId,gradeId:this.gradeId,courseId:this.courseId,moduleId:this.preItem.moduleId || 0}).then(res => {
  387. // if(res.data.code==200){
  388. // let lastItem = res.data.data[res.data.data.length -1];
  389. // if(lastItem.learning == 1) {
  390. // this.playVideo();
  391. // } else {
  392. // uni.showToast({
  393. // icon:'none',
  394. // title:'请按顺序学习视频课程'
  395. // })
  396. // }
  397. // }
  398. // });
  399. // } else if(this.preItem.menuType == 1) { //上一个是模块
  400. // this.$api.reChapterList({moduleId:this.preItem.menuId,gradeId:this.gradeId,courseId:this.courseId}).then(res => {
  401. // if(res.data.code==200){
  402. // let lastChapterItem = res.data.data[res.data.data.length -1];
  403. // this.$api.reSectionList({chapterId:lastChapterItem.chapterId,gradeId:this.gradeId,courseId:this.courseId,moduleId:this.menuItem.menuId || this.menuItem.moduleId}).then(res => {
  404. // if(res.data.code==200){
  405. // let lastSectionItem = res.data.data[res.data.data.length -1];
  406. // if(lastSectionItem.learning == 1) {
  407. // this.playVideo();
  408. // } else {
  409. // uni.showToast({
  410. // icon:'none',
  411. // title:'请按顺序学习视频课程'
  412. // })
  413. // }
  414. // }
  415. // });
  416. // }
  417. // });
  418. // }
  419. } else { //第一章第一节
  420. this.playVideo();
  421. }
  422. } else {
  423. this.playVideo();
  424. }
  425. setTimeout(() => {
  426. this.clickLock = false;
  427. },3000)
  428. },
  429. studyRecordGetChannelBasicInfo(channelId) {
  430. return new Promise((resolve) => {
  431. this.$api
  432. .studyRecordGetChannelBasicInfo({
  433. channelId,
  434. })
  435. .then((res) => {
  436. resolve(res.data.data);
  437. });
  438. });
  439. },
  440. async playVideo() {
  441. // console.log('直播的课程:',this.menuItem,this.menuItem.recordingUrl)
  442. if(this.menuItem.sectionType==1 || this.menuItem.sectionType == 3){
  443. //1录播 3回放
  444. if(!this.isBuy){
  445. //非购买
  446. if(!this.menuItem.tryListen){
  447. //不允许试听
  448. this.clickLock = false;
  449. return
  450. } else {
  451. this.$store.commit('setPlaySectionId', {playSectionId :this.newId});
  452. this.$store.commit('setPlayVID', {playVID :this.menuItem.recordingUrl});
  453. this.menuItem.courseId = this.courseId;
  454. uni.$emit('getSection', this.menuItem)
  455. return;
  456. }
  457. }
  458. let learnNum = await this.goodsTodayStudySectionNum()
  459. let hasLearn = await this.gradeCheckGoodsStudy();
  460. // console.log(this.sectionMaxNum,'this.sectionMaxNum')
  461. // console.log(learnNum,'learnNum')
  462. if(this.sectionMaxNum > 0) {
  463. if(learnNum >= this.sectionMaxNum && !hasLearn) {
  464. uni.showToast({
  465. icon:'none',
  466. title:`每天最多学习${this.sectionMaxNum}节`
  467. })
  468. this.clickLock = false;
  469. return;
  470. }
  471. }
  472. if(!this.menuItem.recordingUrl){
  473. uni.showToast({
  474. title: '暂无播放地址数据',
  475. icon: 'none'
  476. });
  477. this.clickLock = false;
  478. return;
  479. }
  480. /* if(this.playSectionId==this.newId){
  481. //切换为同一节
  482. return
  483. } */
  484. // 回放
  485. if (this.menuItem.sectionType == 3) {
  486. // return
  487. let moduleId = this.menuItem.moduleId || 0;
  488. let chapterId = this.menuItem.chapterId || 0;
  489. let sectionId = this.menuItem.sectionId || this.menuItem.menuId;
  490. let uuid = new Date().valueOf() + ""
  491. // buyCourse 是否购买课程:1是 0否,type=vod是回放
  492. let encode = encodeURIComponent(WEBVIEW_URL+'pages/live/index?token='+uni.getStorageSync('token')+'&userInfo='+JSON.stringify(this.userInfo)+
  493. '&channelId='+this.menuItem.liveUrl+'&gradeId='+this.gradeId+'&courseId='+this.courseId+'&goodsId='+this.goodsId+'&orderGoodsId='+this.orderGoodsId+
  494. '&sectionId='+sectionId+'&chapterId='+chapterId+'&moduleId='+moduleId+'&buyCourse=1'+'&ident='+uuid+'&sectionType=3'+'&vid='+this.menuItem.recordingUrl)
  495. uni.navigateTo({
  496. url:`../../pages/webview/index?url=`+encode
  497. })
  498. return
  499. }
  500. if(this.playSectionId>0){
  501. //切换视频
  502. let oldSectionId = this.playSectionId
  503. uni.$emit('changeSection', oldSectionId)
  504. }
  505. //设置播放的节ID
  506. this.$store.commit('setPlaySectionId', {playSectionId :this.newId});
  507. this.$store.commit('setPlayVID', {playVID :this.menuItem.recordingUrl});
  508. this.$store.commit('updatePlayNextId',this.playId)
  509. uni.$emit('levelId', this.levelId)
  510. uni.$emit('getSection', this.menuItem)
  511. uni.$emit('isRebuild',this.isRebuild)
  512. // console.log(this.menuItem,'menuItem')
  513. // uni.$off('playend')
  514. // uni.$on('playend',res => {
  515. // console.log('playend2')
  516. // this.$emit('playEnd',{isRebuild:this.isRebuild})
  517. // })
  518. }
  519. if(this.menuItem.sectionType==2){
  520. //直播
  521. if(!this.isBuy){
  522. //非购买
  523. this.clickLock = false;
  524. return
  525. }
  526. let learnNum = await this.goodsTodayStudySectionNum()
  527. let hasLearn = await this.gradeCheckGoodsStudy();
  528. // console.log(this.sectionMaxNum,'this.sectionMaxNum')
  529. // console.log(learnNum,'learnNum')
  530. if(this.sectionMaxNum > 0 && !this.isLive) {
  531. if(learnNum >= this.sectionMaxNum && !hasLearn) {
  532. uni.showToast({
  533. icon:'none',
  534. title:`每天最多学习${this.sectionMaxNum}节`
  535. })
  536. this.clickLock = false;
  537. return;
  538. }
  539. }
  540. if(!this.menuItem.liveUrl){
  541. uni.showToast({
  542. title: '暂无直播地址数据',
  543. icon: 'error'
  544. });
  545. return;
  546. }
  547. let data = await this.studyRecordGetChannelBasicInfo(this.menuItem.liveUrl);
  548. let nowTime = +this.$method.timest();
  549. if (this.menuItem.liveStartTime > nowTime) {
  550. if (data.watchStatus == "end" || data.watchStatus == "playback") {
  551. this.clickLock = false;
  552. uni.showToast({
  553. title: '直播未开始',
  554. icon: 'none'
  555. });
  556. return;
  557. }
  558. } else if (
  559. this.menuItem.liveStartTime < nowTime &&
  560. this.menuItem.liveEndTime > nowTime
  561. ) {
  562. if (data.watchStatus == "end" || data.watchStatus == "playback") {
  563. this.clickLock = false;
  564. uni.showToast({
  565. title: '暂无直播',
  566. icon: 'none'
  567. });
  568. return;
  569. }
  570. } else if (this.menuItem.liveEndTime < nowTime) {
  571. if (!data) {
  572. uni.showToast({
  573. title: '直播已结束',
  574. icon: 'none'
  575. });
  576. return;
  577. }
  578. if (data.watchStatus == "end" || data.watchStatus == "playback") {
  579. this.clickLock = false;
  580. uni.showToast({
  581. title: '直播已结束',
  582. icon: 'none'
  583. });
  584. return;
  585. }
  586. }
  587. // if (data.watchStatus == "end" || data.watchStatus == "playback") {
  588. // this.clickLock = false;
  589. // uni.showToast({
  590. // title: '直播已结束',
  591. // icon: 'none'
  592. // });
  593. // return;
  594. // }
  595. // if (data.watchStatus == "waiting") {
  596. // this.clickLock = false;
  597. // uni.showToast({
  598. // title: '直播未开始',
  599. // icon: 'none'
  600. // });
  601. // return;
  602. // }
  603. // if(this.playSectionId==this.newId){
  604. // //切换为同一频道
  605. // this.clickLock = false;
  606. // return
  607. // }
  608. let moduleId = this.menuItem.moduleId || 0;
  609. let chapterId = this.menuItem.chapterId || 0;
  610. let sectionId = this.menuItem.sectionId || this.menuItem.menuId;
  611. let uuid = new Date().valueOf() + ""
  612. // buyCourse 是否购买课程:1是 0否
  613. let encode = encodeURIComponent(WEBVIEW_URL+'pages/live/index?token='+uni.getStorageSync('token')+'&userInfo='+JSON.stringify(this.userInfo)+
  614. '&channelId='+this.menuItem.liveUrl+'&gradeId='+this.gradeId+'&courseId='+this.courseId+'&goodsId='+this.goodsId+'&orderGoodsId='+this.orderGoodsId+
  615. '&sectionId='+sectionId+'&chapterId='+chapterId+'&moduleId='+moduleId+'&buyCourse=1'+'&ident='+uuid+'&sectionType=2')
  616. uni.navigateTo({
  617. url:`../../pages/webview/index?url=`+encode
  618. })
  619. return;
  620. //设置播放的节ID
  621. // this.$store.commit('setPlaySectionId', {playSectionId :this.newId});
  622. // this.$store.commit('setPlayChannelId', {playChannelId :this.menuItem.liveUrl});
  623. // this.$store.commit('updatePlayNextId',this.playId)
  624. // uni.$emit('levelId', this.levelId)
  625. // uni.$emit('getChannel', this.menuItem)
  626. // uni.$emit('isRebuild',this.isRebuild)
  627. // console.log(this.menuItem,'menuItem')
  628. // uni.$off('playend')
  629. // uni.$on('playend',res => {
  630. // console.log('playend1')
  631. // this.$emit('playEnd',{isRebuild:this.isRebuild})
  632. // })
  633. }
  634. }
  635. },
  636. computed: { ...mapGetters(['playSectionId','playChannelId','playVID','playNextId','userInfo','liveLast']) }
  637. };
  638. </script>
  639. <style scoped lang="scss">
  640. .tagGreen{
  641. width: 80rpx;
  642. height: 28rpx;
  643. background: #34C759;
  644. border-radius: 8rpx;
  645. font-size: 20rpx;
  646. color: #FFFFFF;
  647. text-align: center;
  648. }
  649. .tagWillPlay{
  650. width: 80rpx;
  651. height: 28rpx;
  652. background: #EBF4FF;
  653. border-radius: 8rpx;
  654. font-size: 20rpx;
  655. color: #007AFF;
  656. text-align: center;
  657. }
  658. .tagPlaying{
  659. width: 80rpx;
  660. height: 28rpx;
  661. background: #FFF7EB;
  662. border-radius: 8rpx;
  663. font-size: 20rpx;
  664. color: #FF9500;
  665. text-align: center;
  666. }
  667. .tagPlayed{
  668. width: 80rpx;
  669. height: 28rpx;
  670. background: #EEEEEE;
  671. border-radius: 8rpx;
  672. font-size: 20rpx;
  673. color: #666666;
  674. text-align: center;
  675. }
  676. .tagRe{
  677. width: 80rpx;
  678. height: 28rpx;
  679. background: #FF3B30;
  680. border-radius: 8rpx;
  681. font-size: 20rpx;
  682. color: #FFFFFF;
  683. text-align: center;
  684. }
  685. .tryBox{
  686. width: 103rpx;
  687. height: 48rpx;
  688. background: #fff;
  689. border-radius: 24rpx;
  690. color: #3577E8;
  691. font-size: 24rpx;
  692. line-height: 48rpx;
  693. text-align: center;
  694. border: 1rpx solid #3577E8;
  695. }
  696. .icon_up{
  697. width: 24rpx;
  698. height: 24rpx;
  699. }
  700. .t_content3{
  701. color: #007AFF;
  702. }
  703. .t_content2{
  704. color: #007AFF;
  705. }
  706. .t_content1{
  707. color: #007AFF;
  708. }
  709. .t_content{
  710. font-size: 30rpx;
  711. margin-left: 10rpx;
  712. color: #666666;
  713. flex:1;
  714. }
  715. .tagColor3{
  716. border: 2rpx solid #FF9500;
  717. color: #FF9500;
  718. }
  719. .tagColor2{
  720. border: 2rpx solid #FF3B30;
  721. color: #FF3B30;
  722. }
  723. .tagColor1{
  724. border: 2rpx solid #007AFF;
  725. color: #007AFF;
  726. }
  727. .color3{
  728. color: #FF9500;
  729. }
  730. .color2{
  731. color: #FF3B30;
  732. }
  733. .color1{
  734. color: #007AFF;
  735. }
  736. .tag{
  737. border-radius: 8rpx;
  738. font-size: 20rpx;
  739. padding: 4rpx 10rpx;
  740. }
  741. .exercises {
  742. margin-left: 10rpx;
  743. font-size: 26rpx;
  744. color: #498AFE;
  745. >text {
  746. margin-right: 6rpx;
  747. }
  748. }
  749. </style>