tm-maskFlow.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <template>
  2. <view class="tm-maskFlow" :style="{
  3. width:width+'px',
  4. height:height+'px'
  5. }" v-if="show">
  6. <tm-translate @start="$emit('start')" :duration="duration" :wait="0" :animation-name="aniName">
  7. <view @click.stop="closeMask" class="tm-maskFlow-mask" :style="{
  8. background:bgColor,
  9. width:width+'px',
  10. height:height+'px'
  11. }"></view>
  12. <view @click.stop="closeMask" class="tm-maskFlow-body flex-center">
  13. <view @click.stop="">
  14. <slot></slot>
  15. </view>
  16. </view>
  17. </tm-translate>
  18. </view>
  19. </template>
  20. <script>
  21. /**
  22. * 黑色遮罩
  23. * @property {String} bg-color = [rgba(0,0,0,0.35)] 默认:rgba(0,0,0,0.35),背景颜色值。
  24. * @property {Boolean} close = [] 默认:true,点击遮罩是否关闭。
  25. * @property {Boolean} blur = [] 默认:true,是否显示模糊背景。
  26. * @property {Boolean} value = [] 默认:false,推荐使用value.sync或者v-model,来控制显示和关闭。
  27. * @property {Function} change 和v-model同步,显示 和隐藏时触发,返回当前变化 参数true显示,false关闭。
  28. * @example <tm-maskFlow v-model="show"></tm-maskFlow>
  29. */
  30. import tmTranslate from "@/tm-vuetify/components/tm-translate/tm-translate.vue"
  31. export default {
  32. components:{tmTranslate},
  33. name: 'tm-maskFlow',
  34. model: {
  35. prop: "value",
  36. event: 'input'
  37. },
  38. props: {
  39. bgColor: {
  40. type: String,
  41. default: 'rgba(0,0,0,0.35)'
  42. },
  43. close: {
  44. type: Boolean,
  45. default: true
  46. },
  47. value: {
  48. type: Boolean,
  49. default: false
  50. },
  51. duration:{
  52. type:Number,
  53. default:300
  54. },
  55. blur:{
  56. type:Boolean|String,
  57. default:true,
  58. }
  59. },
  60. data() {
  61. return {
  62. width: 0,
  63. height: 0,
  64. aniName: 'fadeIn'
  65. };
  66. },
  67. created() {
  68. let syinfo = uni.getSystemInfoSync();
  69. this.width = syinfo.screenWidth;
  70. this.height = syinfo.screenHeight;
  71. },
  72. watch:{
  73. show:function(){
  74. this.$emit("input", this.value)
  75. this.$emit("change", this.value)
  76. this.$emit("update:value", this.value)
  77. }
  78. },
  79. computed: {
  80. show: {
  81. get: function() {
  82. return this.value;
  83. },
  84. set: function(val) {
  85. this.$emit("input", val)
  86. this.$emit("change", val)
  87. this.$emit("update:value", val)
  88. },
  89. }
  90. },
  91. methods: {
  92. closeMask() {
  93. if (!this.close) return;
  94. this.show = false;
  95. }
  96. },
  97. }
  98. </script>
  99. <style lang="scss" scoped>
  100. .tm-maskFlow {
  101. position: fixed;
  102. left: 0;
  103. top: 0;
  104. z-index: 500;
  105. .tm-maskFlow-mask {
  106. left: 0;
  107. top: 0;
  108. width: 100%;
  109. height: 100%;
  110. .blur{
  111. backdrop-filter:blur(3px);
  112. }
  113. }
  114. .tm-maskFlow-body {
  115. position: absolute;
  116. left: 0;
  117. top: 0;
  118. width: 100%;
  119. height: 100%;
  120. overflow-y: auto;
  121. }
  122. }
  123. </style>