123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <div
  3. v-if="show"
  4. class="overlay"
  5. @click="onClose"
  6. >
  7. <div class="warp" @click.stop>
  8. <img :src="info.image" class="image" alt="" />
  9. <div class="text">
  10. {{ info.content }}
  11. </div>
  12. </div>
  13. <div class="colse" ><i class="iconfont icon-roundclose"></i></div>
  14. </div>
  15. </template>
  16. <script setup>
  17. import { onMounted, ref, watch } from 'vue';
  18. const props = defineProps({
  19. show: Boolean,
  20. info: Object,
  21. onClose: {
  22. type: Function,
  23. default: () => {},
  24. },
  25. });
  26. const origin = document.body.style.overflow;
  27. watch(() => props.show, (val) => {
  28. if (val) {
  29. document.body.style.overflow = 'hidden';
  30. } else {
  31. document.body.style.overflow = origin;
  32. }
  33. })
  34. </script>
  35. <style lang="less" scoped>
  36. .overlay {
  37. position: fixed;
  38. top: 0;
  39. left: 0;
  40. width: 100vw;
  41. height: 100vh;
  42. z-index: 100;
  43. overflow: hidden;
  44. background: rgba(0, 0, 0, 0.8);
  45. display: flex;
  46. flex-direction: column;
  47. justify-content: center;
  48. align-items: center;
  49. .warp {
  50. margin: 0 auto;
  51. width: 80%;
  52. height: 80%;
  53. overflow: hidden;
  54. display: flex;
  55. flex-direction: column;
  56. // background: fff;
  57. overflow-y: auto;
  58. .image {
  59. width: 100%;
  60. }
  61. .text {
  62. line-height: 1.6em;
  63. padding: 0 20px;
  64. font-size: 20px;
  65. text-indent: 42px;
  66. margin-top: 50px;
  67. color: #fff;
  68. }
  69. }
  70. .warp::-webkit-scrollbar {
  71. display: none;
  72. }
  73. animation: fade-in; /*动画名称*/
  74. animation-duration: 0.7s; /*动画持续时间*/
  75. .colse{
  76. position: absolute;
  77. bottom: 20px;
  78. color: rgba(256, 256, 256, 0.8);
  79. .icon-roundclose{
  80. font-size: 48px;
  81. }
  82. }
  83. }
  84. @keyframes fade-in {
  85. 0% {
  86. opacity: 0;
  87. } /*初始状态 透明度为0*/
  88. // 40% {
  89. // opacity: 0.3;
  90. // } /*过渡状态 透明度为0*/
  91. 100% {
  92. opacity: 1;
  93. } /*结束状态 透明度为1*/
  94. }
  95. </style>