guide.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <template>
  2. <div class="bg2C2C2D">
  3. <video v-for="item in topADList" id="ad" :key="item.id" class="w345h120" :poster="item.imgUrls[0]" :src="item.videoUrl" @click="playAd()" />
  4. <div v-for="item in videoList" :key="item.plateId">
  5. <div class="fs16">{{item.plateName}}</div>
  6. <div :class="item.displayMode === 1 ? 'jjjc-list' : 'jcjc-list'">
  7. <div v-for="ele in item.videoCourseList" :key="ele.id" class="video-card">
  8. <video :id="'el-video-' + ele.id" class="w165h148" :x5-video-player-fullscreen="true" x5-video-player-type="h5" style="object-fit:fill" x5-video-orientation="landscape|portrait" preload="auto" :poster="videoURL(ele.coverImageKey)" :src="videoURL(ele.videoKey)" @click="play(item, ele)" />
  9. <div class="video-card-title">{{ele.videoName}}</div>
  10. </div>
  11. </div>
  12. </div>
  13. <!-- <div class="return out"><div class="in"><img src="~/assets/image/activity/invite-user/guide/left.png" /></div></div> -->
  14. </div>
  15. </template>
  16. <script>
  17. import { fileKeyToUrl } from '@/plugins/file-center.js';
  18. export default {
  19. name: 'Guide',
  20. auth: false,
  21. data() {
  22. return {
  23. videoList: [],
  24. topADList: [],
  25. token: ''
  26. }
  27. },
  28. async fetch() {
  29. if (this.$userAgent.isAndroid) {
  30. this.token = await window.native.getToken();
  31. } else {
  32. this.token = this.$route.query.token;
  33. }
  34. },
  35. computed: {
  36. videoURL() {
  37. return (key) => {
  38. return fileKeyToUrl(key)
  39. }
  40. }
  41. },
  42. created() {
  43. this.getActiveInfo()
  44. this.getAdInfoByAdPlace()
  45. },
  46. methods: {
  47. async getActiveInfo() {
  48. const res = await this.$axios.$get('/activity/videoCourse/client/list');
  49. this.videoList = res.data;
  50. },
  51. async getAdInfoByAdPlace() {
  52. const data = {
  53. id: 1,
  54. adPlace: 20,
  55. os: 1
  56. }
  57. const res = await this.$axios.$post('/public/v5/advertising/getAdInfoByAdPlace', data);
  58. this.topADList = res.data;
  59. },
  60. // play(item, ele) {
  61. // const elVideo = document.getElementById('el-video-' + ele.id)
  62. // if (elVideo.requestFullscreen) {
  63. // elVideo.requestFullscreen()
  64. // elVideo.play()
  65. // } else if (elVideo.mozRequestFullscreen) {
  66. // elVideo.mozRequestFullscreen()
  67. // elVideo.play()
  68. // } else if (elVideo.msRequestFullscreen) {
  69. // elVideo.msRequestFullscreen()
  70. // elVideo.play()
  71. // } else if (elVideo.webkitRequestFullscreen) {
  72. // elVideo.webkitRequestFullscreen()
  73. // elVideo.play()
  74. // } else {
  75. // elVideo.requestFullscreen()
  76. // elVideo.play()
  77. // }
  78. // elVideo.addEventListener("webkitfullscreenchange", function (e) {
  79. // if (!document.webkitIsFullScreen) {// 退出全屏暂停视频
  80. // elVideo.pause();
  81. // };
  82. // }, false);
  83. // elVideo.addEventListener('ended', function () {
  84. // document.webkitCancelFullScreen(); // 播放完毕自动退出全屏
  85. // }, false);
  86. // this.submit(item, ele, 1)
  87. // },
  88. fullscreen(elem) {
  89. const prefix = 'webkit';
  90. if (elem[prefix + 'EnterFullScreen']) {
  91. return prefix + 'EnterFullScreen';
  92. } else if (elem[prefix + 'RequestFullScreen']) {
  93. return prefix + 'RequestFullScreen';
  94. };
  95. return false;
  96. },
  97. play(item, ele) {
  98. // const ua = navigator.userAgent.toLowerCase();
  99. // const Android = String(ua.match(/android/i)) == "android";
  100. // if(!Android) return;//非android系统不使用;
  101. const video = document.getElementById('el-video-' + ele.id);
  102. const doc = document;
  103. const fullscreenvideo = this.fullscreen(doc.createElement("video"));
  104. // if (!fullscreen) {
  105. // alert("不支持全屏模式");
  106. // return;
  107. // }
  108. video.addEventListener("webkitfullscreenchange", function (e) {
  109. if (!doc.webkitIsFullScreen) {// 退出全屏暂停视频
  110. this.pause();
  111. // this.pause();
  112. };
  113. }, false);
  114. video.addEventListener("click", function () {
  115. this.play();
  116. video[fullscreenvideo]();
  117. }, false);
  118. video.addEventListener('ended', function () {
  119. doc.webkitCancelFullScreen(); // 播放完毕自动退出全屏
  120. }, false);
  121. this.submit(item, ele, 1)
  122. },
  123. playAd(item, ele) {
  124. const elVideo = document.getElementById('ad')
  125. if (elVideo.requestFullscreen) {
  126. elVideo.requestFullscreen()
  127. elVideo.play()
  128. } else if (elVideo.mozRequestFullscreen) {
  129. elVideo.mozRequestFullscreen()
  130. elVideo.play()
  131. } else if (elVideo.webkitRequestFullscreen) {
  132. elVideo.webkitRequestFullscreen()
  133. elVideo.play()
  134. }
  135. this.submit(item, ele, 2)
  136. },
  137. submit(item, ele, flag) {
  138. const data = flag === 1 ? { id: ele.id, plateId: item.plateId, type: flag, videoId: ele.id } : { type: 2 }
  139. this.$axios.$post('/activity/videoCourse/statistics/save', data, { headers: { Authorization: this.token } });
  140. }
  141. }
  142. }
  143. </script>
  144. <style lang="scss" scoped>
  145. .video-card {
  146. width: 165px;
  147. height: 148px;
  148. border-radius: 5px;
  149. position: relative;
  150. & .video-card-title {
  151. width: 100%;
  152. height: 45px;
  153. line-height: 45px;
  154. text-align: center;
  155. font-size: 14px;
  156. font-weight: 500;
  157. color: #1c1c1e;
  158. background: #fff;
  159. position: absolute;
  160. left: 0;
  161. bottom: 0;
  162. border-radius: 0 0 9px 9px;
  163. }
  164. }
  165. .bg2C2C2D {
  166. background-color: #1c1c1e;
  167. min-height: 100vh;
  168. overflow: hidden;
  169. }
  170. .w345h120 {
  171. width: 345px;
  172. height: 120px;
  173. margin: 15px;
  174. }
  175. .fs16 {
  176. font-weight: 500;
  177. color: #ffffff;
  178. font-size: 16px;
  179. margin-left: 15px;
  180. display: flex;
  181. align-items: center;
  182. }
  183. .jcjc-list {
  184. padding: 0 15px;
  185. overflow-x: scroll;
  186. overflow-y: hidden;
  187. display: flex;
  188. margin: 15px 0;
  189. .video-card {
  190. margin-right: 10px;
  191. &:last-child {
  192. margin-right: 0;
  193. }
  194. }
  195. }
  196. .fs16::before {
  197. content: '';
  198. display: inline-block;
  199. width: 6px;
  200. height: 14px;
  201. background: #3b7fff;
  202. border-radius: 3px 3px 3px 3px;
  203. opacity: 1;
  204. margin-right: 6px;
  205. }
  206. .w144h140 {
  207. width: 144px;
  208. height: 140px;
  209. margin-right: 10px;
  210. }
  211. .w144h140:last-child {
  212. margin-right: 0;
  213. }
  214. .jjjc-list {
  215. display: flex;
  216. flex-flow: wrap;
  217. justify-content: space-between;
  218. padding: 15px;
  219. }
  220. .w165h148 {
  221. width: 165px;
  222. height: 148px;
  223. object-fit: contain;
  224. margin-bottom: 15px;
  225. border-radius: 10px;
  226. }
  227. .return {
  228. width: 42px;
  229. height: 42px;
  230. margin-left: 20px;
  231. margin-bottom: 40px;
  232. &.out {
  233. border-radius: 50%;
  234. padding: 1px;
  235. background: linear-gradient(
  236. 46deg,
  237. rgba(48, 49, 53, 1),
  238. rgba(113, 116, 127, 1)
  239. );
  240. box-shadow: 0px 9px 17px 0px rgba(0, 0, 0, 0.5);
  241. }
  242. .in {
  243. width: 40px;
  244. height: 40px;
  245. border-radius: 50%;
  246. background: linear-gradient(180deg, #232427 0%, #4b4c52 100%);
  247. opacity: 1;
  248. text-align: center;
  249. line-height: 40px;
  250. }
  251. img {
  252. width: 16px;
  253. height: 16px;
  254. }
  255. }
  256. </style>