courseSection.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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. },
  53. data() {
  54. return {
  55. nowTime:0,
  56. newId:0
  57. };
  58. },
  59. onLoad() {},
  60. created() {
  61. },
  62. mounted() {
  63. this.nowTime = Number(new Date().getTime()/1000).toFixed(0)
  64. this.newId= this.menuItem.sectionId>0?this.menuItem.sectionId:this.menuItem.menuId
  65. },
  66. methods: {
  67. getVideo(){
  68. if(!this.isBuy){
  69. //非购买
  70. if(!this.menuItem.tryListen){
  71. //不允许试听
  72. return
  73. }
  74. }
  75. if(!this.menuItem.recordingUrl){
  76. uni.showToast({
  77. title: '暂无播放数据',
  78. icon: 'error'
  79. });
  80. }
  81. if(this.playSectionId==this.newId){
  82. //切换为同一节
  83. return
  84. }
  85. //设置播放的节ID
  86. this.$store.commit('setPlaySectionId', {playSectionId :this.newId});
  87. // return
  88. eventHub.$emit('getSection', this.menuItem)
  89. eventHub.$emit('levelId', this.levelId)
  90. }
  91. },
  92. computed: { ...mapGetters(['playSectionId']) }
  93. };
  94. </script>
  95. <style scoped>
  96. .tryBox{
  97. width: 96rpx;
  98. height: 48rpx;
  99. background: #007AFF;
  100. border-radius: 24rpx;
  101. color: #FFFFFF;
  102. font-size: 30rpx;
  103. line-height: 48rpx;
  104. text-align: center;
  105. }
  106. .icon_up{
  107. width: 24rpx;
  108. height: 24rpx;
  109. }
  110. .t_content3{
  111. color: #007AFF;
  112. }
  113. .t_content2{
  114. color: #007AFF;
  115. }
  116. .t_content1{
  117. color: #007AFF;
  118. }
  119. .t_content{
  120. margin-left: 10rpx;
  121. color: #666666;
  122. white-space:nowrap;
  123. overflow:hidden;
  124. text-overflow:ellipsis;
  125. }
  126. .tagColor3{
  127. border: 2rpx solid #FF9500;
  128. color: #FF9500;
  129. }
  130. .tagColor2{
  131. border: 2rpx solid #FF3B30;
  132. color: #FF3B30;
  133. }
  134. .tagColor1{
  135. border: 2rpx solid #007AFF;
  136. color: #007AFF;
  137. }
  138. .color3{
  139. color: #FF9500;
  140. }
  141. .color2{
  142. color: #FF3B30;
  143. }
  144. .color1{
  145. color: #007AFF;
  146. }
  147. .tag{
  148. border-radius: 8rpx;
  149. font-size: 20rpx;
  150. padding: 5rpx;
  151. }
  152. </style>