study.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <template>
  2. <view class="kecheng-study-page">
  3. <view class="icon-title-navBar-box">
  4. <view @click="goUpPage" class="nav-bar-icon"></view>
  5. <text class="nav-bar-title">{{name}}</text>
  6. </view>
  7. <!-- 播放器 -->
  8. <videoPlayVue ref="videoRef" class="phone-video-box" v-if="showVideo"></videoPlayVue>
  9. <view v-else class="phone-video-box master-image"></view>
  10. <!-- 中间区域 -->
  11. <view class="kc-info-box">
  12. <view>时长:{{period}}</view>
  13. <view>{{userCount}}人学习</view>
  14. </view>
  15. <!-- 大纲 -->
  16. <view class="phone-tab-box">
  17. <uni-segmented-control :current="current" :values="items" style-type="text" :active-color="activeColor"
  18. @clickItem="onClickItem" />
  19. </view>
  20. <view class="kecheng-content-box">
  21. <!-- 目录 -->
  22. <kechengMuluVue v-if="current === 0" :chapterArr="list" @play="handlePlay" :isHasProgress="false"
  23. :activeKjId="curPlayData&&curPlayData.kjId"></kechengMuluVue>
  24. <!-- 介绍 -->
  25. <rich-text :nodes="intro || '暂无内容'" v-if="current === 1 && intro" class="kecheng-jieshao-box"></rich-text>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. import * as kechengApi from "@/api/kecheng.js";
  31. import videoPlayVue from "@/components/videoPlay/videoPlay.vue";
  32. import kechengMuluVue from "@/components/kecheng-mulu/kecheng-mulu.vue";
  33. import {
  34. useUserCache
  35. } from "@/utils/userCache.js"
  36. import {
  37. formatSecondsToCnhms
  38. } from "@/utils/common.js"
  39. export default {
  40. components: {
  41. videoPlayVue,
  42. kechengMuluVue
  43. },
  44. data() {
  45. return {
  46. showVideo: false,
  47. items: ['目录', '介绍'],
  48. colors: ['#007aff', '#4cd964', '#dd524d'],
  49. activeColor: '#3fd2a1',
  50. current: 0, // 激活的选项卡
  51. kcId: '', // 课程
  52. title: '',
  53. period: 0, // 时长
  54. userCount: 0, // 学习人数
  55. list: [],
  56. intro: '',
  57. curPlayData: null,
  58. kechengFlag: null,
  59. zyName: '',
  60. zyLevelName: '',
  61. operId: '', // 课程
  62. }
  63. },
  64. onLoad(options) {
  65. this.kcId = options.kcId;
  66. this.init();
  67. },
  68. methods: {
  69. goUpPage() {
  70. uni.redirectTo({
  71. url: '/pages/admin/Kecheng/list'
  72. })
  73. },
  74. onClickItem(e) {
  75. if (this.current !== e.currentIndex) {
  76. this.current = e.currentIndex
  77. }
  78. },
  79. formatData(data) {
  80. data.forEach(zhang => {
  81. zhang.open = false;
  82. zhang.jieList.forEach(jie => {
  83. jie.open = false;
  84. })
  85. })
  86. return data;
  87. },
  88. handlePlay(data) {
  89. if (!this.kechengFlag) {
  90. uni.showToast({
  91. icon: 'none',
  92. title: '当前课件不可查看'
  93. })
  94. return;
  95. }
  96. this.showVideo = true;
  97. if (this.curPlayData && this.curPlayData.videoId == data.videoId) {
  98. return;
  99. }
  100. this.curPlayData = data;
  101. kechengApi.getVideoAuth({
  102. videoId: data.url
  103. }).then(res => {
  104. this.$refs.videoRef.init({
  105. videoId: data.url,
  106. playAuth: res.data,
  107. seekTime: '',
  108. isPlay: false
  109. })
  110. })
  111. },
  112. initFirstVideo() {
  113. if (this.list && this.list[0].jieList && this.list[0].jieList[0].kejianList) {
  114. // 设置默认展开项
  115. this.list[0].open = true;
  116. this.list[0].jieList[0].open = true;
  117. const kejian = this.list[0].jieList[0].kejianList[0];
  118. }
  119. },
  120. init() {
  121. kechengApi.getKechengGlStart({
  122. kcId: this.kcId
  123. }).then(res => {
  124. const {
  125. userCount,
  126. period,
  127. name,
  128. kejianUserVo,
  129. intro,
  130. kechengFlag,
  131. operId,
  132. zyName,
  133. zyLevelName,
  134. } = res.data;
  135. this.userCount = userCount;
  136. this.period = formatSecondsToCnhms(period,true);
  137. this.name = name;
  138. this.zyName = zyName;
  139. this.zyLevelName = zyLevelName;
  140. this.kechengFlag = kechengFlag;
  141. this.formatData(kejianUserVo.zhangList)
  142. this.list = kejianUserVo.zhangList;
  143. this.intro = intro;
  144. this.operId = operId;
  145. this.initFirstVideo();
  146. })
  147. }
  148. }
  149. }
  150. </script>
  151. <style>
  152. </style>