study.vue 5.1 KB

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