bottom-popup.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <template>
  2. <view @touchmove.stop.prevent>
  3. <view class="tui-popup-class tui-bottom-popup" :class="{'tui-popup-show':show}" :style="{background:bgcolor,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. bgcolor: {
  25. type: String,
  26. default: "#fff"
  27. },
  28. //高度 rpx
  29. height: {
  30. type: Number,
  31. default: 0
  32. }
  33. },
  34. methods: {
  35. handleClose() {
  36. if (!this.show) {
  37. return;
  38. }
  39. this.$emit('close', {});
  40. }
  41. }
  42. }
  43. </script>
  44. <style>
  45. .tui-bottom-popup {
  46. width: 100%;
  47. position: fixed;
  48. left: 0;
  49. right: 0;
  50. bottom: 0;
  51. z-index: 99999;
  52. visibility: hidden;
  53. transform: translate3d(0, 100%, 0);
  54. transform-origin: center;
  55. transition: all 0.3s ease-in-out;
  56. min-height: 20rpx;
  57. }
  58. .tui-popup-show {
  59. transform: translate3d(0, 0, 0);
  60. visibility: visible;
  61. }
  62. .tui-popup-mask {
  63. position: fixed;
  64. top: 0;
  65. left: 0;
  66. right: 0;
  67. bottom: 0;
  68. background: rgba(0, 0, 0, 0.6);
  69. z-index: 99996;
  70. transition: all 0.3s ease-in-out;
  71. opacity: 0;
  72. visibility: hidden;
  73. }
  74. .tui-mask-show {
  75. opacity: 1;
  76. visibility: visible;
  77. }
  78. </style>