study.vue 5.4 KB

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