guide-pc.vue 6.0 KB

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