customPopupDialog.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <template>
  2. <!-- 自定义弹框组件 -->
  3. <uni-popup ref="popupDialog" :is-mask-click="isMaskClick" style="z-index: 99999;">
  4. <view :class="['dialog_wrap',popupType]" :style="{ width: popupType=='center'?`${dialogWidth}rpx`:'100%' }">
  5. <view class="dialog_title" v-if="showTitle">
  6. <view class="dialog_title_lt">
  7. <text class="title">{{title}}</text>
  8. </view>
  9. <image v-if="showDialogClose" src="@/static/image/icon/close.png" style="width: 48rpx;height: 48rpx;"
  10. @click="CloseDialog"></image>
  11. </view>
  12. <view class="dialog_content">
  13. <slot></slot>
  14. </view>
  15. <!-- 自定义底部按钮区域 -->
  16. <view class="dialog_footer" v-if="showDialogFooter">
  17. <view v-if="showCancelBtn" class="dialog-btn cancel-btn" @click="CloseDialog">取消</view>
  18. <view class="dialog-btn confirm-btn" @click="handleConfirm">确定</view>
  19. </view>
  20. </view>
  21. </uni-popup>
  22. </template>
  23. <script setup>
  24. import uniPopup from '@/uni_modules/uni-popup/components/uni-popup/uni-popup.vue';
  25. import {
  26. ref
  27. } from 'vue';
  28. const props = defineProps({
  29. showTitle: {//显示标题
  30. type: Boolean,
  31. default: true
  32. },
  33. title: {//标题
  34. type: String,
  35. default: '提示'
  36. },
  37. dialogWidth: {//弹框宽度
  38. type: String,
  39. default: '610'
  40. },
  41. isMaskClick:{//蒙版点击是否关闭弹窗
  42. type: Boolean,
  43. default: true
  44. },
  45. showDialogClose: {//关闭按钮
  46. type: Boolean,
  47. default: true
  48. },
  49. showDialogFooter:{//是否显示底部按钮
  50. type: Boolean,
  51. default: true
  52. },
  53. showCancelBtn: {//是否显示取消按钮
  54. type: Boolean,
  55. default: true
  56. }
  57. })
  58. const emit = defineEmits(['DialogConfirm','DialogClose']);
  59. const popupDialog = ref(null);
  60. const popupType = ref('center');//弹出方式 默认中间显示
  61. //打开弹窗
  62. const OpenDialog = (type='center') => {
  63. popupType.value = type;//弹出方式
  64. popupDialog.value.open(type);
  65. }
  66. //关闭弹窗
  67. const CloseDialog = () => {
  68. popupDialog.value.close();
  69. emit('DialogClose')
  70. }
  71. // 点击确定,只通知父组件,子组件不主动关闭!
  72. const handleConfirm = () => {
  73. emit('DialogConfirm')
  74. }
  75. defineExpose({
  76. OpenDialog,
  77. CloseDialog
  78. })
  79. </script>
  80. <style scoped lang="scss">
  81. .dialog_wrap {
  82. background: #fff;
  83. border-radius: 20rpx;
  84. overflow: hidden;
  85. &.bottom{//从底部弹框
  86. border-radius: 40rpx 40rpx 0 0;
  87. .dialog_title{
  88. background-color: #FFFFFF;
  89. justify-content: center;
  90. .dialog_title_lt {
  91. .title {
  92. color: #000000;
  93. font-size: 36rpx;
  94. margin-left: 0;
  95. }
  96. }
  97. }
  98. .dialog_content{
  99. padding: 0;
  100. min-height: auto;
  101. }
  102. }
  103. }
  104. .dialog_title {
  105. height: 96rpx;
  106. padding: 0 40rpx;
  107. width: 100%;
  108. background-color: #F5F7FA;
  109. border-radius: 20rpx 20rpx 0 0;
  110. box-sizing: border-box;
  111. display: flex;
  112. justify-content: space-between;
  113. align-items: center;
  114. .dialog_title_lt {
  115. display: inline-flex;
  116. align-items: center;
  117. .title {
  118. margin-left: 16rpx;
  119. flex: 1;
  120. white-space: nowrap;
  121. overflow: hidden;
  122. text-overflow: ellipsis;
  123. color: #303133;
  124. font-weight: 500;
  125. font-size: 32rpx;
  126. }
  127. }
  128. }
  129. .dialog_content {
  130. min-height: 160rpx;
  131. height: auto;
  132. display: flex;
  133. // overflow: auto;
  134. width: 100%;
  135. box-sizing: border-box;
  136. padding: 40rpx;
  137. flex-wrap: wrap;
  138. }
  139. .dialog_footer {
  140. display: flex;
  141. border: 2rpx solid #EBEEF5;
  142. padding: 24rpx 40rpx;
  143. width: 100%;
  144. box-sizing: border-box;
  145. gap: 20rpx;
  146. .dialog-btn {
  147. flex: 1;
  148. display: inline-flex;
  149. align-items: center;
  150. justify-content: center;
  151. height: 80rpx;
  152. border-radius: 12rpx;
  153. font-size: 28rpx;
  154. font-weight: 500;
  155. }
  156. .cancel-btn {
  157. color: #606266;
  158. background-color: #f0f2f9;
  159. }
  160. .confirm-btn {
  161. color: #ffffff;
  162. background-color: #2e64fa;
  163. }
  164. }
  165. </style>