CustomModal.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <template>
  2. <view class="modal" v-if="visible">
  3. <view class="modal-content">
  4. <text class="mes-text">{{ message }}</text>
  5. <image :src="imageSrc" class="modal-image" mode="aspectFit" />
  6. <view class="modal-buttons">
  7. <button class="login-btn cu-btn block bg-gray lg round" @click="onCancel">取消</button>
  8. <button class="login-btn cu-btn block bg-red lg round" @click="onConfirm">确认</button>
  9. </view>
  10. </view>
  11. </view>
  12. </template>
  13. <script>
  14. export default {
  15. props: {
  16. visible: {
  17. type: Boolean,
  18. default: false
  19. },
  20. message: {
  21. type: String,
  22. default: ''
  23. },
  24. imageSrc: {
  25. type: String,
  26. default: ''
  27. }
  28. },
  29. methods: {
  30. onConfirm() {
  31. this.$emit('confirm');
  32. },
  33. onCancel() {
  34. this.$emit('cancel');
  35. }
  36. }
  37. };
  38. </script>
  39. <style>
  40. .modal {
  41. position: fixed;
  42. top: 0;
  43. left: 0;
  44. right: 0;
  45. bottom: 0;
  46. background: rgba(0, 0, 0, 0.5);
  47. display: flex;
  48. justify-content: center;
  49. align-items: center;
  50. z-index: 9999;
  51. }
  52. .modal-content {
  53. background: white;
  54. padding: 20px;
  55. border-radius: 10px;
  56. text-align: center;
  57. width: 250px;
  58. display: flex;
  59. align-items: center;
  60. flex-direction: column;
  61. }
  62. .mes-text{
  63. margin: 10px 0;
  64. }
  65. .modal-image {
  66. display: block;
  67. width: 150px;
  68. height: 150px;
  69. }
  70. .modal-buttons {
  71. margin-top: 20px;
  72. width: 100%;
  73. display: flex;
  74. justify-content: space-between;
  75. }
  76. </style>