courseSection.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  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;">
  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?'color1':''">{{menuItem.name}}</view>
  10. <view v-if="menuItem.sectionType==2" :class="playSectionId==newId?'color2':''">{{menuItem.name}}</view>
  11. <view v-if="menuItem.sectionType==3" :class="playSectionId==newId?'color3':''">{{menuItem.name}}</view>
  12. <view style="font-size: 20rpx;color: #FF3B30;" v-if="menuItem.liveStartTime">
  13. <view v-if="menuItem.liveStartTime>nowTime">
  14. <text>{{$method.timestampToTime(menuItem.liveStartTime, isDay =false)}}</text>-
  15. <text>{{$method.timestampToTime(menuItem.liveEndTime, isDay =false).substr(11,9)}}</text>
  16. </view>
  17. <view v-if="menuItem.liveStartTime<=nowTime&&menuItem.liveEndTime>nowTime">
  18. <text>直播中</text>
  19. </view>
  20. <view v-if="menuItem.liveEndTime<nowTime">
  21. <text>回放</text>
  22. </view>
  23. </view>
  24. </view>
  25. <view v-if="menuItem.sectionType==null">{{menuItem.name}}</view>
  26. </view>
  27. <view v-if="isRebuild||menuItem.rebuild>0" class="tagRe">待重修</view>
  28. <view v-else>
  29. <view v-if="menuItem.learning==1" class="tagGreen">已看完</view>
  30. </view>
  31. </view>
  32. <view v-if="menuItem.tryListen&&!isBuy" class="tryBox">
  33. 试看
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. import { mapGetters } from 'vuex';
  39. import eventHub from '@/common/eventHub.js'
  40. export default {
  41. name: 'courseSection',
  42. props: {
  43. courseId: {
  44. type: Number,
  45. default: 0
  46. },
  47. goodsId: {
  48. type: Number,
  49. default: 0
  50. },
  51. menuItem: {
  52. type: Object,
  53. default: {}
  54. },
  55. isBuy: {
  56. type: Boolean,
  57. default: false
  58. },
  59. levelId: {
  60. type: String,
  61. default: ""
  62. },
  63. isRebuild: {
  64. type: Boolean,
  65. default: false
  66. },
  67. gradeId: {
  68. type: Number,
  69. default: 0
  70. }
  71. },
  72. data() {
  73. return {
  74. nowTime:0,
  75. newId:0
  76. };
  77. },
  78. onLoad() {},
  79. created() {
  80. },
  81. mounted() {
  82. this.nowTime = Number(new Date().getTime()/1000).toFixed(0)
  83. this.newId= this.menuItem.sectionId>0?this.menuItem.sectionId:this.menuItem.menuId
  84. },
  85. methods: {
  86. getVideo(){
  87. if(this.menuItem.sectionType==1||this.menuItem.sectionType==3){
  88. //录播
  89. if(!this.isBuy){
  90. //非购买
  91. if(!this.menuItem.tryListen){
  92. //不允许试听
  93. return
  94. }
  95. }
  96. if(!this.menuItem.recordingUrl){
  97. uni.showToast({
  98. title: '暂无播放地址数据',
  99. icon: 'error'
  100. });
  101. }
  102. if(this.playSectionId==this.newId){
  103. //切换为同一节
  104. return
  105. }
  106. if(this.playSectionId>0){
  107. //切换视频
  108. let oldSectionId = this.playSectionId
  109. uni.$emit('changeSection', oldSectionId)
  110. }
  111. //设置播放的节ID
  112. this.$store.commit('setPlaySectionId', {playSectionId :this.newId});
  113. this.$store.commit('setPlayVID', {playVID :this.menuItem.recordingUrl});
  114. uni.$emit('getSection', this.menuItem)
  115. uni.$emit('levelId', this.levelId)
  116. }
  117. if(this.menuItem.sectionType==2){
  118. //直播
  119. if(!this.isBuy){
  120. //非购买
  121. return
  122. }
  123. if(!this.menuItem.liveUrl){
  124. uni.showToast({
  125. title: '暂无直播地址数据',
  126. icon: 'error'
  127. });
  128. }
  129. if(this.playSectionId==this.newId){
  130. //切换为同一频道
  131. return
  132. }
  133. //设置播放的节ID
  134. this.$store.commit('setPlaySectionId', {playSectionId :this.newId});
  135. this.$store.commit('setPlayChannelId', {playChannelId :this.menuItem.liveUrl});
  136. uni.$emit('getChannel', this.menuItem)
  137. console.log(this.menuItem,"频道")
  138. }
  139. }
  140. },
  141. computed: { ...mapGetters(['playSectionId','playChannelId','playVID']) }
  142. };
  143. </script>
  144. <style scoped>
  145. .tagGreen{
  146. width: 80rpx;
  147. height: 28rpx;
  148. background: #34C759;
  149. border-radius: 8rpx;
  150. font-size: 20rpx;
  151. color: #FFFFFF;
  152. text-align: center;
  153. }
  154. .tagRe{
  155. width: 80rpx;
  156. height: 28rpx;
  157. background: #FF3B30;
  158. border-radius: 8rpx;
  159. font-size: 20rpx;
  160. color: #FFFFFF;
  161. text-align: center;
  162. }
  163. .tryBox{
  164. width: 96rpx;
  165. height: 48rpx;
  166. background: #007AFF;
  167. border-radius: 24rpx;
  168. color: #FFFFFF;
  169. font-size: 30rpx;
  170. line-height: 48rpx;
  171. text-align: center;
  172. }
  173. .icon_up{
  174. width: 24rpx;
  175. height: 24rpx;
  176. }
  177. .t_content3{
  178. color: #007AFF;
  179. }
  180. .t_content2{
  181. color: #007AFF;
  182. }
  183. .t_content1{
  184. color: #007AFF;
  185. }
  186. .t_content{
  187. margin-left: 10rpx;
  188. color: #666666;
  189. white-space:nowrap;
  190. overflow:hidden;
  191. text-overflow:ellipsis;
  192. }
  193. .tagColor3{
  194. border: 2rpx solid #FF9500;
  195. color: #FF9500;
  196. }
  197. .tagColor2{
  198. border: 2rpx solid #FF3B30;
  199. color: #FF3B30;
  200. }
  201. .tagColor1{
  202. border: 2rpx solid #007AFF;
  203. color: #007AFF;
  204. }
  205. .color3{
  206. color: #FF9500;
  207. }
  208. .color2{
  209. color: #FF3B30;
  210. }
  211. .color1{
  212. color: #007AFF;
  213. }
  214. .tag{
  215. border-radius: 8rpx;
  216. font-size: 20rpx;
  217. padding: 5rpx;
  218. }
  219. </style>