courseSection.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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. //设置播放的节ID
  94. this.$store.commit('setPlaySectionId', {playSectionId :this.newId});
  95. // return
  96. eventHub.$emit('getSection', this.menuItem)
  97. eventHub.$emit('levelId', this.levelId)
  98. }
  99. },
  100. computed: { ...mapGetters(['playSectionId']) }
  101. };
  102. </script>
  103. <style scoped>
  104. .tagRe{
  105. width: 80rpx;
  106. height: 28rpx;
  107. background: #FF3B30;
  108. border-radius: 8rpx;
  109. font-size: 20rpx;
  110. color: #FFFFFF;
  111. text-align: center;
  112. }
  113. .tryBox{
  114. width: 96rpx;
  115. height: 48rpx;
  116. background: #007AFF;
  117. border-radius: 24rpx;
  118. color: #FFFFFF;
  119. font-size: 30rpx;
  120. line-height: 48rpx;
  121. text-align: center;
  122. }
  123. .icon_up{
  124. width: 24rpx;
  125. height: 24rpx;
  126. }
  127. .t_content3{
  128. color: #007AFF;
  129. }
  130. .t_content2{
  131. color: #007AFF;
  132. }
  133. .t_content1{
  134. color: #007AFF;
  135. }
  136. .t_content{
  137. margin-left: 10rpx;
  138. color: #666666;
  139. white-space:nowrap;
  140. overflow:hidden;
  141. text-overflow:ellipsis;
  142. }
  143. .tagColor3{
  144. border: 2rpx solid #FF9500;
  145. color: #FF9500;
  146. }
  147. .tagColor2{
  148. border: 2rpx solid #FF3B30;
  149. color: #FF3B30;
  150. }
  151. .tagColor1{
  152. border: 2rpx solid #007AFF;
  153. color: #007AFF;
  154. }
  155. .color3{
  156. color: #FF9500;
  157. }
  158. .color2{
  159. color: #FF3B30;
  160. }
  161. .color1{
  162. color: #007AFF;
  163. }
  164. .tag{
  165. border-radius: 8rpx;
  166. font-size: 20rpx;
  167. padding: 5rpx;
  168. }
  169. </style>