底部组件封装

This commit is contained in:
minimaxagent1 2025-08-05 14:41:40 +08:00
parent bafeb4736f
commit d8a9d75580
2 changed files with 133 additions and 25 deletions

View File

@ -0,0 +1,126 @@
<template>
<view class="bottom-button" :class="buttonClass" @click="handleClick">
<text class="button-text">{{ title }}</text>
</view>
</template>
<script>
export default {
name: 'BottomButton',
props: {
//
title: {
type: String,
default: '确认'
},
// primary(), secondary(), danger()
type: {
type: String,
default: 'primary',
validator: value => ['primary', 'secondary', 'danger'].includes(value)
},
//
disabled: {
type: Boolean,
default: false
},
//
customClass: {
type: String,
default: ''
}
},
computed: {
buttonClass() {
return [
'bottom-button',
`bottom-button--${this.type}`,
{
'bottom-button--disabled': this.disabled
},
this.customClass
]
}
},
methods: {
handleClick() {
if (this.disabled) {
return
}
this.$emit('click')
}
}
}
</script>
<style lang="scss" scoped>
.bottom-button {
position: fixed;
bottom: 40rpx;
left: 50%;
transform: translateX(-50%);
width: 600rpx;
height: 100rpx;
border-radius: 50rpx;
display: flex;
justify-content: center;
align-items: center;
z-index: 10;
transition: all 0.3s ease;
.button-text {
color: #FFFFFF;
font-size: 36rpx;
font-weight: bold;
text-align: center;
}
//
&--primary {
background-color: #8B2E2E;
box-shadow: 0 8rpx 20rpx rgba(139, 46, 46, 0.3);
&:active {
background-color: #7A2A2A;
transform: translateX(-50%) scale(0.98);
}
}
//
&--secondary {
background-color: #6C757D;
box-shadow: 0 8rpx 20rpx rgba(108, 117, 125, 0.3);
&:active {
background-color: #5A6268;
transform: translateX(-50%) scale(0.98);
}
}
//
&--danger {
background-color: #DC3545;
box-shadow: 0 8rpx 20rpx rgba(220, 53, 69, 0.3);
&:active {
background-color: #C82333;
transform: translateX(-50%) scale(0.98);
}
}
//
&--disabled {
background-color: #CCCCCC !important;
box-shadow: none !important;
cursor: not-allowed;
.button-text {
color: #999999;
}
&:active {
transform: translateX(-50%) !important;
}
}
}
</style>

View File

@ -72,9 +72,11 @@
</view> </view>
</view> </view>
<!-- 敬香按钮 --> <!-- 敬香按钮 -->
<view class="incense-button" @click="submitPrayer"> <bottom-button
<text class="button-text">敬香</text> title="敬香"
</view> type="primary"
@click="submitPrayer"
/>
</view> </view>
</view> </view>
</template> </template>
@ -82,11 +84,13 @@
<script> <script>
import CommonEnum from "../../enum/common"; import CommonEnum from "../../enum/common";
import CustomNavbar from "../../components/custom-navbar/custom-navbar.vue"; import CustomNavbar from "../../components/custom-navbar/custom-navbar.vue";
import BottomButton from "../../components/bottom-button/bottom-button.vue";
import { submitPrayer } from "@/api/pray/pray"; import { submitPrayer } from "@/api/pray/pray";
export default { export default {
components: { components: {
CustomNavbar, CustomNavbar,
BottomButton,
}, },
data() { data() {
return { return {
@ -458,26 +462,4 @@ page {
color: #999; color: #999;
} }
} }
.incense-button {
position: fixed;
bottom: 40rpx;
left: 50%;
transform: translateX(-50%);
width: 600rpx;
height: 100rpx;
background-color: #8B2E2E;
border-radius: 50rpx;
display: flex;
justify-content: center;
align-items: center;
z-index: 10;
.button-text {
color: #FFFFFF;
font-size: 36rpx;
font-weight: bold;
text-align: center;
}
}
</style> </style>