CourseLive.vue 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <template>
  2. <view>
  3. <!-- 左侧显示略缩图、图标 -->
  4. <uni-list>
  5. <uni-list-item v-for="item in dataList" :show-arrow="true" :title="item.title" :note="item.intro"
  6. :rightText="stateText(item.state)" link="navigateTo" @click="showLive(item)">
  7. </uni-list-item>
  8. </uni-list>
  9. </view>
  10. </template>
  11. <script>
  12. export default {
  13. name: 'CourseLive',
  14. props: {
  15. value: Array,
  16. courseId: String
  17. },
  18. data() {
  19. return {
  20. current: {},
  21. dataList: []
  22. }
  23. },
  24. watch: {
  25. value: {
  26. handler(val) {
  27. this.dataList = val
  28. }
  29. }
  30. },
  31. created() {
  32. this.dataList = this.value
  33. },
  34. methods: {
  35. stateText(state) {
  36. if (state === 0) {
  37. return "未开始";
  38. }
  39. if (state === 1) {
  40. return "直播中";
  41. }
  42. if (state === 2) {
  43. return "已结束";
  44. }
  45. },
  46. showLive(live) {
  47. uni.navigateTo({
  48. url: `/pages/course/live?courseId=${this.courseId}&liveId=${live.id}&url=${encodeURIComponent(live.m3u8Url)}`
  49. });
  50. }
  51. }
  52. }
  53. </script>
  54. <style scoped>
  55. </style>