ming-pop.vue 3.1 KB

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