guide-pc.vue 5.8 KB

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