guide.vue 5.7 KB

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