guide-pc.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <template>
  2. <div class="bg-guide">
  3. <video v-for="item in topADList" id="ad" :key="item.id" class="w345h120" :poster="item.imgUrls[0]" :src="item.videoUrl" @click="playAd()" />
  4. <v-tabs v-model="tab" color="#3666F2" background-color="transparent" style="height: 42px;">
  5. <v-tab v-for="item in videoList" :key="item.plateId" style="height: 42px;">{{item.plateName}}</v-tab>
  6. <v-tabs-items v-model="tab">
  7. <v-tab-item v-for="item in videoList" :key="item.plateId" style="padding: 10px;background: #FAFAFA;min-height: calc(100vh - 162px);">
  8. <div v-for="ele in item.videoCourseList" :key="ele.id" class="video-card" @click="play('el-video-' + ele.id)">
  9. <video :id="'el-video-' + ele.id" class="w165h148" preload="auto" :poster="videoURL(ele.coverImageKey)" :src="videoURL(ele.videoKey)" />
  10. <div class="video-card-title">{{ele.videoName}}</div>
  11. </div>
  12. </v-tab-item>
  13. </v-tabs-items>
  14. </v-tabs>
  15. </div>
  16. </template>
  17. <script>
  18. import { fileKeyToUrl } from '@/plugins/file-center.js';
  19. export default {
  20. name: 'GuidePc',
  21. auth: false,
  22. data() {
  23. return {
  24. tab: null,
  25. videoList: [],
  26. topADList: [],
  27. token: ''
  28. }
  29. },
  30. fetch() {
  31. this.token = this.$route.query.token;
  32. },
  33. computed: {
  34. videoURL() {
  35. return (key) => {
  36. return fileKeyToUrl(key)
  37. }
  38. }
  39. },
  40. created() {
  41. this.getActiveInfo()
  42. this.getAdInfoByAdPlace()
  43. },
  44. methods: {
  45. async getActiveInfo() {
  46. const res = await this.$axios.$get('/activity/videoCourse/client/list');
  47. this.videoList = res.data;
  48. },
  49. async getAdInfoByAdPlace() {
  50. const data = {
  51. id: 1,
  52. adPlace: 20,
  53. os: 1
  54. }
  55. const res = await this.$axios.$post('/public/v5/advertising/getAdInfoByAdPlace', data);
  56. this.topADList = res.data;
  57. },
  58. play(item, ele) {
  59. const elVideo = document.getElementById('el-video-' + ele.id)
  60. if (elVideo.requestFullscreen) {
  61. // elVideo.requestFullscreen()
  62. elVideo.play()
  63. } else if (elVideo.mozRequestFullscreen) {
  64. // elVideo.mozRequestFullscreen()
  65. elVideo.play()
  66. } else if (elVideo.webkitRequestFullscreen) {
  67. // elVideo.webkitRequestFullscreen()
  68. elVideo.play()
  69. }
  70. this.submit(item, ele, 1)
  71. },
  72. playAd(item, ele) {
  73. const elVideo = document.getElementById('ad')
  74. if (elVideo.requestFullscreen) {
  75. elVideo.requestFullscreen()
  76. elVideo.play()
  77. } else if (elVideo.mozRequestFullscreen) {
  78. elVideo.mozRequestFullscreen()
  79. elVideo.play()
  80. } else if (elVideo.webkitRequestFullscreen) {
  81. elVideo.webkitRequestFullscreen()
  82. elVideo.play()
  83. }
  84. this.submit(item, ele, 2)
  85. },
  86. submit(item, ele, flag) {
  87. const data = flag === 1 ? { id: ele.id, plateId: item.plateId, type: flag, videoId: ele.id } : { type: 2 }
  88. this.$axios.$post('/activity/v5/advertising/getAdInfoByAdPlace', data, {headers: {Authorization: this.token}});
  89. }
  90. }
  91. }
  92. </script>
  93. <style lang="scss">
  94. @media (min-width: 0px) {
  95. .bg-guide {
  96. & .v-tabs-bar {
  97. height: 42px !important;
  98. }
  99. }
  100. }
  101. </style>
  102. <style lang="scss" scoped>
  103. .bgFAFAFA {
  104. background: #FAFAFA;
  105. }
  106. @media (min-width: 0px) {
  107. .video-card {
  108. width: 165px;
  109. height: 148px;
  110. border-radius: 5px;
  111. position: relative;
  112. display: inline-block;
  113. margin-right: 30px;
  114. &:nth-of-type(4n+0){
  115. margin-right: 0px;
  116. }
  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. border-radius: 0 0 9px 9px;
  127. position: absolute;
  128. left: 0;
  129. bottom: 0;
  130. }
  131. }
  132. .bg-guide {
  133. min-height: 100vh;
  134. overflow: hidden;
  135. & .v-tab {
  136. font-size: 12px;
  137. min-width: 88px;
  138. }
  139. & .v-tabs-bar {
  140. height: 42px !important;
  141. }
  142. }
  143. .w345h120 {
  144. width: 345px;
  145. height: 120px;
  146. margin: 10px auto;
  147. display: block;
  148. background: #FAFAFA;
  149. }
  150. .w165h148 {
  151. width: 165px;
  152. height: 148px;
  153. margin-bottom: 10px;
  154. margin-right: 30px;
  155. border-radius: 10px;
  156. &:nth-of-type(4n+0){
  157. margin-right: 0px;
  158. }
  159. }
  160. }
  161. </style>