tui-landscape.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <view class="tui-landscape__box">
  3. <view class="tui-landscape__inner" :style="{zIndex:zIndex}" v-if="show">
  4. <slot></slot>
  5. <view class="tui-icon__close"
  6. :style="{top:position!=1?iconTop:'auto',bottom:position==1?iconBottom:'auto',left:position==3?iconLeft:(position==1?'50%':'auto'),right:position==2?iconRight:'auto'}"
  7. :class="{'tui-icon__bottom':position==1}" v-if="closeIcon" @tap.stop="close">
  8. <icon type="clear" :color="iconColor" :size="iconSize"></icon>
  9. </view>
  10. </view>
  11. <view :style="{backgroundColor:maskBgColor,zIndex:maskZIndex}" @tap.stop="close(1)" class="tui-landscape__mask"
  12. :class="{'tui-mask_hidden':!show}" v-if="mask"></view>
  13. </view>
  14. </template>
  15. <script>
  16. export default {
  17. name: "tui-landscape",
  18. emits: ['close'],
  19. props: {
  20. //是否显示
  21. show: {
  22. type: Boolean,
  23. default: false
  24. },
  25. //显示内容区z-index
  26. zIndex: {
  27. type: Number,
  28. default: 1001
  29. },
  30. //是否需要关闭图标
  31. closeIcon: {
  32. type: Boolean,
  33. default: true
  34. },
  35. //关闭图标颜色
  36. iconColor: {
  37. type: String,
  38. default: '#fff'
  39. },
  40. //关闭图标大小 px
  41. iconSize: {
  42. type: Number,
  43. default: 25
  44. },
  45. //icon位置:1-底部 2-右上角 3-左上角
  46. position: {
  47. type: [Number, String],
  48. default: 1
  49. },
  50. //关闭图标top值,position为2或3的时候生效
  51. iconTop: {
  52. type: String,
  53. default: '-120rpx'
  54. },
  55. //关闭图标bottom值,position为1的时候生效
  56. iconBottom: {
  57. type: String,
  58. default: '-120rpx'
  59. },
  60. //关闭图标left值,position为3的时候生效
  61. iconLeft: {
  62. type: String,
  63. default: '0'
  64. },
  65. //关闭图标right值,position为2的时候生效
  66. iconRight: {
  67. type: String,
  68. default: '0'
  69. },
  70. //点击遮罩是否可以关闭
  71. maskClosable: {
  72. type: Boolean,
  73. default: true
  74. },
  75. //是否需要遮罩
  76. mask: {
  77. type: Boolean,
  78. default: true
  79. },
  80. //遮罩背景色
  81. maskBgColor: {
  82. type: String,
  83. default: 'rgba(0,0,0,.6)'
  84. },
  85. //遮罩z-index值
  86. maskZIndex: {
  87. type: Number,
  88. default: 1000
  89. },
  90. //自定义参数
  91. params: {
  92. type: [Number, String],
  93. default: 0
  94. }
  95. },
  96. methods: {
  97. close(isMask) {
  98. if (isMask == 1 && !this.maskClosable) return;
  99. this.$emit('close', {
  100. params: this.params
  101. });
  102. }
  103. }
  104. }
  105. </script>
  106. <style scoped>
  107. .tui-landscape__box {
  108. width: 100%;
  109. box-sizing: border-box;
  110. overflow: hidden;
  111. }
  112. .tui-landscape__inner {
  113. max-width: 100%;
  114. position: fixed;
  115. box-sizing: border-box;
  116. display: inline-flex;
  117. align-items: center;
  118. justify-content: center;
  119. flex-direction: column;
  120. left: 50%;
  121. top: 50%;
  122. transform: translate(-50%, -50%);
  123. }
  124. .tui-icon__close {
  125. display: inline-flex;
  126. align-items: center;
  127. justify-content: center;
  128. text-align: center;
  129. position: absolute;
  130. z-index: 10;
  131. }
  132. .tui-icon__bottom {
  133. left: 50% !important;
  134. transform: translateX(-50%);
  135. }
  136. .tui-landscape__mask {
  137. position: fixed;
  138. z-index: 1000;
  139. top: 0;
  140. right: 0;
  141. left: 0;
  142. bottom: 0;
  143. opacity: 1;
  144. transform: scale3d(1, 1, 1);
  145. transition: all .2s ease-in
  146. }
  147. .tui-mask_hidden {
  148. opacity: 0 !important;
  149. transform: scale3d(1, 1, 0) !important;
  150. }
  151. </style>