popup-dialog.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <template>
  2. <uni-popup ref="popupDialog" type="dialog">
  3. <uni-popup-dialog :class="{'white':!showTitle}" @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 src="@/static/image/icon/close.png" style="width: 48rpx;height: 48rpx;" @click="CloseDialog"></image>
  10. </view>
  11. <view class="dialog_content" 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:{
  34. type: String,
  35. default: 'alert'
  36. }
  37. })
  38. const emit = defineEmits(['DialogConfirm']);
  39. //删除提示框
  40. const popupDialog = ref(null);
  41. //打开弹框
  42. const OpenDialog = () => {
  43. popupDialog.value.open();
  44. }
  45. //关闭按钮、取消按钮
  46. const CloseDialog = () => {
  47. popupDialog.value.close();
  48. }
  49. //点击dialog确定按钮触发
  50. const DialogConfirm = () => {
  51. emit('DialogConfirm')
  52. }
  53. //暴露方法被父组件调用
  54. defineExpose({
  55. OpenDialog
  56. })
  57. </script>
  58. <style scoped lang="scss">
  59. </style>