guide-pc.vue 6.1 KB

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