guide-pc.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <template>
  2. <div class="bg-guide">
  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. <v-tabs v-model="tab" color="#3666F2" background-color="transparent" style="height: 42px;">
  7. <v-tab v-for="item in videoList" :key="item.plateId" style="height: 42px;">{{item.plateName}}</v-tab>
  8. <v-tabs-items v-model="tab">
  9. <v-tab-item v-for="(item, index) in videoList" :key="item.plateId" style="padding: 10px;background: #FAFAFA;min-height: calc(100vh - 162px);">
  10. <div v-for="(ele, i) in item.videoCourseList" :key="ele.id" class="video-card">
  11. <!-- <video :id="'el-video-' + ele.id" class="w165h148" preload="auto" :poster="videoURL(ele.coverImageKey)" :src="videoURL(ele.videoKey)" /> -->
  12. <!-- <div class="video-card-title">{{ele.videoName}}</div> -->
  13. <img class="w165h148" :src="videoURL(ele.coverImageKey)" @click="play(item, ele, index, i)" />
  14. </div>
  15. </v-tab-item>
  16. </v-tabs-items>
  17. </v-tabs>
  18. <div v-show="showVideo" class="videobox">
  19. <div v-for="e in videoList" :key="e.plateId">
  20. <video
  21. v-for="element in e.videoCourseList" :id="'el-video-' + element.id" :key="element.id" :class="element.isShow ? '' : 'hide'" controls :src="videoURL(element.videoKey)" preload="auto" webkit-playsinline="true"
  22. playsinline="true" x-webkit-airplay="allow" x5-video-player-type="h5" x5-video-player-fullscreen="true" x5-video-orientation="portraint" style="object-fit:contain">
  23. </video>
  24. </div>
  25. </div>
  26. </div>
  27. </template>
  28. <script>
  29. import { fileKeyToUrl } from '@/plugins/file-center.js';
  30. export default {
  31. name: 'GuidePc',
  32. auth: false,
  33. data() {
  34. return {
  35. tab: null,
  36. videoList: [],
  37. topADList: [],
  38. token: '',
  39. showVideo: false
  40. }
  41. },
  42. fetch() {
  43. this.token = this.$route.query.token;
  44. },
  45. computed: {
  46. videoURL() {
  47. return (key) => {
  48. return fileKeyToUrl(key)
  49. }
  50. }
  51. },
  52. created() {
  53. this.getActiveInfo()
  54. this.getAdInfoByAdPlace()
  55. },
  56. methods: {
  57. async getActiveInfo() {
  58. const res = await this.$axios.$get('/activity/videoCourse/client/list');
  59. this.videoList = res.data;
  60. res.data.forEach(item => {
  61. item.videoCourseList.forEach(ele => {
  62. ele.isShow = false
  63. })
  64. });
  65. },
  66. async getAdInfoByAdPlace() {
  67. const data = {
  68. id: 1,
  69. adPlace: 20,
  70. os: 1
  71. }
  72. const res = await this.$axios.$post('/public/v5/advertising/getAdInfoByAdPlace', data);
  73. this.topADList = res.data;
  74. },
  75. play(item, ele, index, idx) {
  76. this.showVideo = true
  77. this.videoList[index].videoCourseList[idx].isShow = true
  78. const elVideo = document.getElementById('el-video-' + ele.id)
  79. elVideo.addEventListener("ended", () => {
  80. elVideo.pause();
  81. this.showVideo = false
  82. this.videoList[index].videoCourseList[idx].isShow = false
  83. });
  84. this.submit(item, ele, 1)
  85. },
  86. playAd(item) {
  87. this.submit(item, '', 2)
  88. if (item.actionType === '1' || item.actionType === '3' || item.actionType === '4' || item.actionType === '5' || item.actionType === '6') {
  89. window.open('', '_blank', item.clickUrl)
  90. }
  91. },
  92. submit(item, ele, flag) {
  93. const data = flag === 1 ? { id: ele.id, plateId: item.plateId, type: flag, videoId: ele.id } : { type: 2, adId: item.id, adName: item.title }
  94. this.$axios.$post('/activity/v5/advertising/getAdInfoByAdPlace', data, { headers: { Authorization: this.token } });
  95. }
  96. }
  97. }
  98. </script>
  99. <style lang="scss">
  100. @media (min-width: 0px) {
  101. .bg-guide {
  102. & .v-tabs-bar {
  103. height: 42px !important;
  104. }
  105. }
  106. }
  107. </style>
  108. <style lang="scss" scoped>
  109. .bgFAFAFA {
  110. background: #fafafa;
  111. }
  112. @media (min-width: 0px) {
  113. .hide {
  114. display: none;
  115. }
  116. .videobox {
  117. position: fixed;
  118. left: 0;
  119. top: 0;
  120. right: 0;
  121. bottom: 0;
  122. background: #1c1c1e;
  123. z-index: 2;
  124. width: 100vw;
  125. height: 100vh;
  126. overflow: hidden;
  127. }
  128. .videobox video {
  129. height: 100vh;
  130. width: 100vw;
  131. position: absolute;
  132. left: 0;
  133. top: 0;
  134. z-index: 3;
  135. }
  136. .video-card {
  137. width: 165px;
  138. height: 148px;
  139. border-radius: 5px;
  140. position: relative;
  141. display: inline-block;
  142. margin-right: 30px;
  143. z-index: 1;
  144. &:nth-of-type(4n + 0) {
  145. margin-right: 0px;
  146. }
  147. & .video-card-title {
  148. width: 100%;
  149. height: 45px;
  150. line-height: 45px;
  151. text-align: center;
  152. font-size: 14px;
  153. font-weight: 500;
  154. color: #1c1c1e;
  155. background: #fff;
  156. border-radius: 0 0 9px 9px;
  157. position: absolute;
  158. left: 0;
  159. bottom: 0;
  160. }
  161. }
  162. .bg-guide {
  163. min-height: 100vh;
  164. overflow: hidden;
  165. & .v-tab {
  166. font-size: 12px;
  167. min-width: 88px;
  168. }
  169. & .v-tabs-bar {
  170. height: 42px !important;
  171. }
  172. }
  173. .w345h120 {
  174. width: 345px;
  175. height: 120px;
  176. margin: 10px auto;
  177. display: block;
  178. background: #fafafa;
  179. border-radius: 5px;
  180. }
  181. .w165h148 {
  182. width: 165px;
  183. height: 148px;
  184. margin-bottom: 10px;
  185. margin-right: 30px;
  186. border-radius: 10px;
  187. &:nth-of-type(4n + 0) {
  188. margin-right: 0px;
  189. }
  190. }
  191. }
  192. </style>