lj-win-popup.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <template>
  2. <van-popup
  3. class="widget-popup"
  4. v-model="showWidgetPopup"
  5. lock-scroll
  6. :round="round"
  7. :position="position"
  8. :style="popupStyle"
  9. :closeable="closeable"
  10. :get-container="getContainer"
  11. :close-on-click-overlay="closeOnClickOverlay"
  12. :transition-appear="true"
  13. :lazy-render="false"
  14. @click-overlay="handleClickOverlay"
  15. @closed="autoClosed"
  16. >
  17. <div class="widget-popup_main">
  18. <div class="popup_header">
  19. <slot name="title">
  20. {{ title }}
  21. </slot>
  22. </div>
  23. <main class="widget-main">
  24. <slot name="body"></slot>
  25. </main>
  26. <footer class="widget-footer">
  27. <slot name="footer"></slot>
  28. </footer>
  29. </div>
  30. </van-popup>
  31. </template>
  32. <script>
  33. export default {
  34. name: 'L1WinPopup',
  35. data() {
  36. return {
  37. showWidgetPopup: false, // 控制窗体显示与否
  38. };
  39. },
  40. props: {
  41. // 窗体高度
  42. popupStyle: {
  43. type: Object,
  44. default: function() {
  45. return {}
  46. }
  47. },
  48. // 弹窗显示的位置
  49. position: {
  50. type: String,
  51. default: 'bottom'
  52. },
  53. // 是否显示关闭按钮
  54. closeable: {
  55. type: Boolean,
  56. default: true
  57. },
  58. // 挂载的位置
  59. getContainer: {
  60. type: String,
  61. default: 'body'
  62. },
  63. // 标题
  64. title: {
  65. type: String,
  66. default: ''
  67. },
  68. // 是否显示圆角
  69. round: {
  70. type: Boolean,
  71. default: false
  72. },
  73. // 是否在点击遮罩层后关闭
  74. closeOnClickOverlay: {
  75. type: Boolean,
  76. default: true
  77. }
  78. },
  79. mounted() {
  80. },
  81. methods: {
  82. /**打开筛选组件 */
  83. open() {
  84. this.showWidgetPopup = true;
  85. },
  86. /**关闭筛选组件 */
  87. close() {
  88. this.showWidgetPopup = false;
  89. },
  90. /**关闭筛选组件时,回调 */
  91. autoClosed() {
  92. this.$emit('closed')
  93. },
  94. /**点击遮罩层时触发 */
  95. handleClickOverlay() {
  96. this.$emit('click-overlay')
  97. },
  98. },
  99. };
  100. </script>
  101. <style lang="less">
  102. .widget-popup {
  103. .widget-popup_main {
  104. max-height: 80vh;
  105. position: relative;
  106. height: 100%;
  107. border-radius: 10px;
  108. display: flex;
  109. flex-direction: column;
  110. }
  111. .popup_header {
  112. flex-shrink: 0;
  113. width: 100%;
  114. height: 44px;
  115. line-height: 44px;
  116. font-size: 16px;
  117. font-weight: 700;
  118. text-align: center;
  119. background-color: #f8f8f8;
  120. }
  121. .widget-main {
  122. padding-bottom: 60px;
  123. flex: 1;
  124. overflow: auto;
  125. }
  126. .widget-footer {
  127. position: fixed;
  128. left: 0;
  129. right: 0;
  130. bottom: 0;
  131. padding: 10px;
  132. // width: 100%;
  133. display: flex;
  134. z-index: 1999;
  135. .btn + .btn {
  136. margin-left: 10px;
  137. }
  138. .btn {
  139. box-shadow: 0px 2px 5px 0px rgba(0,0,0,0.04), 0px 0px 3px 0px rgba(0,0,0,0.08);
  140. .iconfont {
  141. font-size: 14px;
  142. }
  143. }
  144. }
  145. .van-popup__close-icon {
  146. top: 10px;
  147. }
  148. }
  149. </style>