detail.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <template>
  2. <view class="content" v-if="courseData!=null && courseData.id!=null">
  3. <view class="uni-form-item uni-column">
  4. <view class="tt1">{{courseData.title}}</view>
  5. </view>
  6. <view class="uni-form-item uni-column" v-if="courseData.catId_dictText">
  7. <view class="tt2 desc">类型:{{courseData.catId_dictText}}</view>
  8. </view>
  9. <view class="uni-form-item uni-column">
  10. <view class="tt2 desc">课时:{{courseData.periods}}</view>
  11. </view>
  12. <view v-if="courseData.state===1" class="empty">
  13. 课程已禁用,请联系管理员!
  14. </view>
  15. <view v-else-if="courseData.state===2" class="empty">
  16. 课程学习暂未开始,请持续关注!
  17. </view>
  18. <view v-else-if="courseData.state===3" class="empty">
  19. 来晚了,课程学习已截止!
  20. </view>
  21. <view v-else-if="courseData.state===4" class="empty">
  22. 当前不在可学习时间段,可学习时间段为:{{courseData.dayRule}}
  23. </view>
  24. <view v-else-if="courseData.state===5" class="empty">
  25. 每天限制最多学习{{courseData.dayLimit}}分钟,明天再来吧!
  26. </view>
  27. <view v-else style="margin-top: 20px;">
  28. <view style="background: #f5f5f5">
  29. <uni-segmented-control :current="current" :values="tabs" @clickItem="changeTab" styleType="text"
  30. activeColor="#007aff">
  31. </uni-segmented-control>
  32. </view>
  33. <scroll-view style="margin-top: 20px;">
  34. <view v-if="courseData.liveList!=null && courseData.liveList.length>0">
  35. <view v-if="current === 0">
  36. <course-live v-model="courseData.liveList"
  37. :courseId="courseData.id"
  38. :drag="courseData.videoDrag">
  39. </course-live>
  40. </view>
  41. <view v-if="current === 1">
  42. <course-file v-model="courseData.dirList"
  43. :courseId="courseData.id"
  44. :checkOn="courseData.checkOn"
  45. :checkSec="courseData.checkSec"
  46. :drag="courseData.videoDrag"/>
  47. </view>
  48. <view v-if="current === 2">
  49. <u-parse :content="courseData.content | formatRichText" @preview="preview" @navigate="navigate" ></u-parse>
  50. </view>
  51. </view>
  52. <view v-else>
  53. <view v-if="current === 0">
  54. <course-file v-model="courseData.dirList"
  55. :courseId="courseData.id"
  56. :checkOn="courseData.checkOn"
  57. :checkSec="courseData.checkSec"
  58. :drag="courseData.videoDrag"/>
  59. </view>
  60. <view v-if="current === 1">
  61. <!-- <rich-text :nodes="courseData.content | formatRichText"></rich-text> -->
  62. <u-parse :content="courseData.content | formatRichText" @preview="preview" @navigate="navigate" ></u-parse>
  63. </view>
  64. </view>
  65. </scroll-view>
  66. </view>
  67. </view>
  68. </template>
  69. <script>
  70. import cmdProgress from "@/components/cmd-progress/cmd-progress.vue"
  71. import CourseLive from "./components/CourseLive.vue"
  72. import CourseFile from "./components/CourseFile.vue"
  73. import {
  74. fetchDetail,
  75. fetchLearnList,
  76. } from '@/api/course.js'
  77. export default {
  78. components: {
  79. cmdProgress,
  80. CourseLive,
  81. CourseFile
  82. },
  83. data() {
  84. return {
  85. courseId: null,
  86. courseData: {},
  87. current: 0,
  88. tabs: ['课件列表', '课程详情']
  89. }
  90. },
  91. onShow:function(){
  92. // 返回重新获取进度
  93. if(this.courseId){
  94. this.fetchData()
  95. }
  96. },
  97. onLoad: function(option) {
  98. // 课程ID
  99. const id = option.id;
  100. if (typeof id !== 'undefined') {
  101. this.courseId = id
  102. this.fetchData()
  103. }
  104. // 支付成功刷新页面
  105. uni.$on('paySuccess', () => {
  106. this.fetchData()
  107. });
  108. },
  109. methods: {
  110. fetchData() {
  111. uni.showLoading({
  112. title: '加载中...'
  113. });
  114. fetchDetail(this.courseId).then(res => {
  115. this.courseData = res
  116. uni.hideLoading()
  117. if(res.liveList!==null && res.liveList.length>0){
  118. this.tabs = ['直播列表','课件列表', '课程详情']
  119. }
  120. })
  121. },
  122. changeTab(e) {
  123. if (this.current != e.currentIndex) {
  124. this.current = e.currentIndex;
  125. }
  126. },
  127. preview(src, e) {
  128. // do something
  129. },
  130. navigate(href, e) {
  131. // do something
  132. // window.location = href
  133. console.log('跳转...')
  134. // location.href = href
  135. uni.navigateTo({
  136. url: '/pages/webview/webview?url='+encodeURIComponent(href)
  137. })
  138. }
  139. },
  140. onUnload() {
  141. uni.$off('paySuccess');
  142. }
  143. }
  144. </script>
  145. <style scoped>
  146. .content {
  147. padding: 32rpx;
  148. font-size: 16px;
  149. }
  150. .uni-form-item {
  151. line-height: 54rpx;
  152. }
  153. /deep/
  154. .a {
  155. color: #007AFF;
  156. font-weight: 700;
  157. }
  158. </style>