guide-pc.vue 5.9 KB

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