guide-pc.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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. adPlace: 20,
  82. os: 0
  83. }
  84. const res = await this.$axios.$post('/public/v5/advertising/getAdInfoByAdPlace', data);
  85. this.topADList = res.data;
  86. },
  87. play(item, ele, index, idx) {
  88. this.showVideo = true
  89. this.videoList[index].videoCourseList[idx].isShow = true
  90. this.index = index
  91. this.idx = idx
  92. const elVideo = document.getElementById('el-video-' + ele.id)
  93. elVideo.addEventListener("ended", () => {
  94. elVideo.pause();
  95. this.showVideo = false
  96. this.videoList[index].videoCourseList[idx].isShow = false
  97. });
  98. elVideo.addEventListener("play", () => {
  99. this.submit(item, ele, 1)
  100. });
  101. },
  102. playAd(item) {
  103. this.submit(item, '', 2)
  104. if (item.actionType === '1' || item.actionType === '3' || item.actionType === '5' || item.actionType === '6') {
  105. window.open(item.clickUrl, '_blank')
  106. } else if (item.actionType === '4') {
  107. window.open(item.deeplink, '_blank')
  108. }
  109. },
  110. submit(item, ele, flag) {
  111. const data = flag === 1 ? { id: ele.id, plateId: item.plateId, type: flag, videoId: ele.id } : { type: 2, adId: item.id, adName: item.title }
  112. this.$axios.$post('/activity/videoCourse/statistics/save', data, { headers: { Authorization: this.token } });
  113. }
  114. }
  115. }
  116. </script>
  117. <style lang="scss">
  118. @media (min-width: 0px) {
  119. .bg-guide {
  120. & .v-tabs-bar {
  121. height: 42px !important;
  122. }
  123. .v-btn--icon.v-size--small {
  124. height: 15px;
  125. width: 15px;
  126. }
  127. }
  128. }
  129. </style>
  130. <style lang="scss" scoped>
  131. .bgFAFAFA {
  132. background: #fafafa;
  133. }
  134. @media (min-width: 0px) {
  135. .wh24 {
  136. width: 24px;
  137. height: 24px;
  138. position: fixed;
  139. right: 20px;
  140. top: 20px;
  141. z-index: 4;
  142. }
  143. .hide {
  144. display: none;
  145. }
  146. .videobox {
  147. position: fixed;
  148. left: 0;
  149. top: 0;
  150. right: 0;
  151. bottom: 0;
  152. background: #1c1c1e;
  153. z-index: 2;
  154. width: 100vw;
  155. height: 100vh;
  156. overflow: hidden;
  157. }
  158. .videobox video {
  159. height: 100vh;
  160. width: 100vw;
  161. position: absolute;
  162. left: 0;
  163. top: 0;
  164. z-index: 3;
  165. }
  166. .video-card {
  167. width: 165px;
  168. height: 148px;
  169. border-radius: 5px;
  170. position: relative;
  171. display: inline-block;
  172. padding: 0;
  173. margin-bottom: 10px;
  174. z-index: 1;
  175. & .video-card-title {
  176. width: 100%;
  177. height: 45px;
  178. line-height: 45px;
  179. text-align: center;
  180. font-size: 14px;
  181. font-weight: 500;
  182. color: #1c1c1e;
  183. background: #fff;
  184. border-radius: 0 0 9px 9px;
  185. position: absolute;
  186. left: 0;
  187. bottom: 0;
  188. }
  189. }
  190. .bg-guide {
  191. min-height: 100vh;
  192. overflow: hidden;
  193. & .v-tab {
  194. font-size: 12px;
  195. min-width: 88px;
  196. }
  197. & .v-tabs-bar {
  198. height: 42px !important;
  199. }
  200. }
  201. .w345h120 {
  202. width: 345px;
  203. height: 120px;
  204. margin: 10px auto;
  205. display: block;
  206. background: #fafafa;
  207. border-radius: 5px;
  208. }
  209. .w165h148 {
  210. width: 165px;
  211. height: 148px;
  212. margin: 0 auto;
  213. display: block;
  214. border-radius: 10px;
  215. }
  216. }
  217. </style>