z-select-popup.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <template>
  2. <view >
  3. <view class="mask" @click="clickmask" @touchmove.stop.prevent="moveHandle" v-if="visible"></view>
  4. <view class="z-select-popup" v-if="visible" :class="[{'animate_show':visible}]">
  5. <view class="z-select-popup-top">
  6. <slot></slot>
  7. </view>
  8. <view class="z-select-popup-bottom mt-20" @click="cancel">{{doText}}</view>
  9. </view>
  10. </view>
  11. </template>
  12. <script>
  13. export default{
  14. name:'z-select-popup',
  15. props:{
  16. visible:Boolean,
  17. doText:{
  18. type:String,
  19. default:'取消'
  20. }
  21. },
  22. watch:{
  23. visible(newval,oldval){
  24. console.log(newval)
  25. if(newval){
  26. this.hideAnimate=false;
  27. }else{
  28. this.hideAnimate=true;
  29. // this.cleartime=setTimeout(()=>{
  30. this.$emit('update:visible', false);
  31. // },300)
  32. }
  33. }
  34. },
  35. data(){
  36. return{
  37. showAnimate:false,
  38. hideAnimate:true,
  39. isvisible:false,
  40. cleartime:''
  41. }
  42. },
  43. methods:{
  44. moveHandle(){},
  45. cancel(){
  46. this.$emit('update:visible', false);
  47. console.log(this.visible)
  48. this.$emit('cancel');
  49. },
  50. clickmask(){
  51. this.$emit('clickmask')
  52. }
  53. },
  54. beforeDestroy(){
  55. this.hideAnimate=true;
  56. this.$emit('update:visible', false);
  57. // this.isvisible=false;
  58. // clearTimeout(this.cleartime);
  59. }
  60. }
  61. </script>
  62. <style scoped lang="scss">
  63. @keyframes show{
  64. 0%{
  65. bottom: -100%;
  66. }
  67. 100%{
  68. bottom: 30rpx;
  69. }
  70. }
  71. @keyframes hide{
  72. 0%{
  73. bottom: 30rpx;
  74. }
  75. 100%{
  76. bottom: -100%;
  77. }
  78. }
  79. .animate_show {
  80. animation: show .5s;
  81. animation-fill-mode: forwards;
  82. }
  83. .animate_hide {
  84. animation: hide .5s;
  85. animation-fill-mode: forwards;
  86. }
  87. .mask{
  88. position: fixed;
  89. top: 0;
  90. left: 0;
  91. background: rgba(0, 0, 0, 0.3);
  92. width: 100%;
  93. height: 100%;
  94. z-index: 510;
  95. }
  96. .z-select-popup{
  97. position: fixed;
  98. width: 690rpx;
  99. left: 30rpx;
  100. z-index: 600;
  101. .z-select-popup-top,.z-select-popup-bottom{
  102. line-height: 100rpx;
  103. border-radius: 20rpx;
  104. background: white;
  105. font-size: 32rpx;
  106. color: #4179bf;
  107. text-align: center;
  108. }
  109. }
  110. </style>