tui-bottom-popup.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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}"
  4. :style="{backgroundColor:backgroundColor,height:height?height+'rpx':'auto','--dot-color':dotColor||'#2979ff'}">
  5. <view class="tui-header" v-if="title">
  6. <view>{{title}}</view>
  7. <icon type="clear" :size="16" color="#c0c0c0" class="tui-icon-close" @tap.stop="handleClose"></icon>
  8. </view>
  9. <slot></slot>
  10. </view>
  11. <view class="tui-popup-mask" :class="[show?'tui-mask-show':'']" v-if="mask" @tap="handleClose"></view>
  12. </view>
  13. </template>
  14. <script>
  15. export default {
  16. name: "tuiBottomPopup",
  17. props: {
  18. title: {
  19. type: String,
  20. default: ""
  21. },
  22. //是否需要mask
  23. mask: {
  24. type: Boolean,
  25. default: true
  26. },
  27. //控制显示
  28. show: {
  29. type: Boolean,
  30. default: false
  31. },
  32. dotColor: {
  33. type: String,
  34. default: '#2979ff'
  35. },
  36. //背景颜色
  37. backgroundColor: {
  38. type: String,
  39. default: "#fff"
  40. },
  41. //高度 rpx
  42. height: {
  43. type: Number,
  44. default: 0
  45. },
  46. //设置圆角
  47. radius: {
  48. type: Boolean,
  49. default: true
  50. }
  51. },
  52. methods: {
  53. handleClose() {
  54. if (!this.show) {
  55. return;
  56. }
  57. this.$emit('close', {});
  58. }
  59. }
  60. }
  61. </script>
  62. <style lang="scss" scoped>
  63. .tui-header {
  64. width: 100%;
  65. display: flex;
  66. align-items: center;
  67. justify-content: flex-start;
  68. padding: 30rpx;
  69. font-weight: bold;
  70. font-size: 30rpx;
  71. box-sizing: border-box;
  72. background-color: #fff;
  73. border-top-left-radius: 20rpx;
  74. border-top-right-radius: 20rpx;
  75. overflow: hidden;
  76. position: relative;
  77. color: #333333;
  78. &:before {
  79. content: " ";
  80. height: 12px;
  81. background-color: var(--dot-color);
  82. border-radius: 10px;
  83. width: 4px;
  84. margin-right: 20rpx;
  85. }
  86. &:after {
  87. content: ' ';
  88. position: absolute;
  89. left: 0;
  90. bottom: 0;
  91. right: 0;
  92. height: 1rpx;
  93. z-index: 1;
  94. // border-bottom: 1rpx solid #e5e5e5;
  95. background-color: #e5e5e5;
  96. transform-origin: 0 100%;
  97. transform: scaleY(0.5);
  98. }
  99. }
  100. .tui-icon-close {
  101. position: absolute;
  102. right: 30rpx;
  103. top: 50%;
  104. transform: translateY(-50%);
  105. }
  106. .tui-bottom-popup {
  107. width: 100%;
  108. position: fixed;
  109. left: 0;
  110. right: 0;
  111. bottom: 0;
  112. z-index: 99;
  113. /* visibility: hidden; */
  114. opacity: 0;
  115. transform: translate3d(0, 100%, 0);
  116. transform-origin: center;
  117. transition: all 0.3s ease-in-out;
  118. min-height: 20rpx;
  119. }
  120. .tui-popup-radius {
  121. border-top-left-radius: 24rpx;
  122. border-top-right-radius: 24rpx;
  123. // padding-bottom: env(safe-area-inset-bottom);
  124. overflow: hidden;
  125. }
  126. .tui-popup-show {
  127. transform: translate3d(0, 0, 0);
  128. opacity: 1;
  129. /* visibility: visible; */
  130. }
  131. .tui-popup-mask {
  132. position: fixed;
  133. top: 0;
  134. left: 0;
  135. right: 0;
  136. bottom: 0;
  137. background-color: rgba(0, 0, 0, 0.6);
  138. z-index: 95;
  139. transition: all 0.3s ease-in-out;
  140. opacity: 0;
  141. visibility: hidden;
  142. }
  143. .tui-mask-show {
  144. opacity: 1;
  145. visibility: visible;
  146. }
  147. </style>