guide.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <template>
  2. <div class="bg2C2C2D">
  3. <video v-for="item in topADList" id="ad" :key="item.id" class="w345h120" :poster="item.imgUrls[0]" :src="item.videoUrl" @click="playAd()" />
  4. <div v-for="item in videoList" :key="item.plateId">
  5. <div class="fs16">{{item.plateName}}</div>
  6. <div :class="item.displayMode === 1 ? 'jjjc-list' : 'jcjc-list'">
  7. <div v-for="ele in item.videoCourseList" :key="ele.id" class="video-card">
  8. <video :id="'el-video-' + ele.id" class="w165h148" preload="auto" :poster="videoURL(ele.coverImageKey)" :src="videoURL(ele.videoKey)" @click="play(item, ele)" />
  9. <div class="video-card-title">{{ele.videoName}}</div>
  10. </div>
  11. </div>
  12. </div>
  13. <!-- <div class="return out"><div class="in"><img src="~/assets/image/activity/invite-user/guide/left.png" /></div></div> -->
  14. </div>
  15. </template>
  16. <script>
  17. import { fileKeyToUrl } from '@/plugins/file-center.js';
  18. export default {
  19. name: 'Guide',
  20. auth: false,
  21. data() {
  22. return {
  23. videoList: [],
  24. topADList: [],
  25. token: ''
  26. }
  27. },
  28. async fetch() {
  29. if (this.$userAgent.isAndroid) {
  30. this.token = await window.native.getToken();
  31. } else {
  32. this.token = this.$route.query.token;
  33. }
  34. },
  35. computed: {
  36. videoURL() {
  37. return (key) => {
  38. return fileKeyToUrl(key)
  39. }
  40. }
  41. },
  42. created() {
  43. this.getActiveInfo()
  44. this.getAdInfoByAdPlace()
  45. },
  46. methods: {
  47. async getActiveInfo() {
  48. const res = await this.$axios.$get('/activity/videoCourse/client/list');
  49. this.videoList = res.data;
  50. },
  51. async getAdInfoByAdPlace() {
  52. const data = {
  53. id: 1,
  54. adPlace: 20,
  55. os: 1
  56. }
  57. const res = await this.$axios.$post('/public/v5/advertising/getAdInfoByAdPlace', data);
  58. this.topADList = res.data;
  59. },
  60. play(item, ele) {
  61. const elVideo = document.getElementById('el-video-' + ele.id)
  62. if (elVideo.requestFullscreen) {
  63. elVideo.requestFullscreen()
  64. elVideo.play()
  65. } else if (elVideo.mozRequestFullscreen) {
  66. elVideo.mozRequestFullscreen()
  67. elVideo.play()
  68. } else if (elVideo.webkitRequestFullscreen) {
  69. elVideo.webkitRequestFullscreen()
  70. elVideo.play()
  71. } else {
  72. elVideo.requestFullscreen()
  73. elVideo.play()
  74. }
  75. this.submit(item, ele, 1)
  76. },
  77. playAd(item, ele) {
  78. const elVideo = document.getElementById('ad')
  79. if (elVideo.requestFullscreen) {
  80. elVideo.requestFullscreen()
  81. elVideo.play()
  82. } else if (elVideo.mozRequestFullscreen) {
  83. elVideo.mozRequestFullscreen()
  84. elVideo.play()
  85. } else if (elVideo.webkitRequestFullscreen) {
  86. elVideo.webkitRequestFullscreen()
  87. elVideo.play()
  88. }
  89. this.submit(item, ele, 2)
  90. },
  91. submit(item, ele, flag) {
  92. const data = flag === 1 ? { id: ele.id, plateId: item.plateId, type: flag, videoId: ele.id } : { type: 2 }
  93. this.$axios.$post('/activity/videoCourse/statistics/save', data, {headers: {Authorization: this.token}});
  94. }
  95. }
  96. }
  97. </script>
  98. <style lang="scss" scoped>
  99. .video-card {
  100. width: 165px;
  101. height: 148px;
  102. border-radius: 5px;
  103. position: relative;
  104. & .video-card-title {
  105. width: 100%;
  106. height: 45px;
  107. line-height: 45px;
  108. text-align: center;
  109. font-size: 14px;
  110. font-weight: 500;
  111. color: #1C1C1E;
  112. background: #fff;
  113. position: absolute;
  114. left: 0;
  115. bottom: 0;
  116. border-radius: 0 0 9px 9px;
  117. }
  118. }
  119. .bg2C2C2D {
  120. background-color: #1C1C1E;
  121. min-height: 100vh;
  122. overflow: hidden;
  123. }
  124. .w345h120 {
  125. width: 345px;
  126. height: 120px;
  127. margin: 15px;
  128. }
  129. .fs16 {
  130. font-weight: 500;
  131. color: #ffffff;
  132. font-size: 16px;
  133. margin-left: 15px;
  134. display: flex;
  135. align-items: center;
  136. }
  137. .jcjc-list {
  138. padding: 0 15px;
  139. overflow-x: scroll;
  140. overflow-y: hidden;
  141. display: flex;
  142. margin: 15px 0;
  143. .video-card {
  144. margin-right: 10px;
  145. &:last-child {
  146. margin-right: 0;
  147. }
  148. }
  149. }
  150. .fs16::before {
  151. content: '';
  152. display: inline-block;
  153. width: 6px;
  154. height: 14px;
  155. background: #3b7fff;
  156. border-radius: 3px 3px 3px 3px;
  157. opacity: 1;
  158. margin-right: 6px;
  159. }
  160. .w144h140 {
  161. width: 144px;
  162. height: 140px;
  163. margin-right: 10px;
  164. }
  165. .w144h140:last-child {
  166. margin-right: 0;
  167. }
  168. .jjjc-list {
  169. display: flex;
  170. flex-flow: wrap;
  171. justify-content: space-between;
  172. padding: 15px;
  173. }
  174. .w165h148 {
  175. width: 165px;
  176. height: 148px;
  177. object-fit: contain;
  178. margin-bottom: 15px;
  179. border-radius: 10px;
  180. }
  181. .return {
  182. width: 42px;
  183. height: 42px;
  184. margin-left: 20px;
  185. margin-bottom: 40px;
  186. &.out {
  187. border-radius: 50%;
  188. padding: 1px;
  189. background: linear-gradient(46deg, rgba(48, 49, 53, 1), rgba(113, 116, 127, 1));
  190. box-shadow: 0px 9px 17px 0px rgba(0,0,0,0.5);
  191. }
  192. .in {
  193. width: 40px;
  194. height: 40px;
  195. border-radius: 50%;
  196. background: linear-gradient(180deg, #232427 0%, #4B4C52 100%);
  197. opacity: 1;
  198. text-align: center;
  199. line-height: 40px;
  200. }
  201. img {
  202. width: 16px;
  203. height: 16px;
  204. }
  205. }
  206. </style>