lookShipin.vue 6.6 KB

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