popup.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <template>
  2. <up-popup
  3. :show="show"
  4. :overlay="!overlay"
  5. :closeOnClickOverlay="!closeOnClickOverlay"
  6. :zIndex="zIndex"
  7. :safeAreaInsetTop="safeAreaInsetTop"
  8. :round="round"
  9. :mode="mode"
  10. @close="close"
  11. :customStyle="{ maxWidth: '1536rpx', margin: '0 auto' }"
  12. >
  13. <view class="pop">
  14. <view class="top" v-if="title || isClose">
  15. <view class="top_left">
  16. <slot name="title">
  17. <trans :_t="title" />
  18. </slot>
  19. </view>
  20. <view class="close" @click="close" v-if="isClose">
  21. <i
  22. class="icon-font"
  23. :class="icon"
  24. :style="{ color: iconColor, fontSize: iconSize }"
  25. ></i>
  26. </view>
  27. </view>
  28. <view class="conts">
  29. <slot name="content"></slot>
  30. </view>
  31. <view class="footer">
  32. <slot name="footer"></slot>
  33. </view>
  34. </view>
  35. </up-popup>
  36. </template>
  37. <script setup>
  38. import { ref } from "vue";
  39. const props = defineProps({
  40. overlay: Boolean,
  41. closeOnClickOverlay: Boolean,
  42. safeAreaInsetTop: Boolean,
  43. title: {
  44. type: String,
  45. default: "",
  46. },
  47. round: {
  48. type: Number,
  49. default: 10,
  50. },
  51. mode: {
  52. type: String,
  53. default: "bottom",
  54. },
  55. isClose: Boolean,
  56. icon: {
  57. type: String,
  58. default: "icon-close",
  59. },
  60. iconColor: {
  61. type: String,
  62. default: "var(--text-01)",
  63. },
  64. iconSize: {
  65. type: String,
  66. default: "28px",
  67. },
  68. zIndex: {
  69. type: [Number, String],
  70. default: 10075,
  71. },
  72. });
  73. const emit = defineEmits(["close"]);
  74. const show = ref(false);
  75. const open = () => {
  76. show.value = true;
  77. };
  78. const close = () => {
  79. show.value = false;
  80. };
  81. defineExpose({
  82. open,
  83. close,
  84. });
  85. </script>
  86. <style lang="less" scoped>
  87. .pop {
  88. max-height: 80vh;
  89. display: flex;
  90. flex-direction: column;
  91. .top {
  92. padding: 48rpx 48rpx 0;
  93. display: flex;
  94. align-items: center;
  95. justify-content: space-between;
  96. &_left {
  97. display: flex;
  98. align-items: center;
  99. color: var(--text);
  100. font-size: 32rpx;
  101. font-weight: 700;
  102. }
  103. .close {
  104. .icon-close {
  105. cursor: pointer;
  106. font-weight: 400;
  107. }
  108. }
  109. }
  110. .conts {
  111. display: flex;
  112. align-items: stretch;
  113. flex-grow: 1;
  114. padding: 32rpx 48rpx;
  115. overflow: hidden scroll;
  116. }
  117. .footer {
  118. padding: 0 48rpx 24rpx;
  119. }
  120. }
  121. </style>