dialog-base.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <template>
  2. <view v-if="visible" class="dialog-container uni-column">
  3. <view class="bg"></view>
  4. <view class="dialog-body">
  5. <view class="close-btn uni-column" @click="close">
  6. <image class="close-btn-icon" src="../../static/images/login-dialog-close-icon.png" mode="widthFix" />
  7. </view>
  8. <view class="dialog-title">
  9. <text class="label">{{props.title}}</text>
  10. </view>
  11. <slot></slot>
  12. <slot name='footer'></slot>
  13. </view>
  14. </view>
  15. </template>
  16. <script setup>
  17. import {
  18. ref
  19. } from 'vue'
  20. const visible = ref(false)
  21. const emit = defineEmits(['close'])
  22. const props = defineProps({
  23. title: {
  24. type: String,
  25. default: '对话框'
  26. }
  27. })
  28. const open = () => {
  29. visible.value = true
  30. }
  31. function close() {
  32. emit('close')
  33. visible.value = false
  34. }
  35. /** 暴露给父组件的方法 */
  36. defineExpose({
  37. open,
  38. close
  39. })
  40. </script>
  41. <style lang="scss">
  42. .dialog-container {
  43. position: fixed;
  44. top: 0;
  45. right: 0;
  46. bottom: 0;
  47. left: 0;
  48. z-index: 1000;
  49. .bg {
  50. position: absolute;
  51. top: 0;
  52. right: 0;
  53. bottom: 0;
  54. left: 0;
  55. background-color: #333333;
  56. opacity: 0.3;
  57. z-index: 1001;
  58. }
  59. .dialog-body {
  60. border-radius: 18rpx;
  61. // position: absolute;
  62. // top: 400rpx;
  63. // right: 64rpx;
  64. // left: 64rpx;
  65. width: 70%;
  66. margin: auto auto;
  67. padding: 0 48rpx 48rpx 48rpx;
  68. background-color: #FFFFFF;
  69. z-index: 1002;
  70. max-height: 64%;
  71. // overflow: auto;
  72. .close-btn {
  73. position: absolute;
  74. right: 24rpx;
  75. top: 24rpx;
  76. width: 40rpx;
  77. height: 40rpx;
  78. z-index: 1003;
  79. .close-btn-icon {
  80. width: 40rpx;
  81. }
  82. }
  83. .dialog-title {
  84. align-items: center;
  85. margin-top: 40rpx;
  86. .label {
  87. font-weight: bold;
  88. font-size: 40rpx;
  89. }
  90. }
  91. }
  92. }
  93. </style>