wechat_yxcl/components/uni-popup.vue
2020-11-12 14:57:34 +08:00

103 lines
1.7 KiB
Vue

<template>
<view >
<view class="uni-mask" v-show="show" :style="{top:offsetTop + 'px'}" @click="hide" ></view>
<view :class="['uni-popup','uni-popup-'+type]" v-show="show">
<view class="header-top" v-show="msg!=''">{{msg}}</view>
<slot></slot>
</view>
</view>
</template>
<script>
export default {
props: {
show: {
type: Boolean,
default: false
},
type: {
type: String,
//top - 顶部, middle - 居中, bottom - 底部
default: 'middle'
},
msg: {
type: String,
default: ""
}
},
data() {
let offsetTop = 0;
//#ifdef H5
offsetTop = 44;
//#endif
return {
offsetTop: offsetTop
}
},
methods: {
hide: function() {
this.$emit('hidePopup');
}
}
}
</script>
<style>
.uni-mask {
position: fixed;
z-index: 998;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: rgba(0, 0, 0, .6);
}
.uni-popup {
position: fixed;
z-index: 999;
background-color: #ffffff;
box-shadow: 0 0 30upx rgba(0, 0, 0, .1);
}
.header-top {
background-color: #5393F7;
color: #fff;
width: 100%;
/* margin-bottom: 20upx; */
text-align: center;
padding: 20upx 30upx;
}
.uni-popup-middle {
overflow: hidden;
display: flex;
flex-direction: column;
align-items: center;
min-width: 400upx;
min-height: 100upx;
border-radius: 16upx;
top: 50%;
left: 50%;
transform: translate(-50%, -65%);
justify-content: center;
padding: 0 30upx 30upx 30upx;
}
.uni-popup-top {
top: 0;
left: 0;
width: 100%;
min-height: 390upx;
line-height: 100upx;
text-align: center;
height: auto;
}
.uni-popup-bottom {
left: 0;
bottom: 0;
width: 100%;
min-height: 200upx;
line-height: 100upx;
text-align: center;
}
</style>