lookShipin.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  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" :class="{active: this.showA}" @click="handleSelectHexinti">核心基础题</view>
  10. <view class="tab-item" :class="{active: this.showB}" @click="handleSelectNengliTishengti">能力提升题</view>
  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. <view class="list-btn" @click="markersClick(item)"></view>
  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. <view class="list-btn" @click="markersClick2(item)"></view>
  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. export default {
  77. data() {
  78. return {
  79. danyuanId: null,
  80. jieInfo: {
  81. cover1: '',
  82. cover2: '',
  83. jieId: '',
  84. jieIntro: '',
  85. jieName: '',
  86. jiedianList1: [],
  87. jiedianList2: [],
  88. type: '',
  89. video1: '',
  90. video2: '',
  91. },
  92. jieId: '',
  93. shipinTitle: '',
  94. pageData: null, //上个页面获取的视频参数(视频id)
  95. playAuth: "", //播放凭证
  96. progressMarkers: [],
  97. hideFlag: 'show',
  98. videoId: "", //阿里云视频id
  99. seekTime: '',
  100. showA: true,
  101. pageData2: null, //上个页面获取的视频参数(视频id)
  102. playAuth2: "", //播放凭证
  103. progressMarkers2: [],
  104. hideFlag2: 'show',
  105. videoId2: "", //阿里云视频id
  106. seekTime2: '',
  107. showB: false,
  108. }
  109. },
  110. components: {
  111. tishiDlVue,
  112. videoPlayVue,
  113. videoPlayVue2
  114. },
  115. onLoad(options) {
  116. this.init(options)
  117. },
  118. onHide() {
  119. this.hideFlag = 'hide'
  120. this.hideFlag2 = 'hide'
  121. },
  122. onUnload() {
  123. this.hideFlag = 'hide'
  124. this.hideFlag2 = 'hide'
  125. },
  126. methods: {
  127. handleSelectHexinti() {
  128. if (this.showA) return;
  129. this.showB = false;
  130. this.showA = true;
  131. this.$refs.c1 && this.$refs.c1.handleStop()
  132. this.$refs.c2 && this.$refs.c2.handleStop()
  133. },
  134. handleSelectNengliTishengti() {
  135. if (this.showB) return;
  136. this.showB = true;
  137. this.showA = false;
  138. this.$refs.c1 && this.$refs.c1.handleStop()
  139. this.$refs.c2 && this.$refs.c2.handleStop()
  140. },
  141. // 当前节学习完成
  142. saveJieWancheng() {
  143. httpApi.getShuxueChanpinWancheng({
  144. jieId: this.jieInfo.jieId
  145. }).then(res => {
  146. if (res.data) {
  147. // 更新单员状态
  148. cacheManager.updateShuxueWanchengStatus(this.jieInfo.jieId)
  149. // 学习完成提示弹窗
  150. this.$refs.popupRef.open();
  151. }
  152. })
  153. },
  154. // 当前节学习开始
  155. saveJinduStart() {
  156. httpApi.getShuxueChanpinSave({
  157. jieId: this.jieInfo.jieId
  158. })
  159. },
  160. courseBjFun() {
  161. return 'static/images/course/couse-shuxue-bj.png'
  162. },
  163. courseIconFun() {
  164. return 'static/images/course/shuxue-icon.png'
  165. },
  166. getDataInfo() {
  167. httpApi.getShuxueChanpinJieInfo({
  168. jieId: this.jieId
  169. }).then(res => {
  170. // 时间节点转换
  171. res.data.jiedianList1.forEach(item => item.offset = convertTimeToSeconds(item.time1))
  172. res.data.jiedianList2.forEach(item => item.offset = convertTimeToSeconds(item.time1))
  173. // 重新赋值
  174. Object.assign(this.jieInfo, res.data)
  175. // 触发当前节学习进度
  176. // this.saveJinduStart();
  177. // 针对视频进行赋值
  178. this.videoId = this.jieInfo.video1;
  179. this.videoId2 = this.jieInfo.video2;
  180. // 针对节点赋值
  181. this.progressMarkers = this.jieInfo.jiedianList1;
  182. this.progressMarkers = this.jieInfo.jiedianList2;
  183. // 执行方法
  184. this.getLive(); //获取播放凭证
  185. this.getLive2();
  186. })
  187. },
  188. init(options) {
  189. this.jieId = options.jieId;
  190. this.getDataInfo()
  191. },
  192. playEnd(data) {
  193. // #ifdef APP-PLUS
  194. plus.screen.lockOrientation('portrait-primary');
  195. // #endif
  196. this.saveJieWancheng();
  197. },
  198. getLive() {
  199. if (!this.videoId) {
  200. toast("video缺失!")
  201. return false
  202. }
  203. let req = {
  204. videoId: this.videoId
  205. }
  206. getVideoAuth(req).then(res => {
  207. this.playAuth = res.data
  208. })
  209. },
  210. getLive2() {
  211. if (!this.videoId2) {
  212. toast("video缺失!")
  213. return false
  214. }
  215. let req = {
  216. videoId: this.videoId2
  217. }
  218. getVideoAuth(req).then(res => {
  219. this.playAuth2 = res.data
  220. })
  221. },
  222. markersClick(data) {
  223. this.showA = true;
  224. this.showB = false;
  225. this.$refs.c2 && this.$refs.c2.handleStop();
  226. this.seekTime = ""
  227. this.$nextTick(() => {
  228. this.seekTime = data.offset
  229. });
  230. },
  231. markersClick2(data) {
  232. this.showA = false;
  233. this.showB = true;
  234. this.$refs.c1 && this.$refs.c1.handleStop()
  235. this.seekTime2 = ""
  236. this.$nextTick(() => {
  237. this.seekTime2 = data.offset
  238. });
  239. },
  240. goUpPage() {
  241. uni.switchTab({
  242. url: "/pages/chanpinneirong/index"
  243. })
  244. // uni.navigateBack()
  245. // uni.redirectTo({
  246. // url: "/pages/chanpinneirong/index"
  247. // })
  248. },
  249. },
  250. }
  251. </script>