courseSection.vue 4.0 KB

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