commonDialog.vue 1.4 KB

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