lookShipin.vue 7.2 KB

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