graceDialog.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <template>
  2. <view class="grace-dialog-shade" @tap.stop="closeDialogByShade" @touchmove.stop.prevent="stopFun"
  3. :style="{backgroundColor:background, zIndex:zIndex, height:showIn ?'100%':'0px'}">
  4. <view class="grace-dialog" :class="[showIn ? 'grace-shade-in' : 'grace-shade-out']" @tap.stop="stopFun"
  5. :style="{width:width, borderRadius:borderRadius}">
  6. <view class="grace-dialog-title" v-if="isTitle"
  7. :style="{
  8. fontSize:titleSize, color:titleColor, fontWeight:titleWeight?'bold':'',
  9. background:titleBg, lineHeight:titleHeight}">{{title}}</view>
  10. <view class="grace-dialog-content" @tap.stop="stopFun"><slot name="content"></slot></view>
  11. <view class="grace-dialog-close-btn"
  12. :style="{color:closeBtnColor, zIndex:zIndex+1}" v-if="isCloseBtn" @tap.stop="closeDialog"></view>
  13. <view v-if="isBtns"><slot name="btns"></slot></view>
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. export default {
  19. name: "graceDialog",
  20. props: {
  21. show : {
  22. type : Boolean,
  23. default : false
  24. },
  25. width : {
  26. type : String,
  27. default : '580rpx'
  28. },
  29. isCloseBtn: {
  30. type : Boolean,
  31. default : true
  32. },
  33. closeBtnColor : {
  34. type : String,
  35. default : '#FF0036'
  36. },
  37. isTitle : {
  38. type : Boolean,
  39. default : true
  40. },
  41. title : {
  42. type : String,
  43. default : ''
  44. },
  45. titleBg : {
  46. type : String,
  47. default : ''
  48. },
  49. titleHeight : {
  50. type : String,
  51. default : '100rpx'
  52. },
  53. titleWeight : {
  54. type : Boolean,
  55. default : true
  56. },
  57. titleSize : {
  58. type : String,
  59. default : '28rpx'
  60. },
  61. titleColor : {
  62. type : String,
  63. default : '#333333'
  64. },
  65. isBtns : {
  66. type : Boolean,
  67. default : true
  68. },
  69. background:{
  70. type : String,
  71. default : 'rgba(0, 0, 0, 0.5)'
  72. },
  73. borderRadius : {
  74. type : String,
  75. default : '6rpx'
  76. },
  77. zIndex : {
  78. type : Number,
  79. default : 99
  80. },
  81. canCloseByShade:{
  82. type : Boolean,
  83. default : true
  84. }
  85. },
  86. data() {
  87. return {
  88. showIn : false
  89. }
  90. },
  91. created:function(){
  92. this.showIn = this.show;
  93. },
  94. watch:{
  95. show:function (val) {
  96. if(val){this.open();}else{this.hide();}
  97. }
  98. },
  99. methods:{
  100. closeDialogByShade:function(){
  101. if(this.canCloseByShade){this.closeDialog();}
  102. },
  103. closeDialog : function(){
  104. this.$emit('closeDialog');
  105. },
  106. stopFun : function(){},
  107. open:function () {this.showIn = true;},
  108. hide:function () {this.showIn = false;}
  109. }
  110. }
  111. </script>
  112. <style scoped>
  113. .grace-dialog-shade{position:fixed; width:100%; height:100%; overflow:hidden; left:0; top:0; bottom:0; z-index:9991; display:flex; justify-content:center; align-items:center;}
  114. .grace-dialog{width:580rpx; background:#FFFFFF; position:relative; transition:all 200ms linear 0s;}
  115. .grace-dialog-title{line-height:100rpx; font-size:30rpx; text-align:center;}
  116. .grace-dialog-content{transition:all 200ms linear 0s;}
  117. .grace-dialog-close-btn{position:absolute; z-index:9993; right:0px; top:0px; font-size:30rpx; width:80rpx; height:80rpx; line-height:80rpx; text-align:center; font-family:"grace-iconfont";}
  118. .grace-dialog-close-btn:before{content:"\e632";}
  119. .grace-shade-in{animation:grace-shade-in-a 200ms linear forwards;}
  120. @keyframes grace-shade-in-a{0%{transform: scale(0.1); opacity:0;} 100%{transform: scale(1); opacity:1;}}
  121. .grace-shade-out{animation:grace-shade-out-a 200ms ease-out forwards;}
  122. @keyframes grace-shade-out-a{0%{transform: scale(1); opacity:1;} 100%{transform: scale(0.1); opacity:0;}}
  123. </style>