commonDialog.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <template>
  2. <uni-popup ref="commonPopup" :animation="false" :is-mask-click="false"
  3. mask-background-color="rgba(0, 0, 0, 0.4)">
  4. <view class="phone-common-dialog">
  5. <view class="common-body-box">
  6. <view class="common-title">{{title}}</view>
  7. <view class="common-content" :class="dialogContentClass">{{content}}</view>
  8. <view class="common-btn-box">
  9. <view class="not-confirm-btn" v-if="showQuxiao" @click="handleClose">{{notBtn}}</view>
  10. <view class="confirm-btn" @click="confirmBtn">{{okBtn}}</view>
  11. </view>
  12. </view>
  13. </view>
  14. </uni-popup>
  15. </template>
  16. <script setup>
  17. import { ref } from 'vue';
  18. const props = defineProps({
  19. title: {
  20. type: String,
  21. default: ''
  22. },
  23. content: {
  24. type: String,
  25. require: true,
  26. default: ''
  27. },
  28. dialogContentClass: {
  29. type: String,
  30. require: true,
  31. default: 'content-center-class'
  32. },
  33. showQuxiao: {
  34. type: Boolean,
  35. default: true
  36. },
  37. notBtn: {
  38. type: String,
  39. require: true,
  40. default: '取消'
  41. },
  42. okBtn: {
  43. type: String,
  44. require: true,
  45. default: '确认'
  46. },
  47. });
  48. const commonPopup = ref(null); // 索引
  49. const $emit = defineEmits(['confirm-btn'])
  50. // 打开弹窗
  51. function handleShow() {
  52. commonPopup.value.open();
  53. }
  54. // 取消
  55. function handleClose() {
  56. commonPopup.value.close();
  57. }
  58. // 确认
  59. function confirmBtn(){
  60. $emit('confirm-btn');
  61. commonPopup.value.close();
  62. }
  63. defineExpose({
  64. handleShow,
  65. handleClose
  66. })
  67. </script>
  68. <style>
  69. </style>