ConfirmDialog.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <script setup lang="ts">
  2. const props = defineProps<{
  3. show: boolean
  4. title: string
  5. confirmText: string
  6. cancelText: string
  7. }>()
  8. const emit = defineEmits<{
  9. (e: 'update:show', value: boolean): void
  10. (e: 'confirm' | 'cancel'): void
  11. }>()
  12. const handleClose = () => {
  13. emit('update:show', false)
  14. emit('cancel')
  15. }
  16. const handleConfirm = () => {
  17. emit('confirm')
  18. emit('update:show', false)
  19. }
  20. const handleCancel = () => {
  21. emit('cancel')
  22. emit('update:show', false)
  23. }
  24. </script>
  25. <template>
  26. <van-popup
  27. :show="props.show"
  28. position="center"
  29. class="order-popup-confirm"
  30. @update:show="val => emit('update:show', val)"
  31. >
  32. <div class="order-popup-confirm__container">
  33. <div
  34. class="order-popup-confirm__close"
  35. @click="handleClose"
  36. >
  37. <van-icon
  38. name="cross"
  39. :size="20"
  40. color="#CDCFD9"
  41. />
  42. </div>
  43. <div class="order-popup-confirm__title">
  44. {{ props.title }}
  45. </div>
  46. <div class="order-popup-confirm__content">
  47. <div
  48. class="order-popup-btn-confirm"
  49. @click="handleConfirm"
  50. >
  51. {{ props.confirmText }}
  52. </div>
  53. <div
  54. class="order-popup-btn-cancel"
  55. @click="handleCancel"
  56. >
  57. {{ props.cancelText }}
  58. </div>
  59. </div>
  60. </div>
  61. </van-popup>
  62. </template>
  63. <style scoped lang="scss">
  64. .order-popup-confirm {
  65. background-color: transparent;
  66. &__container {
  67. width: 300px;
  68. padding: 30px 24px;
  69. border-radius: 20px;
  70. background-color: #fff;
  71. position: relative;
  72. display: flex;
  73. flex-direction: column;
  74. align-items: center;
  75. justify-content: space-between;
  76. gap: 16px;
  77. }
  78. &__close {
  79. position: absolute;
  80. top: 12px;
  81. right: 12px;
  82. }
  83. &__content {
  84. display: flex;
  85. flex-direction: column;
  86. gap: 16px;
  87. .order-popup-btn-confirm {
  88. @include size(200px, 36px);
  89. border-radius: 999px;
  90. background-image: linear-gradient(90deg, #2f95ff 0%, #50ffd8 100%);
  91. color: #fff;
  92. font-size: 14px;
  93. font-weight: 600;
  94. display: flex;
  95. align-items: center;
  96. justify-content: center;
  97. cursor: pointer;
  98. -webkit-tap-highlight-color: transparent;
  99. }
  100. .order-popup-btn-cancel {
  101. @include size(200px, 36px);
  102. border-radius: 999px;
  103. border: 1px solid #86909C;
  104. color: #4E5969;
  105. font-size: 14px;
  106. font-weight: 400;
  107. display: flex;
  108. align-items: center;
  109. justify-content: center;
  110. cursor: pointer;
  111. -webkit-tap-highlight-color: transparent;
  112. }
  113. }
  114. &__title {
  115. font-family: var(--font-title);
  116. font-size: 16px;
  117. font-weight: 600;
  118. color: #4E5969;
  119. text-align: center;
  120. }
  121. }
  122. </style>