study.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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. }
  67. },
  68. onLoad(options) {
  69. this.kcId = options.kcId;
  70. this.init();
  71. },
  72. methods: {
  73. goUpPage() {
  74. uni.redirectTo({
  75. url: '/pages/admin/Kecheng/list'
  76. })
  77. },
  78. onClickItem(e) {
  79. if (this.current !== e.currentIndex) {
  80. this.current = e.currentIndex
  81. }
  82. },
  83. formatData(data) {
  84. data.forEach(zhang => {
  85. zhang.open = false;
  86. zhang.jieList.forEach(jie => {
  87. jie.open = false;
  88. })
  89. })
  90. return data;
  91. },
  92. handlePlay(data) {
  93. if (!this.kechengFlag) {
  94. uni.showToast({
  95. icon: 'none',
  96. title: '当前课件不可查看'
  97. })
  98. return;
  99. }
  100. this.showVideo = true;
  101. if (this.curPlayData && this.curPlayData.videoId == data.videoId) {
  102. return;
  103. }
  104. this.curPlayData = data;
  105. kechengApi.getVideoAuth({
  106. videoId: data.url
  107. }).then(res => {
  108. this.$refs.videoRef.init({
  109. videoId: data.url,
  110. playAuth: res.data,
  111. seekTime: '',
  112. isPlay: false
  113. })
  114. })
  115. },
  116. initFirstVideo() {
  117. if (this.list && this.list[0].jieList && this.list[0].jieList[0].kejianList) {
  118. // 设置默认展开项
  119. this.list[0].open = true;
  120. this.list[0].jieList[0].open = true;
  121. const kejian = this.list[0].jieList[0].kejianList[0];
  122. }
  123. },
  124. init() {
  125. kechengApi.getKechengGlStart({
  126. kcId: this.kcId
  127. }).then(res => {
  128. const {
  129. userCount,
  130. period,
  131. name,
  132. kejianUserVo,
  133. intro,
  134. kechengFlag,
  135. operId,
  136. zyName,
  137. zyLevelName,
  138. } = res.data;
  139. this.userCount = userCount;
  140. this.period = formatSecondsToCnhms(period,true);
  141. this.name = name;
  142. this.zyName = zyName;
  143. this.zyLevelName = zyLevelName;
  144. this.kechengFlag = kechengFlag;
  145. this.formatData(kejianUserVo.zhangList)
  146. this.list = kejianUserVo.zhangList;
  147. this.intro = intro;
  148. this.operId = operId;
  149. this.initFirstVideo();
  150. })
  151. }
  152. }
  153. }
  154. </script>
  155. <style>
  156. </style>