study.vue 4.5 KB

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