courseSection.vue 23 KB

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