help.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. <template>
  2. <view class="page_help">
  3. <view class="help_item" v-for="(item,index) in helpList" :key="index">
  4. <view class="item_title">
  5. {{item.title}}
  6. </view>
  7. <view class="item_list">
  8. <view v-for="(video,vIndex) in item.list" :key="vIndex" class="video_item">
  9. <view class="image_item" @click="playVideo(video.url)">
  10. <view class="video_title_span">{{video.title}}</view>
  11. </view>
  12. <!-- <video
  13. :id="'video_' + index + '_' + vIndex"
  14. poster="@/static/image/bg/video_bg.png"
  15. :src="video.url"
  16. class="image_item"
  17. enable-fullscreen
  18. controls="false"
  19. show-center-play-btn="false"
  20. show-play-btn="false"
  21. @ended="onEnded('video_' + index + '_' + vIndex)"
  22. @click="togglePlay(video.url, 'video_' + index + '_' + vIndex)"
  23. ></video> -->
  24. <view class="video_title">
  25. {{video.title}}
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. <view class="video_play_content" v-if="showVideoPlayer">
  31. <video
  32. id="video_paly"
  33. poster="@/static/image/bg/video_bg.png"
  34. :src="currentVideoUrl"
  35. class="image_item"
  36. enable-fullscreen
  37. controls="false"
  38. show-center-play-btn="false"
  39. show-play-btn="false"
  40. @fullscreenchange="onFullscreenChange"
  41. @click="togglePlay()"
  42. ></video>
  43. </view>
  44. </view>
  45. </template>
  46. <script setup>
  47. import { ref, onMounted } from 'vue';
  48. import { useStore } from 'vuex';
  49. const store = useStore();
  50. const currentVideoUrl=ref('');//当前视频的播放地址
  51. let videoContext = null;
  52. const showVideoPlayer=ref(false);//是否显示视频播放器
  53. const helpList=ref([
  54. {
  55. title:'在线制卡',
  56. list:[
  57. {
  58. title:'在线制卡',
  59. img:'',
  60. url:'https://videos.k12100.net/在线制卡.mp4',
  61. },
  62. ],
  63. },
  64. {
  65. title:'我的考试',
  66. list:[
  67. {
  68. title:'制作模板',
  69. img:'',
  70. url:'https://videos.k12100.net/1.制作模板.mp4',
  71. },
  72. {
  73. title:'画批阅块',
  74. img:'',
  75. url:'https://videos.k12100.net/2.画批阅块.mp4',
  76. },
  77. {
  78. title:'设给分点',
  79. img:' ',
  80. url:'https://videos.k12100.net/3.设给分点.mp4',
  81. },
  82. {
  83. title:'录入标答',
  84. img:' ',
  85. url:'https://videos.k12100.net/4.录入标答.mp4',
  86. },
  87. {
  88. title:'扫描学生',
  89. img:' ',
  90. url:'https://videos.k12100.net/5.扫描学生.mp4',
  91. },
  92. {
  93. title:'分配任务',
  94. img:' ',
  95. url:'https://videos.k12100.net/6.分配任务.mp4',
  96. },
  97. {
  98. title:'阅卷进度',
  99. img:' ',
  100. url:'https://videos.k12100.net/7.阅卷进度.mp4',
  101. },
  102. {
  103. title:'发布成绩',
  104. img:' ',
  105. url:'https://videos.k12100.net/8.发布成绩.mp4',
  106. },
  107. ],
  108. },
  109. {
  110. title:'在线阅卷',
  111. list:[
  112. {
  113. title:'批阅试卷',
  114. img:' ',
  115. url:'https://videos.k12100.net/批阅试卷.mp4',
  116. },
  117. {
  118. title:'知识点录入',
  119. img:' ',
  120. url:'https://videos.k12100.net/知识点录入.mp4',
  121. },
  122. ],
  123. },
  124. {
  125. title:'成绩纠错',
  126. list:[
  127. {
  128. title:'成绩纠错',
  129. img:' ',
  130. url:'https://videos.k12100.net/成绩纠错.mp4',
  131. },
  132. ],
  133. },
  134. ]);
  135. onMounted(() => {
  136. });
  137. const playVideo=(url)=>{
  138. console.log("打印当前的播放地址",url);
  139. // 暂停之前播放的视频
  140. if (videoContext) {
  141. videoContext.pause();
  142. }
  143. showVideoPlayer.value=true;//显示视频播放器
  144. currentVideoUrl.value=url;//设置视频地址
  145. setTimeout(() => {
  146. // 3. 获取 video_paly 的视频上下文
  147. const context = uni.createVideoContext('video_paly');
  148. console.log("打印视频上下文",context);
  149. if (context) {
  150. // 4. 播放视频
  151. context.play();
  152. // 5. 请求全屏
  153. context.requestFullScreen();
  154. }
  155. }, 300);
  156. };
  157. // 监听全屏变化事件
  158. const onFullscreenChange = (e) => {
  159. // e.detail.fullScreen 为 false 表示退出全屏
  160. if (!e.detail.fullScreen) {
  161. // 暂停视频
  162. console.log("退出全屏,清空播放并暂停");
  163. if (videoContext) {
  164. videoContext.pause();
  165. }
  166. // 清空视频地址
  167. currentVideoUrl.value = '';
  168. // 清空视频上下文引用
  169. videoContext = null;
  170. // 隐藏视频播放器
  171. showVideoPlayer.value = false;
  172. }
  173. };
  174. </script>
  175. <style>
  176. .page_help
  177. {
  178. width: 100%;
  179. height: 100%;
  180. background-color: #F8F9FD;
  181. overflow-y: auto;
  182. }
  183. .help_item
  184. {
  185. width: 100%;
  186. height: auto;
  187. }
  188. .item_title
  189. {
  190. font-weight: 500;
  191. font-size: 32rpx;
  192. color: #333333;
  193. line-height: 48rpx;
  194. margin-top: 20rpx;
  195. text-indent: 24rpx;
  196. }
  197. .item_list
  198. {
  199. width: calc(100% - 22rpx);
  200. margin-left: 22rpx;
  201. height: auto;
  202. display: flex;
  203. justify-content: flex-start;
  204. gap: 22rpx;
  205. flex-wrap: wrap;
  206. margin-top: 10rpx;
  207. margin-bottom: 20rpx;
  208. }
  209. .video_item
  210. {
  211. width: calc(50% - 22rpx);
  212. height: auto;
  213. border-radius: 12rpx 12rpx 12rpx 12rpx;
  214. }
  215. .image_item
  216. {
  217. width: 100%;
  218. min-height: 190rpx;
  219. height: auto;
  220. background-image: url('@/static/image/bg/video_bg.png');
  221. background-size: cover;
  222. background-repeat: no-repeat;
  223. background-position: center;
  224. border-radius: 12rpx 12rpx 12rpx 12rpx;
  225. cursor: pointer;
  226. position: relative;
  227. }
  228. .video_title
  229. {
  230. font-weight: 400;
  231. font-size: 28rpx;
  232. color: #333333;
  233. line-height: 50rpx;
  234. height: 50rpx;
  235. }
  236. .video_title_span
  237. {
  238. position: absolute;
  239. font-weight: 400;
  240. font-size: 28rpx;
  241. color: #333333;
  242. top:50rpx;
  243. left: 20rpx;
  244. }
  245. /* 播放按钮图标 */
  246. .play_icon {
  247. font-size: 60rpx;
  248. color: #fff;
  249. text-shadow: 0 0 10rpx rgba(0,0,0,0.5);
  250. }
  251. .play_overlay {
  252. position: absolute;
  253. top: 0;
  254. left: 0;
  255. width: 100%;
  256. height: 100%;
  257. display: flex;
  258. justify-content: center;
  259. align-items: center;
  260. background: rgba(0, 0, 0, 0.3);
  261. border-radius: 12rpx 12rpx 12rpx 12rpx;
  262. z-index: 10;
  263. }
  264. .video_play_content
  265. {
  266. }
  267. </style>