lookShipin.vue 7.5 KB

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