courseSection.vue 3.4 KB

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