|
@@ -1,8 +1,8 @@
|
|
|
<template>
|
|
|
<div class="toast-wrap">
|
|
|
- <p v-show="val" :class="['tab',{'check':val != '请选择'}]" @click="showPicker">{{val}}</p>
|
|
|
+ <p v-show="val" :class="['ptab',{'check':val != '请选择'}]" @click="showPicker">{{val}}</p>
|
|
|
<p v-show="val != '请选择'" class="tip">点击可修改</p>
|
|
|
- <div class="content" v-show="show">
|
|
|
+ <div class="content pc" v-show="show">
|
|
|
<van-picker
|
|
|
:columns="columns"
|
|
|
:visible-item-count='3'
|
|
@@ -44,9 +44,21 @@
|
|
|
show:false
|
|
|
}
|
|
|
},
|
|
|
- props:['item'],
|
|
|
+ props:['item','outBoxClass'],
|
|
|
methods: {
|
|
|
showPicker(){
|
|
|
+ const winH = $(window).height();
|
|
|
+ // outBoxClass 外层盒子的类名,用以获取高度
|
|
|
+ const HH = $("."+this.outBoxClass).height();
|
|
|
+ const pH = $('.ptab').offset().top;//时间组件距离顶部的高度
|
|
|
+ const btH = winH - pH;console.log("可视区高度:",winH,"时间距顶部的高度:",pH,"差值:",winH-pH) //距离底部的距离
|
|
|
+ // 如果底部距离小于弹窗的高度227px + 44,就显示在上方,否则显示下方
|
|
|
+ // ios和华为底部会有浏览器自带的箭头,故多减30
|
|
|
+ if(btH < 271){
|
|
|
+ $('.pc').css('bottom','.88rem');
|
|
|
+ }else{
|
|
|
+ $('.pc').css('top','.88rem')
|
|
|
+ }
|
|
|
this.show = true;
|
|
|
this.$emit('forbidS'); //禁止滚动
|
|
|
},
|
|
@@ -58,7 +70,8 @@
|
|
|
this.show = false;
|
|
|
const newData = Object.assign({},this.item,{value:this.val,valueP:this.val});
|
|
|
this.$emit("updata",newData);
|
|
|
- this.$emit('resetS'); //恢复滚动
|
|
|
+ const pH = $('.ptab').offset().top;//恢复滚动的位置
|
|
|
+ this.$emit('resetS',pH); //恢复滚动
|
|
|
},
|
|
|
}
|
|
|
};
|
|
@@ -68,7 +81,8 @@
|
|
|
.toast-wrap{
|
|
|
margin-bottom: .2rem;
|
|
|
position: relative;
|
|
|
- .tab{
|
|
|
+ z-index: 116;
|
|
|
+ .ptab{
|
|
|
width:100%;
|
|
|
height: .8rem;
|
|
|
line-height: .8rem;
|
|
@@ -78,21 +92,23 @@
|
|
|
color:#7C828E;
|
|
|
}
|
|
|
.content{
|
|
|
+ box-sizing: border-box;
|
|
|
padding-top: 25px;
|
|
|
width: 100%;
|
|
|
height: 227px;
|
|
|
background: #fff;
|
|
|
z-index: 999;
|
|
|
position: absolute;
|
|
|
- top:.88rem;
|
|
|
+ // top:.88rem;
|
|
|
left: 50%;
|
|
|
transform: translateX(-50%);
|
|
|
box-sizing: border-box;
|
|
|
- border-radius: .2rem;
|
|
|
+ border-radius: .1rem;
|
|
|
z-index: 1000;
|
|
|
font-size: .3rem;
|
|
|
overflow-y: hidden;
|
|
|
box-shadow: 0 .12rem .24rem 0 rgba(79,129,255,0.40);
|
|
|
+ // box-shadow:0 .15rem .35rem 0 rgba(179,196,236,0.3);
|
|
|
.confBtn{
|
|
|
height: 44px;
|
|
|
line-height: 44px;
|