guide-pc.vue 5.8 KB

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