lookShipin.vue 7.1 KB

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