popup-bottom.vue 1.3 KB

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