show-modal.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <template>
  2. <div class="_showModal" v-show="show">
  3. <div class="_shade"></div>
  4. <div class="_modalBox" @click="closeModal" @touchmove.stop.prevent="">
  5. <div class="_modal">
  6. <slot name="title">
  7. <div class="title" v-show="title">{{title}}</div>
  8. </slot>
  9. <slot name="content">
  10. <div class="content">
  11. {{content}}
  12. </div>
  13. </slot>
  14. <slot name="btn">
  15. <div class="btnbox">
  16. <div class="cancel btn" v-show="showCancel" :style="cancelColor" @click.stop="clickBtn('cancel')">{{cancelText}}</div>
  17. <div class="confirm btn" :style="confirmColor" @click.stop="clickBtn('confirm')">{{confirmText}}</div>
  18. </div>
  19. </slot>
  20. </div>
  21. </div>
  22. </div>
  23. </template>
  24. <script>
  25. export default {
  26. computed: {
  27. show(){
  28. return this.$modalStore.state.show;
  29. },
  30. title(){
  31. return this.$modalStore.state.title;
  32. },
  33. content(){
  34. return this.$modalStore.state.content;
  35. },
  36. showCancel(){
  37. return this.$modalStore.state.showCancel;
  38. },
  39. cancelText(){
  40. return this.$modalStore.state.cancelText;
  41. },
  42. cancelColor(){
  43. return "color:"+this.$modalStore.state.cancelColor;
  44. },
  45. confirmText(){
  46. return this.$modalStore.state.confirmText;
  47. },
  48. confirmColor(){
  49. return "color:"+this.$modalStore.state.confirmColor;
  50. }
  51. },
  52. methods:{
  53. closeModal(){
  54. this.$modalStore.commit('hideModal')
  55. },
  56. clickBtn(res){
  57. this.$modalStore.commit('hideModal')
  58. this.$modalStore.commit('success',res)
  59. }
  60. },
  61. beforeDestroy(){
  62. this.$modalStore.commit('hideModal')
  63. }
  64. };
  65. </script>
  66. <style lang="scss" scoped>
  67. ._showModal{
  68. position: fixed;
  69. top: 0;
  70. left:0;
  71. width: 100vw;
  72. height: 100vh;
  73. z-index:10000;
  74. ._shade{
  75. width: 100%;
  76. height: 100%;
  77. position: absolute;
  78. top: 0;
  79. left: 0;
  80. background: #000;
  81. opacity: .6;
  82. z-index:11000;
  83. }
  84. ._modalBox{
  85. width: 100%;
  86. height: 100%;
  87. position: absolute;
  88. top: 0;
  89. left: 0;
  90. z-index:12000;
  91. display: flex;
  92. justify-content: center;
  93. align-items: center;
  94. ._modal{
  95. flex: none;
  96. width:70%;
  97. // min-height:200upx;
  98. background: #fff;
  99. border-radius: 10upx;
  100. .title{
  101. height: 40upx;
  102. line-height: 40upx;
  103. text-align: center;
  104. font-size: 26upx;
  105. font-weight: bold;
  106. padding: 15upx 0 0;
  107. // border-bottom: 1upx solid #e1e1e1;
  108. }
  109. .content{
  110. padding:30upx;
  111. font-size: 24upx;
  112. color: #666;
  113. line-height: 35upx;
  114. text-align: center;
  115. }
  116. .btnbox{
  117. display: flex;
  118. .btn{
  119. font-size: 30upx;
  120. text-align: center;
  121. flex: auto;
  122. line-height: 80upx;
  123. border-top: 1upx solid #e1e1e1;
  124. border-right: 1upx solid #e1e1e1;
  125. }
  126. .btn:last-child{
  127. border-right:none;
  128. }
  129. .cancel{
  130. }
  131. }
  132. }
  133. }
  134. }
  135. </style>