tui-bottom-popup.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <view @touchmove.stop.prevent>
  3. <view class="tui-popup-class tui-bottom-popup" :class="{'tui-popup-show':show,'tui-popup-radius':radius}" :style="{backgroundColor:backgroundColor,height:height?height+'rpx':'auto'}">
  4. <slot></slot>
  5. </view>
  6. <view class="tui-popup-mask" :class="[show?'tui-mask-show':'']" v-if="mask" @tap="handleClose"></view>
  7. </view>
  8. </template>
  9. <script>
  10. export default {
  11. name: "tuiBottomPopup",
  12. props: {
  13. //是否需要mask
  14. mask: {
  15. type: Boolean,
  16. default: true
  17. },
  18. //控制显示
  19. show: {
  20. type: Boolean,
  21. default: false
  22. },
  23. //背景颜色
  24. backgroundColor: {
  25. type: String,
  26. default: "#fff"
  27. },
  28. //高度 rpx
  29. height: {
  30. type: Number,
  31. default: 0
  32. },
  33. //设置圆角
  34. radius:{
  35. type:Boolean,
  36. default:true
  37. }
  38. },
  39. methods: {
  40. handleClose() {
  41. if (!this.show) {
  42. return;
  43. }
  44. this.$emit('close', {});
  45. }
  46. }
  47. }
  48. </script>
  49. <style scoped>
  50. .tui-bottom-popup {
  51. width: 100%;
  52. position: fixed;
  53. left: 0;
  54. right: 0;
  55. bottom: 0;
  56. z-index: 997;
  57. /* visibility: hidden; */
  58. opacity: 0;
  59. transform: translate3d(0, 100%, 0);
  60. transform-origin: center;
  61. transition: all 0.3s ease-in-out;
  62. min-height: 20rpx;
  63. }
  64. .tui-popup-radius {
  65. border-top-left-radius: 24rpx;
  66. border-top-right-radius: 24rpx;
  67. padding-bottom: env(safe-area-inset-bottom);
  68. overflow: hidden;
  69. }
  70. .tui-popup-show {
  71. transform: translate3d(0, 0, 0);
  72. opacity: 1;
  73. /* visibility: visible; */
  74. }
  75. .tui-popup-mask {
  76. position: fixed;
  77. top: 0;
  78. left: 0;
  79. right: 0;
  80. bottom: 0;
  81. background-color: rgba(0, 0, 0, 0.6);
  82. z-index: 996;
  83. transition: all 0.3s ease-in-out;
  84. opacity: 0;
  85. visibility: hidden;
  86. }
  87. .tui-mask-show {
  88. opacity: 1;
  89. visibility: visible;
  90. }
  91. </style>