2025-07-24 10:05:17 +08:00
|
|
|
|
<template>
|
2025-08-04 15:49:17 +08:00
|
|
|
|
<view class="agreement-mask" v-if="show" @click.stop="closePopup">
|
|
|
|
|
<!-- 弹窗主体:支持自定义边框、背景 -->
|
|
|
|
|
<view
|
|
|
|
|
class="agreement-popup"
|
|
|
|
|
@click.stop
|
|
|
|
|
:style="{
|
|
|
|
|
border: popupBorder,
|
|
|
|
|
backgroundColor: popupBg,
|
|
|
|
|
borderRadius: popupRadius
|
|
|
|
|
}"
|
|
|
|
|
:class="popupClass"
|
|
|
|
|
>
|
2025-08-02 16:32:48 +08:00
|
|
|
|
<view class="popup-content">
|
2025-08-04 15:49:17 +08:00
|
|
|
|
<!-- 动态图标:支持自定义大小、边距 -->
|
|
|
|
|
<image
|
|
|
|
|
v-if="showIcon && icon"
|
|
|
|
|
:src="icon"
|
|
|
|
|
mode="aspectFit"
|
|
|
|
|
class="svg"
|
|
|
|
|
:style="iconStyle"
|
|
|
|
|
></image>
|
|
|
|
|
|
2025-08-02 16:32:48 +08:00
|
|
|
|
<view class="text-content">
|
2025-08-04 15:49:17 +08:00
|
|
|
|
<!-- 动态标题:支持自定义颜色、字体大小 -->
|
|
|
|
|
<view
|
|
|
|
|
class="popup-Title"
|
|
|
|
|
v-if="title"
|
|
|
|
|
:style="{
|
|
|
|
|
color: titleColor,
|
|
|
|
|
fontSize: titleSize,
|
|
|
|
|
padding: titlePadding
|
|
|
|
|
}"
|
|
|
|
|
>
|
|
|
|
|
{{ title }}
|
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
<!-- 动态消息内容:支持自定义颜色、换行、字体大小 -->
|
|
|
|
|
<view
|
|
|
|
|
class="popup-Message"
|
|
|
|
|
v-if="message"
|
|
|
|
|
:style="{
|
|
|
|
|
color: messageColor,
|
|
|
|
|
fontSize: messageSize,
|
|
|
|
|
whiteSpace: messageWrap ? 'normal' : 'nowrap',
|
|
|
|
|
padding: messagePadding
|
|
|
|
|
}"
|
|
|
|
|
>
|
|
|
|
|
{{ message }}
|
|
|
|
|
</view>
|
2025-08-02 16:32:48 +08:00
|
|
|
|
</view>
|
|
|
|
|
</view>
|
2025-08-04 15:49:17 +08:00
|
|
|
|
|
|
|
|
|
<!-- 按钮组:支持自定义按钮样式 -->
|
|
|
|
|
<view class="popup-buttons" :style="{ marginTop: buttonGroupMargin }">
|
|
|
|
|
<button
|
|
|
|
|
v-if="showCancel"
|
|
|
|
|
class="btn cancelBtn"
|
|
|
|
|
@click="handleCancel"
|
|
|
|
|
:style="{
|
|
|
|
|
border: cancelBtnBorder,
|
|
|
|
|
color: cancelBtnColor,
|
|
|
|
|
backgroundColor: cancelBtnBg,
|
|
|
|
|
fontSize: cancelBtnSize,
|
|
|
|
|
borderRadius: buttonRadius,
|
|
|
|
|
margin: buttonMargin
|
|
|
|
|
}"
|
|
|
|
|
:class="cancelBtnClass"
|
|
|
|
|
>
|
|
|
|
|
{{ cancelText }}
|
|
|
|
|
</button>
|
|
|
|
|
|
|
|
|
|
<button
|
|
|
|
|
class="btn agreeBtn"
|
|
|
|
|
@click="handleConfirm"
|
|
|
|
|
:style="{
|
|
|
|
|
backgroundColor: confirmBtnBg,
|
|
|
|
|
color: confirmBtnColor,
|
|
|
|
|
fontSize: confirmBtnSize,
|
|
|
|
|
borderRadius: buttonRadius,
|
|
|
|
|
margin: buttonMargin
|
|
|
|
|
}"
|
|
|
|
|
:class="confirmBtnClass"
|
|
|
|
|
>
|
|
|
|
|
{{ confirmText }}
|
|
|
|
|
</button>
|
2025-08-02 16:32:48 +08:00
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
2025-07-24 10:05:17 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2025-08-02 16:32:48 +08:00
|
|
|
|
export default {
|
2025-08-04 15:49:17 +08:00
|
|
|
|
name: 'CustomPopup',
|
2025-08-02 16:32:48 +08:00
|
|
|
|
props: {
|
2025-08-04 15:49:17 +08:00
|
|
|
|
// 基础控制
|
2025-08-02 16:32:48 +08:00
|
|
|
|
show: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
default: false
|
|
|
|
|
},
|
|
|
|
|
title: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: ''
|
|
|
|
|
},
|
|
|
|
|
message: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: ''
|
|
|
|
|
},
|
|
|
|
|
confirmText: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: '确定'
|
|
|
|
|
},
|
|
|
|
|
cancelText: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: '取消'
|
|
|
|
|
},
|
|
|
|
|
showCancel: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
default: false
|
|
|
|
|
},
|
|
|
|
|
showIcon: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
default: true
|
|
|
|
|
},
|
|
|
|
|
icon: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: ''
|
|
|
|
|
},
|
2025-08-04 15:49:17 +08:00
|
|
|
|
// 文本换行控制
|
|
|
|
|
messageWrap: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
default: false // 默认不换行,true则自动换行
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 弹窗样式自定义
|
|
|
|
|
popupBorder: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: '1px solid rgba(187, 230, 0, 0.3)'
|
|
|
|
|
},
|
|
|
|
|
popupBg: {
|
|
|
|
|
type: String,
|
2025-08-05 19:02:04 +08:00
|
|
|
|
default: 'rgb(42, 42, 42, 0.9)'
|
2025-08-04 15:49:17 +08:00
|
|
|
|
},
|
|
|
|
|
popupRadius: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: '40rpx'
|
|
|
|
|
},
|
|
|
|
|
popupClass: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: ''
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 标题样式自定义
|
|
|
|
|
titleColor: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: 'rgba(255, 255, 255, 0.86)'
|
|
|
|
|
},
|
|
|
|
|
titleSize: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: '32rpx'
|
|
|
|
|
},
|
|
|
|
|
titlePadding: {
|
|
|
|
|
type: String,
|
2025-08-04 17:48:03 +08:00
|
|
|
|
default: '10rpx 0 10rpx'
|
2025-08-04 15:49:17 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 消息样式自定义
|
|
|
|
|
messageColor: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: 'rgba(255, 255, 255, 0.7)'
|
|
|
|
|
},
|
|
|
|
|
messageSize: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: '28rpx'
|
|
|
|
|
},
|
|
|
|
|
messagePadding: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: '10rpx 20rpx 30rpx'
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 图标样式自定义
|
2025-08-02 16:32:48 +08:00
|
|
|
|
iconStyle: {
|
|
|
|
|
type: Object,
|
|
|
|
|
default: () => ({
|
2025-08-04 15:49:17 +08:00
|
|
|
|
width: '72rpx',
|
|
|
|
|
height: '60rpx',
|
2025-08-02 16:32:48 +08:00
|
|
|
|
marginBottom: '20rpx'
|
|
|
|
|
})
|
2025-08-04 15:49:17 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 按钮组样式
|
|
|
|
|
buttonGroupMargin: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: '20rpx'
|
|
|
|
|
},
|
|
|
|
|
buttonRadius: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: '40rpx'
|
|
|
|
|
},
|
|
|
|
|
buttonMargin: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: '0 10rpx'
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 确认按钮样式
|
|
|
|
|
confirmBtnBg: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: 'rgba(187, 230, 0, 1)'
|
|
|
|
|
},
|
|
|
|
|
confirmBtnColor: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: '#232323'
|
|
|
|
|
},
|
|
|
|
|
confirmBtnSize: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: '24rpx'
|
|
|
|
|
},
|
|
|
|
|
confirmBtnClass: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: ''
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 取消按钮样式
|
|
|
|
|
cancelBtnBorder: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: '1px solid rgba(255, 255, 255, 0.3)'
|
|
|
|
|
},
|
|
|
|
|
cancelBtnColor: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: 'rgba(255, 255, 255, 0.7)'
|
|
|
|
|
},
|
|
|
|
|
cancelBtnBg: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: 'transparent'
|
|
|
|
|
},
|
|
|
|
|
cancelBtnSize: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: '24rpx'
|
|
|
|
|
},
|
|
|
|
|
cancelBtnClass: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: ''
|
2025-08-02 16:32:48 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
handleConfirm() {
|
|
|
|
|
this.$emit('confirm')
|
|
|
|
|
this.$emit('update:show', false)
|
|
|
|
|
},
|
|
|
|
|
handleCancel() {
|
|
|
|
|
this.$emit('cancel')
|
|
|
|
|
this.$emit('update:show', false)
|
|
|
|
|
},
|
|
|
|
|
closePopup() {
|
|
|
|
|
this.$emit('close')
|
|
|
|
|
this.$emit('update:show', false)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-07-24 10:05:17 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
2025-08-04 15:49:17 +08:00
|
|
|
|
/* 遮罩层:全屏覆盖 */
|
2025-08-02 16:32:48 +08:00
|
|
|
|
.agreement-mask {
|
|
|
|
|
position: fixed;
|
|
|
|
|
top: 0;
|
|
|
|
|
left: 0;
|
|
|
|
|
right: 0;
|
|
|
|
|
bottom: 0;
|
2025-08-05 19:02:04 +08:00
|
|
|
|
background-color: rgba(0, 0, 0, 0.7);
|
2025-08-02 16:32:48 +08:00
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
align-items: center;
|
|
|
|
|
z-index: 9999;
|
|
|
|
|
}
|
2025-07-24 10:05:17 +08:00
|
|
|
|
|
2025-08-04 15:49:17 +08:00
|
|
|
|
/* 弹窗主体:基础样式 */
|
2025-08-02 16:32:48 +08:00
|
|
|
|
.agreement-popup {
|
|
|
|
|
width: 66%;
|
|
|
|
|
padding: 30rpx;
|
|
|
|
|
text-align: center;
|
|
|
|
|
}
|
2025-07-24 10:05:17 +08:00
|
|
|
|
|
2025-08-04 15:49:17 +08:00
|
|
|
|
/* 内容区域布局 */
|
2025-08-02 16:32:48 +08:00
|
|
|
|
.popup-content {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
align-items: center;
|
|
|
|
|
}
|
2025-07-24 10:05:17 +08:00
|
|
|
|
|
2025-08-02 16:32:48 +08:00
|
|
|
|
.text-content {
|
|
|
|
|
width: 100%;
|
|
|
|
|
}
|
2025-07-24 10:05:17 +08:00
|
|
|
|
|
2025-08-04 15:49:17 +08:00
|
|
|
|
/* 按钮基础样式(不包含可变样式) */
|
2025-08-02 16:32:48 +08:00
|
|
|
|
.popup-buttons {
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
}
|
2025-07-24 10:05:17 +08:00
|
|
|
|
|
2025-08-02 16:32:48 +08:00
|
|
|
|
.btn {
|
|
|
|
|
height: 60rpx;
|
|
|
|
|
line-height: 60rpx;
|
|
|
|
|
padding: 0 30rpx;
|
|
|
|
|
min-width: 170rpx;
|
|
|
|
|
border: none;
|
|
|
|
|
}
|
2025-07-24 10:05:17 +08:00
|
|
|
|
|
2025-08-04 15:49:17 +08:00
|
|
|
|
/* 解决按钮默认样式冲突 */
|
|
|
|
|
.btn::after {
|
|
|
|
|
border: none;
|
2025-08-02 16:32:48 +08:00
|
|
|
|
}
|
2025-07-24 10:05:17 +08:00
|
|
|
|
</style>
|