drawerWindow.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <template name="drawerWindow">
  2. <view :style="{background:background,zIndex:zIndex, top:top+'px'}">
  3. <view class="DrawerClose" :class="show ? direction:default_direction" @tap="hideModal">
  4. <text class="cuIcon-pullright"></text>
  5. </view>
  6. <scroll-view scroll-y class="DrawerWindow" :class="show ? direction:default_direction" :style="{width:width,padding:padding, zIndex:zIndex+1, background:slotBg}" @tap.stop="stopFun" @touchstart="Dever.slide" @touchend="end" @scrolltolower="bottomCall">
  7. <view class="cu-list menu card-menu margin-top-xl margin-bottom-xl shadow-lg" v-if="show">
  8. <slot name="links"></slot>
  9. </view>
  10. </scroll-view>
  11. </view>
  12. </template>
  13. <script>
  14. export default {
  15. name: "drawerWindow",
  16. props: {
  17. show : {
  18. type : Boolean,
  19. default : false
  20. },
  21. direction : {
  22. type : String,
  23. default : 'left'
  24. },
  25. width : {
  26. type : String,
  27. default : '60%'
  28. },
  29. background:{
  30. type : String,
  31. default : 'rgba(0, 0, 0, 0.5)'
  32. },
  33. slotBg:{
  34. type : String,
  35. default : 'rgba(255, 255, 255, 1)'
  36. },
  37. padding :{
  38. type : String,
  39. default : '30rpx'
  40. },
  41. zIndex : {
  42. type : Number,
  43. default : 10
  44. },
  45. // #ifdef H5
  46. top:{
  47. type : Number,
  48. default : 44
  49. },
  50. // #endif
  51. // #ifndef H5
  52. top:{
  53. type : Number,
  54. default : 0
  55. },
  56. // #endif
  57. },
  58. data() {
  59. return {
  60. default_direction:'default_left'
  61. };
  62. },
  63. mounted() {
  64. this.default_direction = 'default_' + this.direction;
  65. },
  66. methods:{
  67. bottomCall : function() {
  68. this.$emit('bottomFunc');
  69. },
  70. closeDrawer : function(){
  71. this.$emit('closeDrawer');
  72. },
  73. end : function(e) {
  74. var type = this.Dever.slideEnd(e);
  75. if (type == 3 || type == 4) {
  76. this.closeDrawer();
  77. }
  78. },
  79. showModal : function(e) {
  80. this.show = true;
  81. },
  82. hideModal : function(e) {
  83. this.closeDrawer();
  84. },
  85. stopFun : function() {
  86. }
  87. }
  88. }
  89. </script>
  90. <style>
  91. .DrawerWindow {
  92. position: absolute;
  93. width: 85vw;
  94. height: 100vh;
  95. left: 0;
  96. top: 0;
  97. transform: scale(0.9, 0.9) translateX(-100%);
  98. opacity: 0;
  99. pointer-events: none;
  100. transition: all 0.4s;
  101. }
  102. .DrawerWindow.default_left {
  103. transform: scale(1, 1) translateX(-100%);
  104. opacity: 1;
  105. pointer-events: all;
  106. }
  107. .DrawerWindow.left {
  108. transform: scale(1, 1) translateX(0%);
  109. opacity: 1;
  110. pointer-events: all;
  111. }
  112. .DrawerWindow.default_down {
  113. transform: scale(1, 1) translateY(100%);
  114. }
  115. .DrawerWindow.down {
  116. transform: scale(1, 1) translateY(20%);
  117. opacity: 1;
  118. pointer-events: all;
  119. }
  120. .DrawerClose {
  121. position: absolute;
  122. width: 40vw;
  123. height: 100vh;
  124. right: 0;
  125. top: 0;
  126. color: transparent;
  127. padding-bottom: 30upx;
  128. display: flex;
  129. align-items: flex-end;
  130. justify-content: center;
  131. background-image: linear-gradient(90deg, rgba(0, 0, 0, 0.01), rgba(0, 0, 0, 0.6));
  132. letter-spacing: 5px;
  133. font-size: 50upx;
  134. opacity: 0;
  135. pointer-events: none;
  136. transition: all 0.4s;
  137. }
  138. .DrawerClose.left {
  139. opacity: 1;
  140. pointer-events: all;
  141. width: 15vw;
  142. color: #fff;
  143. }
  144. .DrawerClose.down {
  145. opacity: 0;
  146. pointer-events: all;
  147. width: 15vw;
  148. color: #fff;
  149. }
  150. .card-menu {
  151. border-radius: 0px;
  152. }
  153. </style>