index.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <template>
  2. <div
  3. class="modal-wrap"
  4. @click.self="maskClose"
  5. >
  6. <div class="container">
  7. <span class="title">{{ props.title }}</span>
  8. <i
  9. v-if="!hiddenClose"
  10. class="close"
  11. @click="emits('close')"
  12. ></i>
  13. <div class="content">
  14. <slot></slot>
  15. </div>
  16. <div class="footer">
  17. <slot name="footer"></slot>
  18. <div
  19. v-if="!slots.footer"
  20. class="btn"
  21. >
  22. 返回首页
  23. </div>
  24. </div>
  25. </div>
  26. </div>
  27. </template>
  28. <script lang="ts" setup>
  29. import { useSlots } from 'vue';
  30. const slots = useSlots();
  31. const props = defineProps({
  32. modelValue: Boolean,
  33. hiddenClose: Boolean,
  34. maskClosable: Boolean,
  35. title: {
  36. type: String,
  37. default: '',
  38. },
  39. });
  40. function maskClose() {
  41. if (props.maskClosable) {
  42. emits('close');
  43. }
  44. }
  45. const emits = defineEmits(['close']);
  46. </script>
  47. <style lang="scss" scoped>
  48. .modal-wrap {
  49. z-index: 1;
  50. background-color: rgba(0, 0, 0, 0.7) !important;
  51. @extend %maskBg;
  52. .container {
  53. position: absolute;
  54. top: 50%;
  55. left: 50%;
  56. box-sizing: border-box;
  57. padding: 20px;
  58. // min-height: 200px;
  59. width: 320px;
  60. border-radius: 10px;
  61. background-color: #fff;
  62. font-size: 14px;
  63. transform: translate(-50%, -50%);
  64. .title {
  65. font-weight: 700;
  66. font-size: 24px;
  67. }
  68. .close {
  69. position: absolute;
  70. top: 20px;
  71. right: 20px;
  72. width: 18px;
  73. height: 18px;
  74. cursor: pointer;
  75. @include cross(#ccc, 3px);
  76. }
  77. .content {
  78. margin-top: 10px;
  79. }
  80. .footer {
  81. margin-top: 10px;
  82. .btn {
  83. width: 280px;
  84. height: 44px;
  85. border-radius: 100px;
  86. background: linear-gradient(270deg, #929dff 4.71%, #3cfdfd 103.24%),
  87. linear-gradient(270deg, #b3acff 4.71%, #3ccffd 103.24%),
  88. linear-gradient(270deg, #b3acff 4.71%, #3ccffd 103.24%);
  89. color: white;
  90. font-weight: 600;
  91. font-size: 16px;
  92. line-height: 44px;
  93. cursor: pointer;
  94. }
  95. }
  96. }
  97. }
  98. </style>