study.vue 4.7 KB

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