mrr.sj.front/pages/search/components/confirm-modal.vue

122 lines
2.3 KiB
Vue
Raw Normal View History

2026-03-24 11:45:13 +08:00
<template>
<view class="confirm-modal" v-if="visible">
<!-- 遮罩层点击关闭弹窗 -->
<view class="modal-mask" @click="handleCancel"></view>
<!-- 弹窗内容区 -->
<view class="modal-content">
<view class="modal-title">{{ title }}</view>
<view class="modal-buttons">
<view class="button cancel" @click="handleCancel">{{
cancelText
}}</view>
<view class="button delete" @click="handleConfirm">{{
confirmText
}}</view>
</view>
</view>
</view>
</template>
<script>
export default {
props: {
visible: Boolean, // 控制弹窗显示/隐藏
title: {
type: String,
default: "提示",
},
desc: {
type: String,
default: "确认执行操作吗?",
},
cancelText: {
type: String,
default: "取消",
},
confirmText: {
type: String,
default: "确认",
},
},
methods: {
handleCancel() {
this.$emit("cancel"); // 触发“取消”事件,通知父组件
},
handleConfirm() {
this.$emit("confirm"); // 触发“确认”事件,通知父组件
},
},
};
</script>
<style scoped lang="less">
.confirm-modal {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
z-index: 999; /* 保证弹窗在最上层 */
}
.modal-mask {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5); /* 半透明遮罩 */
}
.modal-content {
position: relative;
width: 554rpx;
height: 232rpx;
background-color: #fff;
border-radius: 20rpx;
padding: 54rpx 0rpx 0 0;
box-sizing: border-box;
display: flex;
flex-direction: column;
align-items: center;
}
.modal-title {
font-weight: 500;
font-size: 32rpx;
color: #333333;
margin-bottom: 40rpx;
}
.modal-buttons {
display: flex;
width: 100%;
height: 45rpx;
line-height: 45rpx;
justify-content: space-around;
border-top: 2rpx solid #dedede;
}
.button {
font-size: 32rpx;
color: #999999;
height: 45rpx;
width: 50%;
text-align: center;
line-height: 45rpx;
padding: 23rpx 0;
}
.cancel {
padding-right: 0.5rpx;
border-right: 2rpx solid #dedede;
}
.delete {
color: #e8101e;
}
</style>