| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- <template>
- <view v-if="visible" class="modal-overlay" @click.stop="handleOverlayClick">
- <view class="modal-container" @click.stop>
- <view class="modal-title">{{ title }}</view>
- <view class="modal-content">{{ content }}</view>
- <view class="modal-footer">
- <view v-if="showCancel" class="modal-btn cancel-btn" @click="handleCancel">
- {{ cancelText }}
- </view>
- <view class="modal-btn confirm-btn" @click="handleConfirm">
- {{ confirmText }}
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- name: 'CustomModal',
- props: {
- visible: {
- type: Boolean,
- default: false
- },
- title: {
- type: String,
- default: '提示'
- },
- content: {
- type: String,
- default: ''
- },
- showCancel: {
- type: Boolean,
- default: false
- },
- cancelText: {
- type: String,
- default: '取消'
- },
- confirmText: {
- type: String,
- default: '确定'
- }
- },
- methods: {
- handleConfirm() {
- this.$emit('confirm')
- },
- handleCancel() {
- this.$emit('cancel')
- },
- handleOverlayClick() {
- // 点击遮罩层不做任何操作,防止误触
- }
- }
- }
- </script>
- <style scoped>
- .modal-overlay {
- position: fixed;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- background-color: rgba(0, 0, 0, 0.6);
- display: flex;
- align-items: center;
- justify-content: center;
- z-index: 9999;
- }
- .modal-container {
- width: 600rpx;
- background-color: #fff;
- border-radius: 16rpx;
- overflow: hidden;
- }
- .modal-title {
- padding: 40rpx 40rpx 20rpx;
- font-size: 36rpx;
- font-weight: 600;
- color: #333;
- text-align: center;
- }
- .modal-content {
- padding: 20rpx 40rpx 40rpx;
- font-size: 32rpx;
- color: #666;
- text-align: center;
- line-height: 1.6;
- }
- .modal-footer {
- display: flex;
- border-top: 1rpx solid #e5e5e5;
- }
- .modal-btn {
- flex: 1;
- padding: 30rpx;
- font-size: 34rpx;
- text-align: center;
- color: #333;
- }
- .cancel-btn {
- border-right: 1rpx solid #e5e5e5;
- color: #666;
- }
- .confirm-btn {
- color: #576b95;
- font-weight: 500;
- }
- </style>
|