commonDialog.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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="showNotBtn" @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. showNotBtn: {
  34. type: Boolean,
  35. default: true
  36. },
  37. notBtn: {
  38. type: String,
  39. default: '取消'
  40. },
  41. okBtn: {
  42. type: String,
  43. require: true,
  44. default: '确认'
  45. },
  46. });
  47. const commonPopup = ref(null); // 索引
  48. const $emit = defineEmits(['confirm-btn'])
  49. // 打开弹窗
  50. function handleShow() {
  51. commonPopup.value.open();
  52. }
  53. // 取消
  54. function handleClose() {
  55. commonPopup.value.close();
  56. }
  57. // 确认
  58. function confirmBtn(){
  59. $emit('confirm-btn');
  60. commonPopup.value.close();
  61. }
  62. defineExpose({
  63. handleShow,
  64. handleClose
  65. })
  66. </script>
  67. <style>
  68. </style>