guide-pc.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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(item, ele)">
  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. } else {
  70. elVideo.requestFullscreen()
  71. elVideo.play()
  72. }
  73. this.submit(item, ele, 1)
  74. },
  75. playAd(item, ele) {
  76. const elVideo = document.getElementById('ad')
  77. if (elVideo.requestFullscreen) {
  78. elVideo.requestFullscreen()
  79. elVideo.play()
  80. } else if (elVideo.mozRequestFullscreen) {
  81. elVideo.mozRequestFullscreen()
  82. elVideo.play()
  83. } else if (elVideo.webkitRequestFullscreen) {
  84. elVideo.webkitRequestFullscreen()
  85. elVideo.play()
  86. }
  87. this.submit(item, ele, 2)
  88. },
  89. submit(item, ele, flag) {
  90. const data = flag === 1 ? { id: ele.id, plateId: item.plateId, type: flag, videoId: ele.id } : { type: 2 }
  91. this.$axios.$post('/activity/v5/advertising/getAdInfoByAdPlace', data, {headers: {Authorization: this.token}});
  92. }
  93. }
  94. }
  95. </script>
  96. <style lang="scss">
  97. @media (min-width: 0px) {
  98. .bg-guide {
  99. & .v-tabs-bar {
  100. height: 42px !important;
  101. }
  102. }
  103. }
  104. </style>
  105. <style lang="scss" scoped>
  106. .bgFAFAFA {
  107. background: #FAFAFA;
  108. }
  109. @media (min-width: 0px) {
  110. .video-card {
  111. width: 165px;
  112. height: 148px;
  113. border-radius: 5px;
  114. position: relative;
  115. display: inline-block;
  116. margin-right: 30px;
  117. &:nth-of-type(4n+0){
  118. margin-right: 0px;
  119. }
  120. & .video-card-title {
  121. width: 100%;
  122. height: 45px;
  123. line-height: 45px;
  124. text-align: center;
  125. font-size: 14px;
  126. font-weight: 500;
  127. color: #1C1C1E;
  128. background: #fff;
  129. border-radius: 0 0 9px 9px;
  130. position: absolute;
  131. left: 0;
  132. bottom: 0;
  133. }
  134. }
  135. .bg-guide {
  136. min-height: 100vh;
  137. overflow: hidden;
  138. & .v-tab {
  139. font-size: 12px;
  140. min-width: 88px;
  141. }
  142. & .v-tabs-bar {
  143. height: 42px !important;
  144. }
  145. }
  146. .w345h120 {
  147. width: 345px;
  148. height: 120px;
  149. margin: 10px auto;
  150. display: block;
  151. background: #FAFAFA;
  152. }
  153. .w165h148 {
  154. width: 165px;
  155. height: 148px;
  156. margin-bottom: 10px;
  157. margin-right: 30px;
  158. border-radius: 10px;
  159. &:nth-of-type(4n+0){
  160. margin-right: 0px;
  161. }
  162. }
  163. }
  164. </style>