study.vue 4.1 KB

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