dialog-base.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. margin-top: 260rpx;
  68. margin-left: auto;
  69. margin-right: auto;
  70. padding: 0 48rpx 48rpx 48rpx;
  71. background-color: #FFFFFF;
  72. z-index: 1002;
  73. max-height: 64%;
  74. // overflow: auto;
  75. .close-btn {
  76. position: absolute;
  77. right: 24rpx;
  78. top: 24rpx;
  79. width: 40rpx;
  80. height: 40rpx;
  81. z-index: 1003;
  82. .close-btn-icon {
  83. width: 40rpx;
  84. }
  85. }
  86. .dialog-title {
  87. align-items: center;
  88. margin-top: 40rpx;
  89. .label {
  90. font-weight: bold;
  91. font-size: 40rpx;
  92. }
  93. }
  94. }
  95. }
  96. </style>