| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- <template>
- <u-popup v-model="showPopup" @close="closePopup" mode="center" border-radius="20">
- <view class="dialog-content">
- <!-- 标题 -->
- <view v-if="title" class="dialog-title">{{ title }}</view>
- <!-- 内容插槽 -->
- <view class="dialog-body">
- <slot></slot>
- </view>
- <!-- 按钮区域 -->
- <view class="dialog-footer" :class="{ 'single-btn': !showCancel }">
- <button v-if="showCancel" class="cancel-btn" @click="handleCancel">{{ cancelText }}</button>
- <button class="confirm-btn" @click="handleConfirm">{{ confirmText }}</button>
- </view>
- </view>
- </u-popup>
- </template>
- <script>
- export default {
- props: {
- // 弹窗标题
- title: {
- type: String,
- default: '温馨提示'
- },
- // 是否显示取消按钮
- showCancel: {
- type: Boolean,
- default: true
- },
- // 确认按钮文字
- confirmText: {
- type: String,
- default: '确定'
- },
- // 取消按钮文字
- cancelText: {
- type: String,
- default: '取消'
- }
- },
- data() {
- return {
- showPopup: false
- }
- },
- methods: {
- openPopup() {
- this.showPopup = true
- },
- closePopup() {
- this.showPopup = false
- },
- handleConfirm() {
- this.$emit('confirm')
- this.closePopup()
- },
- handleCancel() {
- this.$emit('cancel')
- this.closePopup()
- }
- }
- }
- </script>
- <style lang="scss">
- .dialog-content {
- width: 580rpx;
- background: #FFFFFF;
- border-radius: 20rpx;
- overflow: hidden;
- .dialog-title {
- font-size: 32rpx;
- color: #333333;
- text-align: center;
- padding: 30rpx;
- font-family: PingFang SC;
- font-weight: bold;
- }
- .dialog-body {
- padding: 0 40rpx;
- text-align: center;
- line-height: 48rpx;
- }
- .dialog-footer {
- display: flex;
- gap: 30rpx;
- padding: 30rpx;
- padding-bottom: 40rpx;
- button {
- flex: 1;
- height: 88rpx;
- line-height: 88rpx;
- font-size: 32rpx;
- border: none;
- margin: 0;
- &::after{
- border: none;
- }
- &.cancel-btn {
- background-color: #F5F5F5;
- color: #333333;
- }
- &.confirm-btn {
- background-color: #38C148;
- color: #FFFFFF;
- }
- }
- &.single-btn {
- display: flex;
- justify-content: center;
- .confirm-btn {
- flex: 1;
- max-width: 280rpx;
- }
- }
- }
- }
- </style>
|