courseSection.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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)}}</text>-
  15. <text>{{$method.timestampToTime(menuItem.liveEndTime)}}</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>
  29. <view v-if="menuItem.tryListen&&!isBuy" class="tryBox">
  30. 试看
  31. </view>
  32. </view>
  33. </template>
  34. <script>
  35. import { mapGetters } from 'vuex';
  36. import eventHub from '@/common/eventHub.js'
  37. export default {
  38. name: 'courseSection',
  39. props: {
  40. menuItem: {
  41. type: Object,
  42. default: {}
  43. },
  44. isBuy: {
  45. type: Boolean,
  46. default: false
  47. },
  48. levelId: {
  49. type: String,
  50. default: ""
  51. },
  52. isRebuild: {
  53. type: Boolean,
  54. default: false
  55. },
  56. gradeId: {
  57. type: Number,
  58. default: 0
  59. }
  60. },
  61. data() {
  62. return {
  63. nowTime:0,
  64. newId:0
  65. };
  66. },
  67. onLoad() {},
  68. created() {
  69. },
  70. mounted() {
  71. this.nowTime = Number(new Date().getTime()/1000).toFixed(0)
  72. this.newId= this.menuItem.sectionId>0?this.menuItem.sectionId:this.menuItem.menuId
  73. },
  74. methods: {
  75. getVideo(){
  76. if(!this.isBuy){
  77. //非购买
  78. if(!this.menuItem.tryListen){
  79. //不允许试听
  80. return
  81. }
  82. }
  83. if(!this.menuItem.recordingUrl){
  84. uni.showToast({
  85. title: '暂无播放数据',
  86. icon: 'error'
  87. });
  88. }
  89. if(this.playSectionId==this.newId){
  90. //切换为同一节
  91. return
  92. }
  93. if(this.playSectionId){
  94. //切换视频
  95. let oldSectionId = this.playSectionId
  96. eventHub.$emit('changeSection', oldSectionId)
  97. }
  98. //设置播放的节ID
  99. this.$store.commit('setPlaySectionId', {playSectionId :this.newId});
  100. // return
  101. eventHub.$emit('getSection', this.menuItem)
  102. eventHub.$emit('levelId', this.levelId)
  103. }
  104. },
  105. computed: { ...mapGetters(['playSectionId']) }
  106. };
  107. </script>
  108. <style scoped>
  109. .tagRe{
  110. width: 80rpx;
  111. height: 28rpx;
  112. background: #FF3B30;
  113. border-radius: 8rpx;
  114. font-size: 20rpx;
  115. color: #FFFFFF;
  116. text-align: center;
  117. }
  118. .tryBox{
  119. width: 96rpx;
  120. height: 48rpx;
  121. background: #007AFF;
  122. border-radius: 24rpx;
  123. color: #FFFFFF;
  124. font-size: 30rpx;
  125. line-height: 48rpx;
  126. text-align: center;
  127. }
  128. .icon_up{
  129. width: 24rpx;
  130. height: 24rpx;
  131. }
  132. .t_content3{
  133. color: #007AFF;
  134. }
  135. .t_content2{
  136. color: #007AFF;
  137. }
  138. .t_content1{
  139. color: #007AFF;
  140. }
  141. .t_content{
  142. margin-left: 10rpx;
  143. color: #666666;
  144. white-space:nowrap;
  145. overflow:hidden;
  146. text-overflow:ellipsis;
  147. }
  148. .tagColor3{
  149. border: 2rpx solid #FF9500;
  150. color: #FF9500;
  151. }
  152. .tagColor2{
  153. border: 2rpx solid #FF3B30;
  154. color: #FF3B30;
  155. }
  156. .tagColor1{
  157. border: 2rpx solid #007AFF;
  158. color: #007AFF;
  159. }
  160. .color3{
  161. color: #FF9500;
  162. }
  163. .color2{
  164. color: #FF3B30;
  165. }
  166. .color1{
  167. color: #007AFF;
  168. }
  169. .tag{
  170. border-radius: 8rpx;
  171. font-size: 20rpx;
  172. padding: 5rpx;
  173. }
  174. </style>