popup-dialog.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <template>
  2. <uni-popup ref="popupDialog" type="dialog">
  3. <uni-popup-dialog :class="{'white':!showTitle,'footBorder':showFootBorder}" :showClose="showCloseBtn" :style="{'width': `${dialogWidth}rpx`}" @confirm="DialogConfirm" @close="CloseDialog">
  4. <view class="dialog_title" v-if="showTitle">
  5. <view class="dialog_title_lt">
  6. <image v-if="popType=='alert'" src="@/static/image/icon/icon_warn.png" style="width: 40rpx;height: 40rpx;"></image>
  7. <text class="title">{{title}}</text>
  8. </view>
  9. <image v-if="showDialogClose" src="@/static/image/icon/close.png" style="width: 48rpx;height: 48rpx;" @click="CloseDialog"></image>
  10. </view>
  11. <view class="dialog_content alert" v-if="popType=='alert'">{{content}}</view>
  12. <view class="dialog_content" v-else style="height: auto;"><slot></slot></view>
  13. </uni-popup-dialog>
  14. </uni-popup>
  15. </template>
  16. <script setup>
  17. import uniPopup from '@/uni_modules/uni-popup/components/uni-popup/uni-popup.vue';
  18. import uniPopupDialog from '@/uni_modules/uni-popup/components/uni-popup-dialog/uni-popup-dialog.vue';
  19. import { ref } from 'vue';
  20. const props = defineProps({
  21. showTitle:{//是否显示标题
  22. type:Boolean,
  23. default:true
  24. },
  25. title:{//标题
  26. type: String,
  27. default: '提示'
  28. },
  29. content:{//提示框内容
  30. type: String,
  31. default: ''
  32. },
  33. popType:{//custom 自定义
  34. type: String,
  35. default: 'alert'
  36. },
  37. dialogWidth:{//弹框宽度
  38. type: String,
  39. default: '610'
  40. },
  41. showDialogClose:{//是否显示关闭按钮
  42. type:Boolean,
  43. default:true
  44. },
  45. showCloseBtn:{//是否显示取消按钮
  46. type:Boolean,
  47. default:true
  48. },
  49. showFootBorder:{//foot是否显示上边框
  50. type:Boolean,
  51. default:false
  52. }
  53. })
  54. const emit = defineEmits(['DialogConfirm']);
  55. //删除提示框
  56. const popupDialog = ref(null);
  57. //打开弹框
  58. const OpenDialog = () => {
  59. popupDialog.value.open();
  60. }
  61. //关闭按钮、取消按钮
  62. const CloseDialog = () => {
  63. popupDialog.value.close();
  64. }
  65. //点击dialog确定按钮触发
  66. const DialogConfirm = () => {
  67. emit('DialogConfirm')
  68. }
  69. //暴露方法被父组件调用
  70. defineExpose({
  71. OpenDialog
  72. })
  73. </script>
  74. <style scoped lang="scss">
  75. </style>