courseSection.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  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;flex:1;">
  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, isDay =false)}}</text>-
  15. <text>{{$method.timestampToTime(menuItem.liveEndTime, isDay =false).substr(11,9)}}</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 style="font-size: 20rpx;color: #FF3B30;" v-if="menuItem.liveStartTime">
  28. <view class="tagWillPlay" v-if="menuItem.liveStartTime>nowTime">
  29. <text>待开播</text>
  30. </view>
  31. <view class="tagPlaying" v-if="menuItem.liveStartTime<=nowTime&&menuItem.liveEndTime>nowTime">
  32. <text>直播中</text>
  33. </view>
  34. <view class="tagPlayed" v-if="menuItem.liveEndTime<nowTime">
  35. <text>已结束</text>
  36. </view>
  37. </view>
  38. <view v-if="isRebuild||menuItem.rebuild>0" class="tagRe">待重修</view>
  39. <view v-else>
  40. <view v-if="menuItem.learning==1" class="tagGreen">已看完</view>
  41. </view>
  42. </view>
  43. <view v-if="menuItem.tryListen&&!isBuy" class="tryBox">
  44. 试看
  45. </view>
  46. </view>
  47. </template>
  48. <script>
  49. import { mapGetters } from 'vuex';
  50. import eventHub from '@/common/eventHub.js'
  51. export default {
  52. name: 'courseSection',
  53. props: {
  54. courseId: {
  55. type: Number,
  56. default: 0
  57. },
  58. goodsId: {
  59. type: Number,
  60. default: 0
  61. },
  62. menuItem: {
  63. type: Object,
  64. default: {}
  65. },
  66. isBuy: {
  67. type: Boolean,
  68. default: false
  69. },
  70. levelId: {
  71. type: String,
  72. default: ""
  73. },
  74. isRebuild: {
  75. type: Boolean,
  76. default: false
  77. },
  78. gradeId: {
  79. type: Number,
  80. default: 0
  81. }
  82. },
  83. data() {
  84. return {
  85. nowTime:0,
  86. newId:0
  87. };
  88. },
  89. onLoad() {},
  90. created() {
  91. },
  92. mounted() {
  93. this.nowTime = Number(new Date().getTime()/1000).toFixed(0)
  94. this.newId= this.menuItem.sectionId>0?this.menuItem.sectionId:this.menuItem.menuId
  95. },
  96. methods: {
  97. getVideo(){
  98. if(this.menuItem.sectionType==1||this.menuItem.sectionType==3){
  99. //录播
  100. if(!this.isBuy){
  101. //非购买
  102. if(!this.menuItem.tryListen){
  103. //不允许试听
  104. return
  105. }
  106. }
  107. if(!this.menuItem.recordingUrl){
  108. uni.showToast({
  109. title: '暂无播放地址数据',
  110. icon: 'error'
  111. });
  112. }
  113. if(this.playSectionId==this.newId){
  114. //切换为同一节
  115. return
  116. }
  117. if(this.playSectionId>0){
  118. //切换视频
  119. let oldSectionId = this.playSectionId
  120. uni.$emit('changeSection', oldSectionId)
  121. }
  122. //设置播放的节ID
  123. this.$store.commit('setPlaySectionId', {playSectionId :this.newId});
  124. this.$store.commit('setPlayVID', {playVID :this.menuItem.recordingUrl});
  125. uni.$emit('getSection', this.menuItem)
  126. uni.$emit('levelId', this.levelId)
  127. }
  128. if(this.menuItem.sectionType==2){
  129. //直播
  130. if(!this.isBuy){
  131. //非购买
  132. return
  133. }
  134. if(!this.menuItem.liveUrl){
  135. uni.showToast({
  136. title: '暂无直播地址数据',
  137. icon: 'error'
  138. });
  139. }
  140. if(this.playSectionId==this.newId){
  141. //切换为同一频道
  142. return
  143. }
  144. //设置播放的节ID
  145. this.$store.commit('setPlaySectionId', {playSectionId :this.newId});
  146. this.$store.commit('setPlayChannelId', {playChannelId :this.menuItem.liveUrl});
  147. uni.$emit('getChannel', this.menuItem)
  148. console.log(this.menuItem,"频道")
  149. }
  150. }
  151. },
  152. computed: { ...mapGetters(['playSectionId','playChannelId','playVID']) }
  153. };
  154. </script>
  155. <style scoped lang="scss">
  156. .tagGreen{
  157. width: 80rpx;
  158. height: 28rpx;
  159. background: #34C759;
  160. border-radius: 8rpx;
  161. font-size: 20rpx;
  162. color: #FFFFFF;
  163. text-align: center;
  164. }
  165. .tagWillPlay{
  166. width: 80rpx;
  167. height: 28rpx;
  168. background: #EBF4FF;
  169. border-radius: 8rpx;
  170. font-size: 20rpx;
  171. color: #007AFF;
  172. text-align: center;
  173. }
  174. .tagPlaying{
  175. width: 80rpx;
  176. height: 28rpx;
  177. background: #FFF7EB;
  178. border-radius: 8rpx;
  179. font-size: 20rpx;
  180. color: #FF9500;
  181. text-align: center;
  182. }
  183. .tagPlayed{
  184. width: 80rpx;
  185. height: 28rpx;
  186. background: #EEEEEE;
  187. border-radius: 8rpx;
  188. font-size: 20rpx;
  189. color: #666666;
  190. text-align: center;
  191. }
  192. .tagRe{
  193. width: 80rpx;
  194. height: 28rpx;
  195. background: #FF3B30;
  196. border-radius: 8rpx;
  197. font-size: 20rpx;
  198. color: #FFFFFF;
  199. text-align: center;
  200. }
  201. .tryBox{
  202. width: 96rpx;
  203. height: 48rpx;
  204. background: #007AFF;
  205. border-radius: 24rpx;
  206. color: #FFFFFF;
  207. font-size: 30rpx;
  208. line-height: 48rpx;
  209. text-align: center;
  210. }
  211. .icon_up{
  212. width: 24rpx;
  213. height: 24rpx;
  214. }
  215. .t_content3{
  216. color: #007AFF;
  217. }
  218. .t_content2{
  219. color: #007AFF;
  220. }
  221. .t_content1{
  222. color: #007AFF;
  223. }
  224. .t_content{
  225. margin-left: 10rpx;
  226. color: #666666;
  227. white-space:nowrap;
  228. overflow:hidden;
  229. text-overflow:ellipsis;
  230. }
  231. .tagColor3{
  232. border: 2rpx solid #FF9500;
  233. color: #FF9500;
  234. }
  235. .tagColor2{
  236. border: 2rpx solid #FF3B30;
  237. color: #FF3B30;
  238. }
  239. .tagColor1{
  240. border: 2rpx solid #007AFF;
  241. color: #007AFF;
  242. }
  243. .color3{
  244. color: #FF9500;
  245. }
  246. .color2{
  247. color: #FF3B30;
  248. }
  249. .color1{
  250. color: #007AFF;
  251. }
  252. .tag{
  253. border-radius: 8rpx;
  254. font-size: 20rpx;
  255. padding: 5rpx;
  256. }
  257. </style>