index.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <template>
  2. <transition appear name="custom-classes-transition" leave-active-class="animated fadeOut faster">
  3. <div class="open-video">
  4. <video x5-playsinline="true" playsinline="true" webkit-playsinline="true" ref="openvideo$" preload autoplay :src="videourl"></video>
  5. <div @click.stop="emit('close')" class="jump">跳過</div>
  6. </div>
  7. </transition>
  8. </template>
  9. <script setup>
  10. import { ref, watch, defineEmits, computed, onMounted,nextTick, defineProps } from 'vue'
  11. import * as apis from "@/apis/index.js";
  12. const openvideo$ = ref(null);
  13. const videourl = ref(null);
  14. const emit = defineEmits(["close"]);
  15. onMounted(()=>{
  16. nextTick(async ()=>{
  17. let res = await apis.get_video()
  18. videourl.value = res.data.videoUrl
  19. openvideo$.value.addEventListener('ended',()=>{
  20. emit('close')
  21. })
  22. document.addEventListener("WeixinJSBridgeReady",()=> {
  23. openvideo$.value.play();
  24. }, false);
  25. })
  26. })
  27. </script>
  28. <style lang="scss" scoped>
  29. .open-video{
  30. position: fixed;
  31. width: 100%;
  32. height: 100%;
  33. top: 0;
  34. left: 0;
  35. right: 0;
  36. bottom: 0;
  37. display: table;
  38. table-layout: fixed;
  39. background: rgba(255, 255, 255, 1);
  40. >video{
  41. width: 100%;
  42. height: 100%;
  43. display: table-cell;
  44. text-align: center;
  45. vertical-align: middle;
  46. }
  47. .jump{
  48. position: absolute;
  49. right: 15px;
  50. top: 20px;
  51. width: 56px;
  52. height: 28px;
  53. background: rgba(0, 0, 0, 0.5);
  54. border-radius: 16px;
  55. text-align: center;
  56. line-height: 28px;
  57. z-index: 999;
  58. }
  59. }
  60. </style>