LgModal.vue 4.5 KB

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