popup-dialog.vue 2.2 KB

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