courseSection.vue 4.0 KB

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