ming-pop.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <template>
  2. <view :class="direction==='center'?'centers':''" v-if="direction==='center'?open:true">
  3. <view class="product-window"
  4. :style="{width:width+'%',height:height=='fit-content'?height:(open?height:'fit-content')}"
  5. :class="(open ? 'on' : '')+' '+direction" @touchmove.stop.prevent="">
  6. <!-- #ifndef MP -->
  7. <!-- #endif -->
  8. <slot></slot>
  9. </view>
  10. <view class="mask" v-if="is_mask" @touchmove.prevent :hidden="!open" @click="close(1)"></view>
  11. </view>
  12. </template>
  13. <script>
  14. export default {
  15. props: {
  16. direction: {
  17. type: String,
  18. default: "below"
  19. },
  20. width: {
  21. type: Number,
  22. default: 100
  23. },
  24. height: {
  25. type: String,
  26. default: "fit-content"
  27. },
  28. is_close: {
  29. type: Boolean,
  30. default: true
  31. },
  32. is_mask: {
  33. type: Boolean,
  34. default: true
  35. },
  36. maskFun: {
  37. type: Boolean,
  38. default: true
  39. }
  40. },
  41. data() {
  42. return {
  43. open: false
  44. };
  45. },
  46. methods: {
  47. show() {
  48. this.open = true;
  49. this.$emit("watchOpen")
  50. },
  51. close(e) {
  52. if (e == 1 && !this.maskFun) return;
  53. this.open = false;
  54. this.$emit("watchClose")
  55. }
  56. }
  57. }
  58. </script>
  59. <style lang="scss" scoped>
  60. view {
  61. box-sizing: border-box;
  62. }
  63. .centers {
  64. width: 100vw;
  65. display: flex;
  66. justify-content: center;
  67. align-items: center;
  68. // height: 100%;
  69. position: fixed;
  70. top: 0;
  71. left: 0;
  72. right: 0;
  73. bottom: 0;
  74. }
  75. .product-window {
  76. position: fixed;
  77. background-color: #fff;
  78. z-index: 77;
  79. border-radius: 32rpx 32rpx 0rpx 0rpx;
  80. padding: 50rpx 30rpx;
  81. transition: all .3s cubic-bezier(.25, .5, .5, .9);
  82. -webkit-transition: all .3s cubic-bezier(.25, .5, .5, .9);
  83. }
  84. .below {
  85. left: 0;
  86. bottom: 0;
  87. transform: translate3d(0, 100%, 0);
  88. -webkit-transform: translate3d(0, 100%, 0);
  89. }
  90. .up {
  91. top: 0;
  92. left: 0;
  93. transform: translate3d(0, -100%, 0);
  94. -webkit-transform: translate3d(0, -100%, 0);
  95. }
  96. .right {
  97. right: 0;
  98. top: 0;
  99. height: 100%;
  100. transform: translate3d(100vw, 0, 0);
  101. -webkit-transform: translate3d(100vw, 0, 0);
  102. }
  103. .left {
  104. left: 0;
  105. top: 0;
  106. height: 100%;
  107. transform: translate3d(-100vw, 0, 0);
  108. -webkit-transform: translate3d(-100vw, 0, 0);
  109. }
  110. .center {
  111. position: static;
  112. -webkit-position: static;
  113. transform: translate3d(-100vw, -100%, 0);
  114. -webkit-transform: translate3d(-100vw, -100%, 0);
  115. }
  116. .product-window.on {
  117. transform: translate3d(0, 0, 0);
  118. -webkit-transform: translate3d(0, 0, 0);
  119. }
  120. .mask {
  121. position: fixed;
  122. top: 0;
  123. left: 0;
  124. right: 0;
  125. bottom: 0;
  126. background-color: #000;
  127. opacity: .5;
  128. z-index: 5;
  129. }
  130. .product-window .iconfont {
  131. position: fixed;
  132. right: 30rpx;
  133. top: 20rpx;
  134. font-size: 35rpx;
  135. color: #8a8a8a;
  136. width: 50rpx;
  137. height: 50rpx;
  138. }
  139. //兼容h5顶部导航空位
  140. // #ifndef MP
  141. .product-window .iconfont-h5 {
  142. top: 100rpx;
  143. }
  144. // #endif
  145. </style>