courseSection.vue 3.2 KB

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