u-drawer.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <template>
  2. <view class="u-drawer " :class="visible ? 'u-drawer-open' : ''">
  3. <view class="u-drawer-mask" @click="cancel"/>
  4. <view class="u-drawer-content" >
  5. <view class="header u-flex">
  6. <view class="cancel" @click="cancel">取消</view>
  7. <view v-if="title" class="title">{{title}}</view>
  8. <view class="u-button" @click="sumbit">完成</view>
  9. </view>
  10. <slot></slot>
  11. </view>
  12. </view>
  13. </template>
  14. <script>
  15. export default {
  16. name: "u-drawer",
  17. props: {
  18. visible: {
  19. type: Boolean,
  20. default: false
  21. },
  22. title: {
  23. type: String,
  24. default: ''
  25. },
  26. },
  27. methods: {
  28. test(e) {
  29. console.log(e)
  30. },
  31. cancel() {
  32. this.$emit('update:visible', false)
  33. },
  34. sumbit() {
  35. this.$emit('sumbit')
  36. }
  37. }
  38. }
  39. </script>
  40. <style lang="scss" scoped>
  41. .u-drawer>* {
  42. transition: transform .3s cubic-bezier(.7, .3, .1, 1), box-shadow .3s cubic-bezier(.7, .3, .1, 1);
  43. }
  44. .u-drawer {
  45. position: fixed;
  46. z-index: 1000;
  47. left: 0;
  48. bottom: 0;
  49. width: 100%;
  50. height: 0%;
  51. }
  52. .u-drawer-mask {
  53. position: absolute;
  54. top: 0;
  55. left: 0;
  56. bottom: 0;
  57. right: 0;
  58. background-color: rgba(0, 0, 0, .45);
  59. display: none;
  60. // pointer-events: none;
  61. }
  62. .u-drawer-open {
  63. height: 100%;
  64. .u-drawer-content,
  65. .u-drawer-mask {
  66. display: inherit;
  67. transform: translateY(0);
  68. }
  69. }
  70. .u-drawer-content {
  71. position: absolute;
  72. width: 100%;
  73. bottom: 0;
  74. // box-shadow: 0 -2px 8px rgb(0 0 0 / 15%);
  75. padding: 28rpx 32rpx;
  76. min-height: 100rpx;
  77. background: #FFFFFF;
  78. border-radius: 28rpx 28rpx 0px 0px;
  79. // display: none;
  80. transform: translateY(1000%);
  81. // animation: mymove 0.3s;
  82. // animation-iteration-count: 1;
  83. .header {
  84. margin-bottom: 50rpx;
  85. .title {
  86. font-size: 36rpx;
  87. font-weight: bold;
  88. color: #333333;
  89. }
  90. .cancel {
  91. min-width: 150rpx;
  92. padding: 12rpx 0;
  93. font-size: 28rpx;
  94. font-weight: 400;
  95. color: #333333;
  96. cursor: pointer;
  97. }
  98. }
  99. }
  100. </style>