lookShipin.vue 7.3 KB

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