topfans/frontend/components/ConfirmModal.vue

329 lines
6.5 KiB
Vue

<template>
<view v-show="visible" class="modal-overlay" :class="{ 'modal-visible': visible }" @tap="handleCancel">
<view class="modal-box" @tap.stop>
<!-- 左上角关闭按钮 -->
<view class="close-btn" @tap="handleCancel">
<image class="close-icon" src="/static/starbookcontent/tuichu.png" mode="aspectFit"></image>
</view>
<!-- 右上角水晶数量 -->
<view class="crystal-badge" v-if="currentBalance">
<image class="topfans-icon" src="/static/icon/crystal.png" mode="aspectFit"></image>
<view class="card-income-text-wrap">
<text class="card-income-text">{{ currentBalance }}</text>
</view>
</view>
<!-- 标题 -->
<view v-if="title" class="modal-title">
<text>{{ title }}</text>
</view>
<!-- <view v-else class="modal-title">
<text class="modal-title-text">铸造确认</text>
</view> -->
<!-- 铸造费用信息 -->
<view v-if="costCrystal > 0" class="cost-info">
<view class="cost-row">
<text class="cost-label">本次消耗</text>
<view class="cost-num-wrap">
<text class="cost-num">{{ costCrystal }}</text>
<text class="cost-unit"> 水晶</text>
</view>
</view>
<view v-if="mintCount > 0" class="cost-row">
<text class="cost-label">铸造次数</text>
<view class="cost-num-wrap">
<text class="cost-unit">第 </text>
<text class="cost-num">{{ mintCount }}</text>
<text class="cost-unit"> 次</text>
</view>
</view>
</view>
<!-- 内容 -->
<view v-else-if="content" class="modal-body">
<text class="modal-content">{{ content }}</text>
</view>
<!-- 按钮区 -->
<view class="modal-actions">
<view class="btn btn-confirm" @tap="handleConfirm">
<text>{{ confirmText }}</text>
</view>
</view>
<!-- 下一阶段消耗提示 -->
<view v-if="nextTierCost > 0" class="next-tier-cost">
<text class="cost-text">下一阶段消耗 </text>
<text class="cost-num">{{ nextTierCost }}</text>
<text class="cost-text"> 水晶</text>
</view>
</view>
</view>
</template>
<script>
export default {
inheritAttrs: false,
};
</script>
<script setup>
const props = defineProps({
visible: {
type: Boolean,
default: false
},
title: {
type: String,
default: ''
},
content: {
type: String,
default: ''
},
confirmText: {
type: String,
default: '确认'
},
// 铸造费用信息
costCrystal: {
type: Number,
default: 0
},
currentBalance: {
type: Number,
default: 0
},
mintCount: {
type: Number,
default: 0
},
nextTierCost: {
type: Number,
default: 0
}
})
const emit = defineEmits(['confirm', 'cancel'])
function handleConfirm() {
emit('confirm', { confirm: true })
}
function handleCancel() {
emit('cancel', { confirm: false })
}
</script>
<style scoped>
.modal-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.5);
z-index: 999;
display: flex;
align-items: center;
justify-content: center;
opacity: 0;
transition: opacity 0.25s ease;
pointer-events: none;
}
.modal-overlay.modal-visible {
opacity: 1;
pointer-events: auto;
}
.modal-box {
width: 560rpx;
/* background: #fff; */
background-image: url('/static/icon/confirmbj.png');
background-size: cover;
background-position: center bottom;
border-radius: 24rpx;
overflow: visible;
padding: 48rpx 40rpx 32rpx;
display: flex;
flex-direction: column;
align-items: center;
position: relative;
}
.close-btn {
position: absolute;
top: 8rpx;
left: 8rpx;
width: 64rpx;
height: 64rpx;
z-index: 10;
padding: 10rpx;
}
.close-icon {
width: 64rpx;
height: 64rpx;
}
.crystal-badge {
position: absolute;
top: 8rpx;
right: 8rpx;
/* background: rgba(0, 0, 0, 0.5); */
/* border-radius: 20rpx; */
/* padding: 8rpx 16rpx; */
display: flex;
align-items: center;
}
.topfans-icon {
width: 56rpx;
height: 56rpx;
position: relative;
z-index: 2;
margin-right: -16rpx;
left: 20rpx;
/* top: 8rpx */
transform: rotate(-15deg);
}
.card-income-text-wrap {
width: 64rpx;
height: 32rpx;
background-image: url('@/static/square/shuijingzhanshikuang.png');
background-size: 100% 100%;
background-position: center;
display: flex;
align-items: center;
justify-content: center;
padding: 0 16rpx 0 32rpx;
}
.card-income-text {
font-size: 24rpx;
color: #fff;
font-weight: 700;
text-align: center;
}
.modal-title {
font-size: 34rpx;
font-weight: bold;
color: #fff;
margin-bottom: 32rpx;
}
.cost-info {
width: 480rpx;
/* margin-bottom: 32rpx; */
padding: 80rpx 0 32rpx;
}
.cost-row {
display: flex;
justify-content: space-between;
align-items: center;
padding: 12rpx 0;
}
.cost-label {
background-image: url('@/static/rank/activity-support-icon/beijingkuang.png');
background-size: cover;
background-position: center;
padding: 16rpx;
border-radius: 999rpx;
font-size: 28rpx;
color: #fff;
text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
}
.cost-value {
font-size: 28rpx;
color: #fff;
font-weight: 500;
text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
}
.cost-num {
font-size: 28rpx;
color: #ff9500;
font-weight: bold;
}
.cost-num-wrap {
display: flex;
align-items: center;
gap: 4rpx;
}
.cost-unit {
font-size: 28rpx;
color: #fff;
text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
}
.next-tier-cost {
margin-top: 16rpx;
padding: 12rpx 16rpx;
border-radius: 12rpx;
text-align: center;
}
.next-tier-cost .cost-text {
font-size: 24rpx;
color: #fff;
text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
}
.modal-body {
display: flex;
flex-direction: column;
align-items: center;
gap: 12rpx;
margin-bottom: 40rpx;
}
.modal-content {
font-size: 28rpx;
color: #555;
text-align: center;
white-space: pre-line;
}
.modal-actions {
width: 224rpx;
display: flex;
gap: 24rpx;
}
.btn {
flex: 1;
height: 80rpx;
border-radius: 40rpx;
display: flex;
align-items: center;
justify-content: center;
font-size: 30rpx;
}
.btn-cancel {
background: #f0f0f0;
color: #666;
}
.btn-confirm {
background: linear-gradient(to bottom right,
#F0E4B1 0%,
#F08399 50%,
#B94E73 100%);
box-shadow:
0 4rpx 12rpx rgba(255, 143, 158, 0.2),
inset 0 2rpx 4rpx rgba(255, 255, 255, 0.4);
color: #fff;
}
</style>