TutorialModal.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <template>
  2. <ion-modal
  3. :is-open="show"
  4. ref="modalRef"
  5. class="open-modal"
  6. @didDismiss="show = false"
  7. :enter-animation="enterAnimation"
  8. :leave-animation="leaveAnimation"
  9. >
  10. <ion-content>
  11. <ion-header>
  12. <ion-toolbar>
  13. <ion-buttons slot="end">
  14. <ion-button @click="dismiss()">{{
  15. showClose ? $t('common.close') : $t('common.skip')
  16. }}</ion-button>
  17. </ion-buttons>
  18. </ion-toolbar>
  19. </ion-header>
  20. <ion-content>
  21. <video
  22. ref="videoRef"
  23. class="video"
  24. webkit-playsinline="true"
  25. x5-video-player-type="h5"
  26. x5-video-orientation="portraint"
  27. autoplay
  28. loop
  29. controls
  30. >
  31. <source
  32. src="https://paimaide.s3.ap-northeast-1.amazonaws.com/video/2023-01-30-07-43-43NAoUVgVk.mp4"
  33. type="video/mp4"
  34. />
  35. </video>
  36. </ion-content>
  37. <!-- <van-button class="back" v-if="showClose" round @click="show = false">{{ $t('common.close') }}</van-button>
  38. <van-button class="back" v-else round @click="show = false">{{ $t('common.skip') }}</van-button> -->
  39. </ion-content>
  40. </ion-modal>
  41. </template>
  42. <script setup>
  43. import { ref, onMounted } from 'vue'
  44. import { createAnimation } from '@ionic/vue'
  45. const show = ref(false)
  46. const modalRef = ref(false)
  47. const videoRef = ref(false)
  48. const showClose = ref(true)
  49. function dismiss() {
  50. modalRef.value.$el.dismiss()
  51. }
  52. const enterAnimation = baseEl => {
  53. const root = baseEl.shadowRoot
  54. const backdropAnimation = createAnimation()
  55. .addElement(root.querySelector('ion-backdrop'))
  56. .fromTo('opacity', '0.01', 'var(--backdrop-opacity)')
  57. const wrapperAnimation = createAnimation()
  58. .addElement(root.querySelector('.modal-wrapper'))
  59. .keyframes([
  60. { offset: 0, opacity: '0', transform: 'scale(0)' },
  61. { offset: 1, opacity: '0.99', transform: 'scale(1)' }
  62. ])
  63. return createAnimation()
  64. .addElement(baseEl)
  65. .easing('ease-out')
  66. .duration(500)
  67. .addAnimation([backdropAnimation, wrapperAnimation])
  68. }
  69. const leaveAnimation = baseEl => {
  70. return enterAnimation(baseEl).direction('reverse')
  71. }
  72. function init() {
  73. showClose.value = true
  74. show.value = true
  75. }
  76. defineExpose({
  77. init
  78. })
  79. </script>
  80. <style lang="less" scoped>
  81. .video {
  82. width: 100vw;
  83. height: 100%;
  84. display: block;
  85. position: relative;
  86. z-index: 1;
  87. }
  88. .back {
  89. position: fixed;
  90. right: 30px;
  91. top: calc(var(--ion-safe-area-top) + 30px);
  92. z-index: 999;
  93. width: 60px;
  94. height: 26px;
  95. background-color: rgba(255, 255, 255, 0.1);
  96. border-width: 0;
  97. color: #fff;
  98. }
  99. </style>