message-box.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <!-- 消息提示组件 -->
  2. <template>
  3. <div class="msg-box-overlay" v-if="dialogVisible">
  4. <div class="content-wrapper">
  5. <div class="title" :class="{'fill': !content}">{{title}}</div>
  6. <div class="desc" v-if="content">{{content}}</div>
  7. <div class="btn-wrapper">
  8. <div class="btn cancel" @click="cancel">{{cancelTxt}}</div>
  9. <div class="btn confirm" @click="confirm">{{confirmTxt}}</div>
  10. </div>
  11. </div>
  12. </div>
  13. </template>
  14. <script setup>
  15. import { ref, defineEmits, defineProps } from "vue";
  16. const props = defineProps({
  17. dialogVisible: {
  18. type: Boolean,
  19. default: false,
  20. },
  21. title: {
  22. type: String,
  23. default: ''
  24. },
  25. content: {
  26. type: String,
  27. default: ''
  28. },
  29. cancelTxt: {
  30. type: String,
  31. default: 'Cancel',
  32. },
  33. confirmTxt: {
  34. type: String,
  35. default: 'Completed',
  36. }
  37. });
  38. const emits = defineEmits(["cancel", "confirm"]);
  39. const cancel = () => {
  40. emits("cancel", {});
  41. };
  42. const confirm = () => {
  43. emits("confirm", {});
  44. };
  45. </script>
  46. <style lang="scss" scoped>
  47. .msg-box-overlay {
  48. position: fixed;
  49. top: 0;
  50. right: 0;
  51. bottom: 0;
  52. left: 0;
  53. z-index: 3000;
  54. height: 100%;
  55. background-color: rgba(0, 0, 0, 0.5);
  56. overflow: auto;
  57. .content-wrapper {
  58. position: absolute;
  59. left: 50%;
  60. top: 50%;
  61. width: 375px;
  62. // min-height: 220px;
  63. background: #FFFFFF;
  64. border-radius: 20px;
  65. padding: 20px;
  66. box-sizing: border-box;
  67. transform: translate(-50%, -50%);
  68. text-align: center;
  69. .title {
  70. font-weight: 600;
  71. font-size: 20px;
  72. margin-bottom: 13px;
  73. box-sizing: border-box;
  74. }
  75. .fill {
  76. padding: 20px 0;
  77. }
  78. .desc {
  79. height: 68px;
  80. font-weight: 400;
  81. font-size: 15px;
  82. margin-bottom: 25px;
  83. }
  84. .btn-wrapper {
  85. display: flex;
  86. align-items: center;
  87. justify-content: space-between;
  88. .btn {
  89. height: 46px;
  90. width: 163px;
  91. text-align: center;
  92. line-height: 46px;
  93. border-radius: 100px;
  94. border: 1px solid #1D9BF0;
  95. box-sizing: border-box;
  96. font-weight: 600;
  97. font-size: 16px;
  98. cursor: pointer;
  99. }
  100. .cancel {
  101. color: #1D9BF0;
  102. }
  103. .confirm {
  104. background: #1D9BF0;
  105. color: #fff;
  106. }
  107. }
  108. }
  109. }
  110. </style>