Modal.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <template>
  2. <!-- 过渡动画 -->
  3. <transition name="modal-fade">
  4. <!-- 关闭模态框事件 和 控制模态框是否显示 -->
  5. <div class="modal-backdrop" @click="$emit('closeModal')" v-show="show">
  6. <div class="modal" @click.stop>
  7. <div class="modal-body" id="modalDescription">
  8. <!-- 状态提示文字的插槽 -->
  9. <slot name="status">{{statusText}}</slot>
  10. <slot name="body"></slot>
  11. <el-button class="icon-btn_style fr" style="font-size: 24px" @click="$emit('closeModal')">
  12. ×
  13. </el-button>
  14. </div>
  15. <!-- 模态框内容文字 可有可无 -->
  16. <div class="modal-content" v-if="contentText">
  17. <slot>this is Modal-content</slot>
  18. </div>
  19. <!--<ul>-->
  20. <!--&lt;!&ndash; 模态框按钮 可选单个确定按钮 和 两个确定、取消按钮 &ndash;&gt;-->
  21. <!--&lt;!&ndash; 单个确定按钮 &ndash;&gt;-->
  22. <!--<li v-if="alert" :class="buttonBackground" @click.stop="$emit('button')">确定</li>-->
  23. <!--&lt;!&ndash; 确定和取消按钮 &ndash;&gt;-->
  24. <!--<li v-else class="confirm">-->
  25. <!--<div>取消</div>-->
  26. <!--<div :class="buttonBackground" @click.stop="$emit('confirm')">{{sure}}</div>-->
  27. <!--</li>-->
  28. <!--</ul>-->
  29. </div>
  30. </div>
  31. </transition>
  32. </template>
  33. <script>
  34. export default {
  35. name: "modal",
  36. // 通过 props 传值
  37. props: {
  38. imgadress: String,
  39. title: String, //标题文字
  40. show: {
  41. //显示取消
  42. type: Boolean,
  43. default: false
  44. },
  45. statusText: String, //状态文字
  46. contentText: String, //描述文字
  47. IDList: Array, //ID 列表
  48. payMoney: Number,
  49. yuan: String,
  50. buttonBackground: String, //按钮背景色
  51. alert: String, //判断一个还是两个按钮
  52. sure: String //第二个按钮的提示文字
  53. },
  54. data() {
  55. return {
  56. closemodal: "close",
  57. // isModalVisible:false,
  58. // 确定和取消按钮的两种颜色
  59. // red: "redBackground",
  60. // blue: "blueBackground"
  61. };
  62. },
  63. components: {
  64. },
  65. methods: {
  66. // 关闭模态框事件
  67. close() {
  68. this.$emit("close");
  69. }
  70. }
  71. };
  72. </script>
  73. <style lang="scss" scoped>
  74. .modal-backdrop {
  75. position: fixed;
  76. top: 0;
  77. right: 0;
  78. bottom: 0;
  79. left: 0;
  80. background-color: rgba(0, 0, 0, 0.3);
  81. display: flex;
  82. justify-content: center;
  83. align-items: center;
  84. z-index: 12;
  85. .modal {
  86. width: 74%;
  87. background-color: #fff;
  88. box-shadow: 2px 2px 20px rgba(0, 0, 0, 0.3);
  89. overflow-x: auto;
  90. display: flex;
  91. flex-direction: column;
  92. // width: 11.8rem;
  93. position: relative;
  94. border-radius: 0.2rem;
  95. padding: 20px;
  96. .img {
  97. width: 3.6rem;
  98. height: 3.6rem;
  99. margin: 0.8rem 4.1rem;
  100. }
  101. .modal-header {
  102. padding: 0.6rem 4.1rem;
  103. width: 3.6rem;
  104. height: 3.6rem;
  105. box-sizing: border-box;
  106. .img {
  107. width: 100%;
  108. height: 100%;
  109. }
  110. div {
  111. width: 100%;
  112. height: 100%;
  113. background: #000;
  114. }
  115. }
  116. .modal-body {
  117. width: 100%;
  118. padding:1.6rem;
  119. box-sizing: border-box;
  120. display: flex;
  121. justify-content: space-between;
  122. align-items: center;
  123. li {
  124. width: 2rem;
  125. height: 0.04rem;
  126. background: #eeeee5;
  127. }
  128. }
  129. .modal-content {
  130. width: 100%;
  131. // height: 0.6rem;
  132. max-height: 61vh;
  133. overflow: auto;
  134. margin-bottom: 0.8rem;
  135. text-align: center;
  136. color: #34304b;
  137. span {
  138. color: #32b8b9;
  139. i {
  140. color: #4f4f4f;
  141. }
  142. }
  143. }
  144. ul {
  145. li {
  146. width: 100%;
  147. height: 1.52rem;
  148. line-height: 1.52rem;
  149. text-align: center;
  150. color: #fff;
  151. font-size: 0.56rem;
  152. letter-spacing: 0.4rem;
  153. }
  154. .confirm {
  155. display: flex;
  156. div:nth-child(1) {
  157. flex: 1;
  158. background: #dedede;
  159. color: #bcbbbf;
  160. }
  161. div:nth-child(2) {
  162. flex: 1;
  163. color: #fff;
  164. }
  165. }
  166. }
  167. }
  168. }
  169. /* 动画 */
  170. .modal-fade-enter,
  171. .modal-fade-leave-active {
  172. opacity: 0;
  173. }
  174. .modal-fade-enter-active,
  175. .modal-fade-leave-active {
  176. transition: opacity 0.5s ease;
  177. }
  178. </style>