lookShipin.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <template>
  2. <view class="ezy-ksp-page">
  3. <view class="icon-title-navBar-box">
  4. <view @click="goUpPage" class="nav-bar-icon"></view>
  5. <text class="nav-bar-title">{{jieInfo.jieIntro}}</text>
  6. </view>
  7. <view class="ksp-body">
  8. <view>
  9. <view @click="handleSelectHexinti">核心基础题</view>
  10. <view @click="handleSelectNengliTishengti">能力提升题</view>
  11. </view>
  12. <!-- 核心基础题 -->
  13. <videoPlayVue ref="c1" v-show="showA" :key="1" :videoId1="videoId" :progressMarkers1="progressMarkers"
  14. :playAuth1="playAuth" :hideFlag1="hideFlag" :seek-time1="seekTime" class="ksp-video-box"
  15. @playEnd="playEnd"></videoPlayVue>
  16. <view class="ksp-item-list" v-show="showA">
  17. <view class="item-title">核心基础题</view>
  18. <view class="ksp-item-box" v-for="(item,index) in jieInfo.jiedianList1" :key="index"
  19. >
  20. <icon class="ksp-icon"></icon>
  21. <view>
  22. <view class="ksp-title">{{item.name}}</view>
  23. <view @click="markersClick(item)">视频讲解</view>
  24. <!-- <view class="ksp-title">课程位置:{{item.time1}}-{{item.time2}}</view> -->
  25. <rich-text :nodes="item.title"></rich-text>
  26. </view>
  27. </view>
  28. </view>
  29. <!-- 能力提升题 -->
  30. <template v-if="!!videoId2">
  31. <videoPlayVue2 ref="c2" v-show="showB" :key="2" :videoId1="videoId2"
  32. :progressMarkers1="progressMarkers2" :playAuth1="playAuth2" :hideFlag1="hideFlag2"
  33. :seek-time1="seekTime2" class="ksp-video-box" @playEnd="playEnd"></videoPlayVue2>
  34. <view class="ksp-item-list" v-show="showB">
  35. <view class="item-title">能力提升题</view>
  36. <view class="ksp-item-box" v-for="(item,index) in jieInfo.jiedianList2" :key="index"
  37. >
  38. <icon class="ksp-icon"></icon>
  39. <view>
  40. <view class="ksp-title">{{item.name}}</view>
  41. <view @click="markersClick2(item)">视频讲解</view>
  42. <!-- <view class="ksp-title">课程位置:{{item.time1}}-{{item.time2}}</view> -->
  43. <rich-text :nodes="item.title"></rich-text>
  44. </view>
  45. </view>
  46. </view>
  47. </template>
  48. </view>
  49. <!-- 弹窗 -->
  50. <tishiDlVue ref="popupRef"></tishiDlVue>
  51. </view>
  52. </template>
  53. <script>
  54. import {
  55. ref
  56. } from 'vue';
  57. import {
  58. onLoad,
  59. onReady
  60. } from '@dcloudio/uni-app';
  61. import {
  62. getVideoAuth,
  63. getVideoAuthYk,
  64. videoWancheng
  65. } from "@/api/shipin.js"
  66. import {
  67. toast,
  68. convertTimeToSeconds
  69. } from "@/utils/common";
  70. import cacheManager from "@/utils/cacheManager.js";
  71. import * as httpApi from "@/api/chanpinShuxue.js";
  72. import tishiDlVue from './components/tishiDl.vue';
  73. import videoPlayVue from './components/videoPlay.vue';
  74. import videoPlayVue2 from './components/videoPlay2.vue';
  75. export default {
  76. data() {
  77. return {
  78. danyuanId: null,
  79. jieInfo: {
  80. cover1: '',
  81. cover2: '',
  82. jieId: '',
  83. jieIntro: '',
  84. jieName: '',
  85. jiedianList1: [],
  86. jiedianList2: [],
  87. type: '',
  88. video1: '',
  89. video2: '',
  90. },
  91. jieId: '',
  92. shipinTitle: '',
  93. pageData: null, //上个页面获取的视频参数(视频id)
  94. playAuth: "", //播放凭证
  95. progressMarkers: [],
  96. hideFlag: 'show',
  97. videoId: "", //阿里云视频id
  98. seekTime: '',
  99. showA: true,
  100. pageData2: null, //上个页面获取的视频参数(视频id)
  101. playAuth2: "", //播放凭证
  102. progressMarkers2: [],
  103. hideFlag2: 'show',
  104. videoId2: "", //阿里云视频id
  105. seekTime2: '',
  106. showB: false,
  107. }
  108. },
  109. components: {
  110. tishiDlVue,
  111. videoPlayVue,
  112. videoPlayVue2
  113. },
  114. onLoad(options) {
  115. this.init(options)
  116. },
  117. onHide() {
  118. this.hideFlag = 'hide'
  119. this.hideFlag2 = 'hide'
  120. },
  121. onUnload() {
  122. this.hideFlag = 'hide'
  123. this.hideFlag2 = 'hide'
  124. },
  125. methods: {
  126. handleSelectHexinti() {
  127. if (this.showA) return;
  128. this.showB = false;
  129. this.showA = true;
  130. this.$refs.c1.handleStop()
  131. this.$refs.c2.handleStop()
  132. },
  133. handleSelectNengliTishengti() {
  134. if (this.showB) return;
  135. this.showB = true;
  136. this.showA = false;
  137. this.$refs.c1.handleStop()
  138. this.$refs.c2.handleStop()
  139. },
  140. // 当前节学习完成
  141. saveJieWancheng() {
  142. httpApi.getShuxueChanpinWancheng({
  143. jieId: this.jieInfo.jieId
  144. }).then(res => {
  145. if (res.data) {
  146. // 更新单员状态
  147. cacheManager.updateShuxueWanchengStatus(this.jieInfo.jieId)
  148. // 学习完成提示弹窗
  149. this.$refs.popupRef.open();
  150. }
  151. })
  152. },
  153. // 当前节学习开始
  154. saveJinduStart() {
  155. httpApi.getShuxueChanpinSave({
  156. jieId: this.jieInfo.jieId
  157. })
  158. },
  159. courseBjFun() {
  160. return 'static/images/course/couse-shuxue-bj.png'
  161. },
  162. courseIconFun() {
  163. return 'static/images/course/shuxue-icon.png'
  164. },
  165. getDataInfo() {
  166. httpApi.getShuxueChanpinJieInfo({
  167. jieId: this.jieId
  168. }).then(res => {
  169. // 时间节点转换
  170. res.data.jiedianList1.forEach(item => item.offset = convertTimeToSeconds(item.time1))
  171. res.data.jiedianList2.forEach(item => item.offset = convertTimeToSeconds(item.time1))
  172. // 重新赋值
  173. Object.assign(this.jieInfo, res.data)
  174. // 触发当前节学习进度
  175. // this.saveJinduStart();
  176. // 针对视频进行赋值
  177. this.videoId = this.jieInfo.video1;
  178. this.videoId2 = this.jieInfo.video2;
  179. // 针对节点赋值
  180. this.progressMarkers = this.jieInfo.jiedianList1;
  181. this.progressMarkers = this.jieInfo.jiedianList2;
  182. // 执行方法
  183. this.getLive(); //获取播放凭证
  184. this.getLive2();
  185. })
  186. },
  187. init(options) {
  188. this.jieId = options.jieId;
  189. this.getDataInfo()
  190. },
  191. playEnd(data) {
  192. // #ifdef APP-PLUS
  193. plus.screen.lockOrientation('portrait-primary');
  194. // #endif
  195. this.saveJieWancheng();
  196. },
  197. getLive() {
  198. if (!this.videoId) {
  199. toast("video缺失!")
  200. return false
  201. }
  202. let req = {
  203. videoId: this.videoId
  204. }
  205. getVideoAuth(req).then(res => {
  206. this.playAuth = res.data
  207. })
  208. },
  209. getLive2() {
  210. if (!this.videoId2) {
  211. toast("video缺失!")
  212. return false
  213. }
  214. let req = {
  215. videoId: this.videoId2
  216. }
  217. getVideoAuth(req).then(res => {
  218. this.playAuth2 = res.data
  219. })
  220. },
  221. markersClick(data) {
  222. this.showA = true;
  223. this.showB = false;
  224. this.$refs.c2.handleStop();
  225. this.seekTime = ""
  226. this.$nextTick(() => {
  227. this.seekTime = data.offset
  228. });
  229. },
  230. markersClick2(data) {
  231. this.showA = false;
  232. this.showB = true;
  233. this.$refs.c1.handleStop()
  234. this.seekTime2 = ""
  235. this.$nextTick(() => {
  236. this.seekTime2 = data.offset
  237. });
  238. },
  239. goUpPage() {
  240. uni.navigateBack()
  241. // uni.redirectTo({
  242. // url: "/pages/chanpinneirong/index"
  243. // })
  244. },
  245. },
  246. }
  247. </script>