courseSection.vue 4.3 KB

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