guide-pc.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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;">
  8. <video v-for="ele in item.videoCourseList" :id="'el-video-' + ele.id" :key="ele.id" class="w165h148" preload="auto" :poster="videoURL(ele.coverImageKey)" :src="videoURL(ele.videoKey)" @click="play('el-video-' + ele.id)" />
  9. </v-tab-item>
  10. </v-tabs-items>
  11. </v-tabs>
  12. </div>
  13. </template>
  14. <script>
  15. import { fileKeyToUrl } from '@/plugins/file-center.js';
  16. export default {
  17. name: 'GuidePc',
  18. auth: false,
  19. data() {
  20. return {
  21. tab: null,
  22. videoList: [],
  23. topADList: [],
  24. token: ''
  25. }
  26. },
  27. fetch() {
  28. this.token = this.$route.query.token;
  29. },
  30. computed: {
  31. videoURL() {
  32. return (key) => {
  33. return fileKeyToUrl + key
  34. }
  35. }
  36. },
  37. created() {
  38. this.getActiveInfo()
  39. this.getAdInfoByAdPlace()
  40. },
  41. methods: {
  42. async getActiveInfo() {
  43. const res = await this.$axios.$get('/videoCourse/client/list');
  44. this.videoList = res.data;
  45. },
  46. async getAdInfoByAdPlace() {
  47. const data = {
  48. id: 1,
  49. adPlace: 511,
  50. os: 1
  51. }
  52. const res = await this.$axios.$post('/v5/advertising/getAdInfoByAdPlace', data);
  53. this.topADList = res.data;
  54. },
  55. play(item, ele) {
  56. const elVideo = document.getElementById('el-video-' + ele.id)
  57. if (elVideo.requestFullscreen) {
  58. elVideo.requestFullscreen()
  59. elVideo.play()
  60. } else if (elVideo.mozRequestFullscreen) {
  61. elVideo.mozRequestFullscreen()
  62. elVideo.play()
  63. } else if (elVideo.webkitRequestFullscreen) {
  64. elVideo.webkitRequestFullscreen()
  65. elVideo.play()
  66. }
  67. this.submit(item, ele, 1)
  68. },
  69. playAd(item, ele) {
  70. const elVideo = document.getElementById('ad')
  71. if (elVideo.requestFullscreen) {
  72. elVideo.requestFullscreen()
  73. elVideo.play()
  74. } else if (elVideo.mozRequestFullscreen) {
  75. elVideo.mozRequestFullscreen()
  76. elVideo.play()
  77. } else if (elVideo.webkitRequestFullscreen) {
  78. elVideo.webkitRequestFullscreen()
  79. elVideo.play()
  80. }
  81. this.submit(item, ele, 2)
  82. },
  83. submit(item, ele, flag) {
  84. const data = flag === 1 ? { id: ele.id, plateId: item.plateId, type: flag, videoId: ele.id } : { type: 2 }
  85. this.$axios.$post('/v5/advertising/getAdInfoByAdPlace', data, {headers: {Authorization: this.token}});
  86. }
  87. }
  88. }
  89. </script>
  90. <style lang="scss">
  91. @media (min-width: 0px) {
  92. .bg-guide {
  93. & .v-tabs-bar {
  94. height: 42px !important;
  95. }
  96. }
  97. }
  98. </style>
  99. <style lang="scss" scoped>
  100. @media (min-width: 0px) {
  101. .bg-guide {
  102. min-height: 100vh;
  103. overflow: hidden;
  104. & .v-tab {
  105. font-size: 12px;
  106. min-width: 88px;
  107. }
  108. & .v-tabs-bar {
  109. height: 42px !important;
  110. }
  111. }
  112. .w345h120 {
  113. width: 345px;
  114. height: 120px;
  115. margin: 10px auto;
  116. display: block;
  117. background: #FAFAFA;
  118. }
  119. .w165h148 {
  120. width: 165px;
  121. height: 148px;
  122. margin-bottom: 10px;
  123. margin-right: 30px;
  124. &:nth-of-type(4n+0){
  125. margin-right: 0px;
  126. }
  127. }
  128. }
  129. </style>