confirmModal.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <template>
  2. <view v-if="visible" class="modal_mask" >
  3. <view class="modal_container" @click.stop>
  4. <view class="modal_header">
  5. <view class="header_left">
  6. <image src="/static/image/icon/icon_warn.png" class="warning_icon" mode="aspectFit"></image>
  7. <text class="header_title">{{ title }}</text>
  8. </view>
  9. <view class="close_btn" @click="handleClose">
  10. <image src="/static/image/icon/close.png" class="close_icon" mode="aspectFit"></image>
  11. </view>
  12. </view>
  13. <view class="modal_content">
  14. <text class="content_text">{{ content }}</text>
  15. </view>
  16. <view class="modal_footer">
  17. <view class="btn cancel_btn" @click="handleCancel">
  18. <text class="btn_text">{{ cancelText }}</text>
  19. </view>
  20. <view class="btn confirm_btn" @click="handleConfirm">
  21. <text class="btn_text">{{ confirmText }}</text>
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. </template>
  27. <script setup>
  28. const props = defineProps({
  29. visible: {
  30. type: Boolean,
  31. default: false
  32. },
  33. title: {
  34. type: String,
  35. default: '提示'
  36. },
  37. content: {
  38. type: String,
  39. default: ''
  40. },
  41. cancelText: {
  42. type: String,
  43. default: '取消'
  44. },
  45. confirmText: {
  46. type: String,
  47. default: '确定'
  48. }
  49. });
  50. const emit = defineEmits(['close', 'cancel', 'confirm']);
  51. const handleClose = () => {
  52. emit('close');
  53. emit('cancel');
  54. };
  55. const handleCancel = () => {
  56. emit('cancel');
  57. };
  58. const handleConfirm = () => {
  59. emit('confirm');
  60. };
  61. </script>
  62. <style lang="scss" scoped>
  63. .modal_mask {
  64. position: fixed;
  65. top: 0;
  66. left: 0;
  67. right: 0;
  68. bottom: 0;
  69. background-color: rgba(0, 0, 0, 0.5);
  70. display: flex;
  71. align-items: center;
  72. justify-content: center;
  73. z-index: 1000;
  74. }
  75. .modal_container {
  76. width: 90%;
  77. background-color: #FFFFFF;
  78. border-radius: 16rpx;
  79. overflow: hidden;
  80. }
  81. .modal_header {
  82. display: flex;
  83. align-items: center;
  84. justify-content: space-between;
  85. height: 96rpx;
  86. padding: 0 40rpx;
  87. background-color: #F5F7FA;
  88. .header_left {
  89. display: flex;
  90. align-items: center;
  91. }
  92. .warning_icon {
  93. width: 40rpx;
  94. height: 40rpx;
  95. margin-right: 16rpx;
  96. }
  97. .header_title {
  98. font-weight: 500;
  99. font-size: 32rpx;
  100. color: #333333;
  101. }
  102. .close_btn {
  103. width: 48rpx;
  104. height: 48rpx;
  105. display: flex;
  106. align-items: center;
  107. justify-content: center;
  108. .close_icon {
  109. width: 48rpx;
  110. height: 48rpx;
  111. }
  112. }
  113. }
  114. .modal_content {
  115. height: 198rpx;
  116. padding: 0 32rpx;
  117. border-bottom: 2rpx solid #DCDFE6;
  118. line-height: 198rpx;
  119. .content_text {
  120. font-size: 28rpx;
  121. color: #000000;
  122. }
  123. }
  124. .modal_footer {
  125. display: flex;
  126. padding: 28rpx 40rpx;
  127. justify-content: space-around;
  128. gap: 32rpx;
  129. .btn {
  130. height: 80rpx;
  131. width: 280rpx;
  132. border-radius: 8rpx;
  133. display: flex;
  134. align-items: center;
  135. justify-content: center;
  136. margin-left: 0;
  137. .btn_text {
  138. font-size: 28rpx;
  139. font-weight: 500;
  140. }
  141. }
  142. .cancel_btn {
  143. background-color: #FFFFFF;
  144. border: 2rpx solid #DCDFE6;
  145. .btn_text {
  146. color: #666666;
  147. }
  148. }
  149. .confirm_btn {
  150. background-color: #2E64FA;
  151. border: 2rpx solid #2E64FA;
  152. .btn_text {
  153. color: #FFFFFF;
  154. }
  155. }
  156. }
  157. </style>