study.vue 4.5 KB

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