y-bottomPopup.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <template>
  2. <view @touchmove.stop.prevent>
  3. <view class="yc-popup-class yc-bottom-popup" :class="[show ? 'yc-popup-show' : '',radius ? 'borderRadius' : '']" :style="{background:bgcolor,height:height?height+'rpx':'auto'}">
  4. <view class="pop-head" v-show="showHead">
  5. <text @tap="handleClose">取消</text>
  6. <text class="color-main title">{{headTitle}}</text>
  7. <text class="color-main-detail" @tap="handleSuccess">确定</text>
  8. </view>
  9. <view class="pop-head" v-show="!showHead && mask">
  10. <text></text>
  11. <text class="color-main title">{{headTitle}}</text>
  12. <text class="cuIcon-close icon-close" @tap="handleClose"></text>
  13. </view>
  14. <slot></slot>
  15. </view>
  16. <view class="yc-popup-mask" :class="[show?'yc-mask-show':'']" v-if="mask" @tap="handleClose"></view>
  17. </view>
  18. </template>
  19. <script>
  20. export default {
  21. name: "ycBottomPopup",
  22. props: {
  23. //是否需要mask
  24. mask: {
  25. type: Boolean,
  26. default: true
  27. },
  28. showHead: {
  29. type: Boolean,
  30. default: true
  31. },
  32. headTitle: {
  33. type: String,
  34. default: ''
  35. },
  36. radius:{
  37. type: Boolean,
  38. default: false
  39. },
  40. //控制显示
  41. show: {
  42. type: Boolean,
  43. default: false
  44. },
  45. //背景颜色
  46. bgcolor: {
  47. type: String,
  48. default: "#fff"
  49. },
  50. //高度 rpx
  51. height: {
  52. type: Number,
  53. default: 0
  54. }
  55. },
  56. methods: {
  57. handleClose() {
  58. if (!this.show) {
  59. return;
  60. }
  61. this.$emit('close');
  62. },
  63. handleSuccess() {
  64. // this.handleClose()
  65. this.$emit('success',{})
  66. }
  67. }
  68. }
  69. </script>
  70. <style>
  71. .yc-bottom-popup {
  72. width: 100%;
  73. position: fixed;
  74. left: 0;
  75. right: 0;
  76. bottom: 0;
  77. z-index: 9999999999999999;
  78. visibility: hidden;
  79. transform: translate3d(0, 100%, 0);
  80. transform-origin: center;
  81. transition: all 0.3s ease-in-out;
  82. min-height: 20rpx;
  83. border-top: 1upx solid #ececec;
  84. }
  85. .yc-popup-show {
  86. transform: translate3d(0, 0, 0);
  87. visibility: visible;
  88. }
  89. .yc-popup-mask {
  90. position: fixed;
  91. top: 0;
  92. left: 0;
  93. right: 0;
  94. bottom: 0;
  95. background: rgba(0, 0, 0, 0.6);
  96. z-index: 996;
  97. transition: all 0.3s ease-in-out;
  98. opacity: 0;
  99. visibility: hidden;
  100. }
  101. .borderRadius{
  102. border-radius: 30upx 30upx 0 0;
  103. }
  104. .yc-mask-show {
  105. opacity: 1;
  106. visibility: visible;
  107. }
  108. .pop-head {
  109. display: flex;
  110. align-items: center;
  111. justify-content: space-between;
  112. font-size: 32upx;
  113. color: #666666;
  114. height: 120upx;
  115. padding: 0 32upx;
  116. }
  117. .title{
  118. font-size: 32upx;
  119. font-family: AlibabaPuHuiTiM;
  120. }
  121. .color-main-detail {
  122. color: var(--mainColor);
  123. }
  124. </style>