buddhism/components/bottom-button/bottom-button.vue

131 lines
2.6 KiB
Vue
Raw Permalink Normal View History

2025-08-05 14:41:40 +08:00
<template>
<view class="bottom-button" :class="buttonClass" @click="handleClick">
<text class="button-text">{{ title }}</text>
</view>
</template>
<script>
2025-08-14 11:22:53 +08:00
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: '',
},
2025-08-05 14:41:40 +08:00
},
2025-08-14 11:22:53 +08:00
computed: {
buttonClass() {
return [
'bottom-button',
`bottom-button--${this.type}`,
{
'bottom-button--disabled': this.disabled,
},
this.customClass,
]
},
2025-08-05 14:41:40 +08:00
},
2025-08-14 11:22:53 +08:00
methods: {
handleClick() {
if (this.disabled) {
return
}
this.$emit('click')
},
2025-08-05 14:41:40 +08:00
},
}
</script>
<style lang="scss" scoped>
2025-08-14 11:22:53 +08:00
.bottom-button {
position: fixed;
bottom: 40rpx;
left: 75rpx;
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 {
2025-08-14 11:22:53 +08:00
color: #ffffff;
font-size: 36rpx;
font-weight: bold;
text-align: center;
}
2025-08-14 11:22:53 +08:00
// 主要按钮样式(默认)
&--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);
}
2025-08-05 14:41:40 +08:00
}
2025-08-14 11:22:53 +08:00
// 次要按钮样式
&--secondary {
background-color: #f5f0e7;
border: 2rpx solid #8b2e2e;
box-shadow: 0 4rpx 12rpx rgba(139, 46, 46, 0.1);
.button-text {
color: #8b2e2e;
}
&:active {
background-color: #f0ebe0;
transform: translateX(-50%) scale(0.98);
}
2025-08-05 14:41:40 +08:00
}
2025-08-14 11:22:53 +08:00
// 危险按钮样式
&--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);
}
2025-08-05 14:41:40 +08:00
}
2025-08-14 11:22:53 +08:00
// 禁用状态
&--disabled {
background-color: #cccccc !important;
box-shadow: none !important;
cursor: not-allowed;
.button-text {
color: #999999;
}
&:active {
transform: translateX(-50%) !important;
}
2025-08-05 14:41:40 +08:00
}
}
2025-08-14 11:22:53 +08:00
</style>