showModal.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <template>
  2. <view class="uv-new-modal">
  3. <uv-modal ref="modal" :class="className" v-model:show="show" :title="params.title"
  4. :confirmText="params.confirmText" :cancelText="params.cancelText"
  5. :showConfirmButton="params.showConfirmButton" :showCancelButton="params.showCancelButton"
  6. :confirmColor="params.confirmColor" :cancelColor="params.cancelColor" :duration="params.duration||3000"
  7. :asyncClose="params.asyncClose" :buttonReverse="params.buttonReverse"
  8. :closeOnClickOverlay="params.closeOnClickOverlay" :confirmButtonShape="params.confirmButtonShape"
  9. @confirm="confirm" @cancel="cancel">
  10. <view class="slot-content">
  11. <view class="content">
  12. {{params.content}}
  13. </view>
  14. </view>
  15. </uv-modal>
  16. </view>
  17. </template>
  18. <script>
  19. export default {
  20. name: "uv-new-modal",
  21. data() {
  22. return {
  23. show: false,
  24. className: 'show-modal',
  25. params: {
  26. title: '提示',
  27. content: '',
  28. confirmText: '确认',
  29. cancelText: '取消',
  30. showConfirmButton: true,
  31. showCancelButton: false,
  32. confirmColor: '#1D8AF6',
  33. cancelColor: '#DCEEFF',
  34. duration: 0,
  35. zIndex: 10075,
  36. buttonReverse: false,
  37. asyncClose: false,
  38. closeOnClickOverlay: false,
  39. confirmButtonShape: '',
  40. }
  41. };
  42. },
  43. methods: {
  44. open(params) {
  45. this.params = Object.assign({}, this.params, params)
  46. //console.log(this.params);
  47. this.show = true;
  48. // this.$refs.modal.close();
  49. this.$refs.modal.open();
  50. },
  51. close() {
  52. this.show = false;
  53. this.$refs.modal.close();
  54. },
  55. confirm(e) {
  56. if (typeof(this.params.confirm) != 'undefined') {
  57. this.params.confirm(e);
  58. }
  59. this.$emit('confirm', e);
  60. this.$refs.modal.close();
  61. },
  62. cancel(e) {
  63. this.$refs.modal.close();
  64. if (typeof(this.params.cancel) != 'undefined') {
  65. this.params.cancel(e);
  66. }
  67. this.$emit('cancel', e);
  68. },
  69. }
  70. }
  71. </script>
  72. <style lang="scss" scoped>
  73. .uv-new-modal {
  74. .slot-content {
  75. text-align: center;
  76. color: #999;
  77. padding: 1rem 0;
  78. }
  79. .uv-popup {
  80. color: var(--color);
  81. ::v-deep .uv-modal {
  82. border-radius: .5rem;
  83. .uv-modal__title {
  84. color: var(--modal-title-color);
  85. font-size: 1rem;
  86. font-weight: normal;
  87. }
  88. .uv-modal__button-group {
  89. height: auto;
  90. ::v-deep .uv-modal__button-group__wrapper--confirm {
  91. background: var(--color);
  92. color: #fff;
  93. margin: .75rem 1.75rem .75rem .875rem;
  94. border-radius: .5rem;
  95. .uv-modal__button-group__wrapper__text {
  96. color: #fff !important;
  97. }
  98. }
  99. .uv-modal__button-group__wrapper--cancel {
  100. background: #DCEEFF;
  101. background-color: transparent;
  102. color: var(--color);
  103. margin: .75rem .875rem .75rem 1.75rem;
  104. border-radius: .5rem;
  105. .uv-modal__button-group__wrapper__text {
  106. color: var(--color) !important;
  107. }
  108. }
  109. .uv-modal__button-group__wrapper--only-confirm {
  110. background: var(--color);
  111. color: #fff;
  112. margin: .75rem 1.75rem;
  113. border-radius: .5rem;
  114. .uv-modal__button-group__wrapper__text {
  115. color: #fff !important;
  116. }
  117. }
  118. }
  119. }
  120. }
  121. }
  122. </style>