dialog-base.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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 props = defineProps({
  22. title: {
  23. type: String,
  24. default: '对话框'
  25. }
  26. })
  27. const open = () => {
  28. visible.value = true
  29. }
  30. function close() {
  31. visible.value = false
  32. }
  33. /** 暴露给父组件的方法 */
  34. defineExpose({
  35. open,
  36. close
  37. })
  38. </script>
  39. <style lang="scss">
  40. .dialog-container {
  41. position: fixed;
  42. top: 0;
  43. right: 0;
  44. bottom: 0;
  45. left: 0;
  46. z-index: 1000;
  47. .bg {
  48. position: absolute;
  49. top: 0;
  50. right: 0;
  51. bottom: 0;
  52. left: 0;
  53. background-color: #333333;
  54. opacity: 0.3;
  55. z-index: 1001;
  56. }
  57. .dialog-body {
  58. border-radius: 18rpx;
  59. // position: absolute;
  60. // top: 400rpx;
  61. // right: 64rpx;
  62. // left: 64rpx;
  63. width: 70%;
  64. margin: auto auto;
  65. padding: 0 48rpx 48rpx 48rpx;
  66. background-color: #FFFFFF;
  67. z-index: 1002;
  68. max-height: 64%;
  69. // overflow: auto;
  70. .close-btn {
  71. position: absolute;
  72. right: 24rpx;
  73. top: 24rpx;
  74. width: 40rpx;
  75. height: 40rpx;
  76. z-index: 1003;
  77. .close-btn-icon {
  78. width: 40rpx;
  79. }
  80. }
  81. .dialog-title {
  82. align-items: center;
  83. margin-top: 40rpx;
  84. .label {
  85. font-weight: bold;
  86. font-size: 40rpx;
  87. }
  88. }
  89. }
  90. }
  91. </style>