lookShipin.vue 6.7 KB

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