智慧教务系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

220 lines
3.8 KiB

<!--通用底部弹窗组件-->
<template>
<view class="bottom-popup" :class="{ 'show': visible }" @touchmove.stop.prevent>
<!-- 遮罩层 -->
<view
class="mask"
:class="{ 'show': visible }"
@click="handleMaskClick"
></view>
<!-- 弹窗内容 -->
<view class="popup-content" :class="{ 'show': visible }">
<!-- 顶部拖拽条 -->
<view class="drag-handle">
<view class="drag-line"></view>
</view>
<!-- 标题栏 -->
<view class="popup-header" v-if="title">
<view class="popup-title">{{ title }}</view>
<view class="close-btn" @click="close">
<text class="close-icon">×</text>
</view>
</view>
<!-- 滚动内容区域 -->
<scroll-view
class="popup-body"
:class="{ 'has-title': title, 'has-footer': hasFooter }"
:scroll-y="true"
:enable-passive="true"
>
<slot></slot>
</scroll-view>
<!-- 底部操作按钮区域 -->
<view class="popup-footer" v-if="hasFooter">
<slot name="footer"></slot>
</view>
</view>
</view>
</template>
<script>
export default {
name: 'BottomPopup',
props: {
// 是否显示弹窗
visible: {
type: Boolean,
default: false
},
// 弹窗标题
title: {
type: String,
default: ''
},
// 是否有底部操作区域
hasFooter: {
type: Boolean,
default: false
},
// 点击遮罩是否关闭
maskClosable: {
type: Boolean,
default: true
},
// 弹窗高度(vh单位)
height: {
type: [String, Number],
default: 70
}
},
methods: {
// 处理遮罩点击
handleMaskClick() {
if (this.maskClosable) {
this.close()
}
},
// 关闭弹窗
close() {
this.$emit('close')
}
}
}
</script>
<style lang="scss" scoped>
.bottom-popup {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
z-index: 1000;
pointer-events: none;
&.show {
pointer-events: auto;
}
}
.mask {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.5);
opacity: 0;
transition: opacity 0.3s ease;
&.show {
opacity: 1;
}
}
.popup-content {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: v-bind("`${height}vh`");
background: #2C2C2C;
border-radius: 24rpx 24rpx 0 0;
transform: translateY(100%);
transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
display: flex;
flex-direction: column;
&.show {
transform: translateY(0);
}
}
.drag-handle {
display: flex;
justify-content: center;
align-items: center;
height: 40rpx;
padding: 20rpx 0;
flex-shrink: 0;
}
.drag-line {
width: 80rpx;
height: 8rpx;
background: #666;
border-radius: 4rpx;
}
.popup-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 40rpx 20rpx;
border-bottom: 1px solid #404040;
flex-shrink: 0;
}
.popup-title {
font-size: 36rpx;
font-weight: 600;
color: #ffffff;
}
.close-btn {
width: 60rpx;
height: 60rpx;
display: flex;
align-items: center;
justify-content: center;
border-radius: 50%;
background: rgba(255, 255, 255, 0.1);
}
.close-icon {
font-size: 40rpx;
color: #ffffff;
line-height: 1;
}
.popup-body {
flex: 1;
padding: 40rpx;
overflow-y: auto;
&.has-title {
padding-top: 20rpx;
}
&.has-footer {
padding-bottom: 20rpx;
}
}
.popup-footer {
padding: 20rpx 40rpx 40rpx;
background: #2C2C2C;
border-top: 1px solid #404040;
flex-shrink: 0;
}
/* 滚动条样式 */
::-webkit-scrollbar {
width: 6rpx;
}
::-webkit-scrollbar-track {
background: transparent;
}
::-webkit-scrollbar-thumb {
background: #29D3B4;
border-radius: 3rpx;
}
</style>