courseSection.vue 4.3 KB

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