lookShipin.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  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. if (!this.jieInfo.jiedianList2 || this.jieInfo.jiedianList2.length === 0) {
  144. toast("本节无能力提升题");
  145. // tab回核心基础题状态
  146. this.showB = false;
  147. this.showA = true;
  148. return;
  149. }
  150. this.showB = true;
  151. this.showA = false;
  152. this.$refs.c1 && this.$refs.c1.handleStop()
  153. this.$refs.c2 && this.$refs.c2.handleStop()
  154. },
  155. // 当前节学习完成
  156. saveJieWancheng() {
  157. httpApi.getShuxueChanpinWancheng({
  158. jieId: this.jieInfo.jieId
  159. }).then(res => {
  160. if (res.data) {
  161. // 更新单员状态
  162. cacheManager.updateShuxueWanchengStatus(this.jieInfo.jieId)
  163. // 学习完成提示弹窗
  164. this.$refs.popupRef.open();
  165. }
  166. })
  167. },
  168. // 当前节学习开始
  169. saveJinduStart() {
  170. httpApi.getShuxueChanpinSave({
  171. jieId: this.jieInfo.jieId
  172. })
  173. },
  174. getDataInfo() {
  175. httpApi.getShuxueChanpinJieInfo({
  176. jieId: this.jieId
  177. }).then(res => {
  178. // 时间节点转换
  179. res.data.jiedianList1.forEach(item => item.offset = convertTimeToSeconds(item.time1))
  180. res.data.jiedianList2.forEach(item => item.offset = convertTimeToSeconds(item.time1))
  181. // 重新赋值
  182. Object.assign(this.jieInfo, res.data)
  183. // 触发当前节学习进度
  184. // this.saveJinduStart();
  185. // 针对视频进行赋值
  186. this.videoId = this.jieInfo.video1;
  187. this.videoId2 = this.jieInfo.video2;
  188. // 针对节点赋值
  189. this.progressMarkers = this.jieInfo.jiedianList1;
  190. this.progressMarkers = this.jieInfo.jiedianList2;
  191. // 执行方法
  192. this.getLive(); //获取播放凭证
  193. this.getLive2();
  194. })
  195. },
  196. init(options) {
  197. this.jieId = options.jieId;
  198. this.getDataInfo()
  199. },
  200. playEnd(data) {
  201. // #ifdef APP-PLUS
  202. plus.screen.lockOrientation('portrait-primary');
  203. // #endif
  204. this.saveJieWancheng();
  205. },
  206. playEnd2(data) {
  207. // #ifdef APP-PLUS
  208. plus.screen.lockOrientation('portrait-primary');
  209. // #endif
  210. },
  211. getLive() {
  212. if (!this.videoId) {
  213. toast("video缺失!")
  214. return false
  215. }
  216. let req = {
  217. videoId: this.videoId
  218. }
  219. getVideoAuth(req).then(res => {
  220. this.playAuth = res.data
  221. })
  222. },
  223. getLive2() {
  224. if (!this.videoId2) {
  225. // toast("video缺失!")
  226. return false
  227. }
  228. let req = {
  229. videoId: this.videoId2
  230. }
  231. getVideoAuth(req).then(res => {
  232. this.playAuth2 = res.data
  233. })
  234. },
  235. markersClick(data) {
  236. this.showA = true;
  237. this.showB = false;
  238. this.$refs.c2 && this.$refs.c2.handleStop();
  239. this.seekTime = ""
  240. this.$nextTick(() => {
  241. this.seekTime = data.offset
  242. });
  243. },
  244. markersClick2(data) {
  245. this.showA = false;
  246. this.showB = true;
  247. this.$refs.c1 && this.$refs.c1.handleStop()
  248. this.seekTime2 = ""
  249. this.$nextTick(() => {
  250. this.seekTime2 = data.offset
  251. });
  252. },
  253. goUpPage() {
  254. uni.switchTab({
  255. url: "/pages/chanpinneirong/index"
  256. })
  257. // uni.navigateBack()
  258. // uni.redirectTo({
  259. // url: "/pages/chanpinneirong/index"
  260. // })
  261. },
  262. },
  263. }
  264. </script>