guide.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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. adPlace: 20,
  54. os: 1
  55. }
  56. const res = await this.$axios.$post('/public/v5/advertising/getAdInfoByAdPlace', data);
  57. this.topADList = res.data;
  58. },
  59. play(item, ele) {
  60. const elVideo = document.getElementById('el-video-' + ele.id)
  61. if (elVideo.requestFullscreen) {
  62. elVideo.requestFullscreen()
  63. elVideo.play()
  64. } else if (elVideo.mozRequestFullscreen) {
  65. elVideo.mozRequestFullscreen()
  66. elVideo.play()
  67. } else if (elVideo.msRequestFullscreen) {
  68. elVideo.msRequestFullscreen()
  69. elVideo.play()
  70. } else if (elVideo.webkitRequestFullscreen) {
  71. elVideo.webkitRequestFullscreen()
  72. elVideo.play()
  73. } else {
  74. elVideo.requestFullscreen()
  75. elVideo.play()
  76. }
  77. elVideo.addEventListener("webkitfullscreenchange", function (e) {
  78. if (!document.webkitIsFullScreen) {// 退出全屏暂停视频
  79. elVideo.pause();
  80. };
  81. }, false);
  82. elVideo.addEventListener('ended', function () {
  83. document.webkitCancelFullScreen(); // 播放完毕自动退出全屏
  84. }, false);
  85. this.submit(item, ele, 1)
  86. },
  87. playAd(item, ele) {
  88. const elVideo = document.getElementById('ad')
  89. if (elVideo.requestFullscreen) {
  90. elVideo.requestFullscreen()
  91. elVideo.play()
  92. } else if (elVideo.mozRequestFullscreen) {
  93. elVideo.mozRequestFullscreen()
  94. elVideo.play()
  95. } else if (elVideo.webkitRequestFullscreen) {
  96. elVideo.webkitRequestFullscreen()
  97. elVideo.play()
  98. }
  99. this.submit(item, ele, 2)
  100. },
  101. submit(item, ele, flag) {
  102. const data = flag === 1 ? { id: ele.id, plateId: item.plateId, type: flag, videoId: ele.id } : { type: 2 }
  103. this.$axios.$post('/activity/videoCourse/statistics/save', data, { headers: { Authorization: this.token } });
  104. }
  105. }
  106. }
  107. </script>
  108. <style lang="scss" scoped>
  109. .video-player--is-cssfullscreen {
  110. position: fixed !important;
  111. left: 0 !important;
  112. top: 0 !important;
  113. width: 100% !important;
  114. height: 100% !important;
  115. z-index: 999;
  116. }
  117. .video-card {
  118. width: 165px;
  119. height: 148px;
  120. border-radius: 5px;
  121. position: relative;
  122. & .video-card-title {
  123. width: 100%;
  124. height: 45px;
  125. line-height: 45px;
  126. text-align: center;
  127. font-size: 14px;
  128. font-weight: 500;
  129. color: #1c1c1e;
  130. background: #fff;
  131. position: absolute;
  132. left: 0;
  133. bottom: 0;
  134. border-radius: 0 0 9px 9px;
  135. }
  136. }
  137. .bg2C2C2D {
  138. background-color: #1c1c1e;
  139. min-height: 100vh;
  140. overflow: hidden;
  141. }
  142. .w345h120 {
  143. width: 345px;
  144. height: 120px;
  145. margin: 15px;
  146. }
  147. .fs16 {
  148. font-weight: 500;
  149. color: #ffffff;
  150. font-size: 16px;
  151. margin-left: 15px;
  152. display: flex;
  153. align-items: center;
  154. }
  155. .jcjc-list {
  156. padding: 0 15px;
  157. overflow-x: scroll;
  158. overflow-y: hidden;
  159. display: flex;
  160. margin: 15px 0;
  161. .video-card {
  162. margin-right: 10px;
  163. &:last-child {
  164. margin-right: 0;
  165. }
  166. }
  167. }
  168. .fs16::before {
  169. content: '';
  170. display: inline-block;
  171. width: 6px;
  172. height: 14px;
  173. background: #3b7fff;
  174. border-radius: 3px 3px 3px 3px;
  175. opacity: 1;
  176. margin-right: 6px;
  177. }
  178. .w144h140 {
  179. width: 144px;
  180. height: 140px;
  181. margin-right: 10px;
  182. }
  183. .w144h140:last-child {
  184. margin-right: 0;
  185. }
  186. .jjjc-list {
  187. display: flex;
  188. flex-flow: wrap;
  189. justify-content: space-between;
  190. padding: 15px;
  191. }
  192. .w165h148 {
  193. width: 165px;
  194. height: 148px;
  195. object-fit: contain;
  196. margin-bottom: 15px;
  197. border-radius: 10px;
  198. }
  199. .return {
  200. width: 42px;
  201. height: 42px;
  202. margin-left: 20px;
  203. margin-bottom: 40px;
  204. &.out {
  205. border-radius: 50%;
  206. padding: 1px;
  207. background: linear-gradient(
  208. 46deg,
  209. rgba(48, 49, 53, 1),
  210. rgba(113, 116, 127, 1)
  211. );
  212. box-shadow: 0px 9px 17px 0px rgba(0, 0, 0, 0.5);
  213. }
  214. .in {
  215. width: 40px;
  216. height: 40px;
  217. border-radius: 50%;
  218. background: linear-gradient(180deg, #232427 0%, #4b4c52 100%);
  219. opacity: 1;
  220. text-align: center;
  221. line-height: 40px;
  222. }
  223. img {
  224. width: 16px;
  225. height: 16px;
  226. }
  227. }
  228. </style>