| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- <template>
- <!-- 自定义弹框组件 -->
- <uni-popup ref="popupDialog">
- <view class="dialog_wrap" :style="{ width: `${dialogWidth}rpx` }">
- <view class="dialog_title" v-if="showTitle">
- <view class="dialog_title_lt">
- <text class="title">{{title}}</text>
- </view>
- <image v-if="showDialogClose" src="@/static/image/icon/close.png" style="width: 48rpx;height: 48rpx;"
- @click="CloseDialog"></image>
- </view>
- <view class="dialog_content">
- <slot></slot>
- </view>
- <!-- 自定义底部按钮区域 -->
- <view class="dialog_footer" v-if="showDialogFooter">
- <view v-if="showCloseBtn" class="dialog-btn cancel-btn" @click="CloseDialog">取消</view>
- <view class="dialog-btn confirm-btn" @click="handleConfirm">确定</view>
- </view>
- </view>
- </uni-popup>
- </template>
- <script setup>
- import uniPopup from '@/uni_modules/uni-popup/components/uni-popup/uni-popup.vue';
- import {
- ref
- } from 'vue';
- const props = defineProps({
- showTitle: {//显示标题
- type: Boolean,
- default: true
- },
- title: {//标题
- type: String,
- default: '提示'
- },
- dialogWidth: {//弹框宽度
- type: String,
- default: '610'
- },
- showDialogClose: {//关闭按钮
- type: Boolean,
- default: true
- },
- showDialogFooter:{//是否显示底部按钮
- type: Boolean,
- default: true
- },
- showCloseBtn: {//是否显示取消按钮
- type: Boolean,
- default: true
- }
- })
- const emit = defineEmits(['DialogConfirm']);
- const popupDialog = ref(null);
- //打开弹窗
- const OpenDialog = () => {
- popupDialog.value.open();
- }
- //关闭弹窗
- const CloseDialog = () => {
- popupDialog.value.close();
- }
- // 点击确定,只通知父组件,子组件不主动关闭!
- const handleConfirm = () => {
- emit('DialogConfirm')
- }
- defineExpose({
- OpenDialog,
- CloseDialog
- })
- </script>
- <style scoped lang="scss">
- .dialog_wrap {
- background: #fff;
- border-radius: 20rpx;
- overflow: hidden;
- }
- .dialog_title {
- height: 96rpx;
- padding: 0 40rpx;
- width: 100%;
- background-color: #F5F7FA;
- border-radius: 20rpx 20rpx 0 0;
- box-sizing: border-box;
- display: flex;
- justify-content: space-between;
- align-items: center;
- .dialog_title_lt {
- display: inline-flex;
- align-items: center;
- .title {
- margin-left: 16rpx;
- flex: 1;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- color: #303133;
- font-weight: 500;
- font-size: 32rpx;
- }
- }
- }
- .dialog_content {
- min-height: 160rpx;
- height: auto;
- display: flex;
- // overflow: auto;
- width: 100%;
- box-sizing: border-box;
- padding: 40rpx;
- flex-wrap: wrap;
- }
- .dialog_footer {
- display: flex;
- border: 2rpx solid #EBEEF5;
- padding: 24rpx 40rpx;
- width: 100%;
- box-sizing: border-box;
- gap: 20rpx;
- .dialog-btn {
- flex: 1;
- display: inline-flex;
- align-items: center;
- justify-content: center;
- height: 80rpx;
-
- border-radius: 12rpx;
- font-size: 28rpx;
- font-weight: 500;
- }
- .cancel-btn {
- color: #606266;
- background-color: #f0f2f9;
- }
- .confirm-btn {
- color: #ffffff;
- background-color: #2e64fa;
- }
- }
- </style>
|