lookShipin.vue 6.4 KB

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