index.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <template>
  2. <uni-shadow-root class="vant-popup-index"><van-overlay v-if="overlay" :show="show" :z-index="zIndex" :custom-style="overlayStyle" :duration="duration" @click="onClickOverlay" :lock-scroll="lockScroll" :root-portal="rootPortal"></van-overlay>
  3. <root-portal v-if="rootPortal">
  4. <include src="./popup.wxml"></include>
  5. </root-portal>
  6. <include v-else src="./popup.wxml"></include></uni-shadow-root>
  7. </template>
  8. <wxs src="../wxs/utils.wxs" module="utils"></wxs><wxs src="./index.wxs" module="computed"></wxs>
  9. <script>
  10. const __wxTemplateComponentProps = {}
  11. import __wxTemplateComponent0 from './popup.vue'
  12. import VanIcon from '../icon/index.vue'
  13. import VanOverlay from '../overlay/index.vue'
  14. global['__wxVueOptions'] = {components:{'van-icon': VanIcon,'van-overlay': VanOverlay,}}
  15. global['__wxRoute'] = 'vant/popup/index'
  16. import { VantComponent } from '../common/component';
  17. import { transition } from '../mixins/transition';
  18. VantComponent({
  19. classes: [
  20. 'enter-class',
  21. 'enter-active-class',
  22. 'enter-to-class',
  23. 'leave-class',
  24. 'leave-active-class',
  25. 'leave-to-class',
  26. 'close-icon-class',
  27. ],
  28. mixins: [transition(false)],
  29. props: {
  30. round: Boolean,
  31. closeable: Boolean,
  32. customStyle: String,
  33. overlayStyle: String,
  34. transition: {
  35. type: String,
  36. observer: 'observeClass',
  37. },
  38. zIndex: {
  39. type: Number,
  40. value: 100,
  41. },
  42. overlay: {
  43. type: Boolean,
  44. value: true,
  45. },
  46. closeIcon: {
  47. type: String,
  48. value: 'cross',
  49. },
  50. closeIconPosition: {
  51. type: String,
  52. value: 'top-right',
  53. },
  54. closeOnClickOverlay: {
  55. type: Boolean,
  56. value: true,
  57. },
  58. position: {
  59. type: String,
  60. value: 'center',
  61. observer: 'observeClass',
  62. },
  63. safeAreaInsetBottom: {
  64. type: Boolean,
  65. value: true,
  66. },
  67. safeAreaInsetTop: {
  68. type: Boolean,
  69. value: false,
  70. },
  71. safeAreaTabBar: {
  72. type: Boolean,
  73. value: false,
  74. },
  75. lockScroll: {
  76. type: Boolean,
  77. value: true,
  78. },
  79. rootPortal: {
  80. type: Boolean,
  81. value: false,
  82. },
  83. },
  84. created() {
  85. this.observeClass();
  86. },
  87. methods: {
  88. onClickCloseIcon() {
  89. this.$emit('close');
  90. },
  91. onClickOverlay() {
  92. this.$emit('click-overlay');
  93. if (this.data.closeOnClickOverlay) {
  94. this.$emit('close');
  95. }
  96. },
  97. observeClass() {
  98. const { transition, position, duration } = this.data;
  99. const updateData = {
  100. name: transition || position,
  101. };
  102. if (transition === 'none') {
  103. updateData.duration = 0;
  104. this.originDuration = duration;
  105. }
  106. else if (this.originDuration != null) {
  107. updateData.duration = this.originDuration;
  108. }
  109. this.setData(updateData);
  110. },
  111. },
  112. });
  113. export default global['__wxComponents']['vant/popup/index']
  114. </script>
  115. <style platform="mp-weixin">
  116. @import '../common/index.css';.van-popup{-webkit-overflow-scrolling:touch;animation:ease both;background-color:var(--popup-background-color,#fff);box-sizing:border-box;max-height:100%;overflow-y:auto;position:fixed;transition-timing-function:ease}.van-popup--center{left:50%;top:50%;transform:translate3d(-50%,-50%,0)}.van-popup--center.van-popup--round{border-radius:var(--popup-round-border-radius,16px)}.van-popup--top{left:0;top:0;width:100%}.van-popup--top.van-popup--round{border-radius:0 0 var(--popup-round-border-radius,var(--popup-round-border-radius,16px)) var(--popup-round-border-radius,var(--popup-round-border-radius,16px))}.van-popup--right{right:0;top:50%;transform:translate3d(0,-50%,0)}.van-popup--right.van-popup--round{border-radius:var(--popup-round-border-radius,var(--popup-round-border-radius,16px)) 0 0 var(--popup-round-border-radius,var(--popup-round-border-radius,16px))}.van-popup--bottom{bottom:0;left:0;width:100%}.van-popup--bottom.van-popup--round{border-radius:var(--popup-round-border-radius,var(--popup-round-border-radius,16px)) var(--popup-round-border-radius,var(--popup-round-border-radius,16px)) 0 0}.van-popup--left{left:0;top:50%;transform:translate3d(0,-50%,0)}.van-popup--left.van-popup--round{border-radius:0 var(--popup-round-border-radius,var(--popup-round-border-radius,16px)) var(--popup-round-border-radius,var(--popup-round-border-radius,16px)) 0}.van-popup--bottom.van-popup--safe{padding-bottom:env(safe-area-inset-bottom)}.van-popup--bottom.van-popup--safeTabBar,.van-popup--top.van-popup--safeTabBar{bottom:var(--tabbar-height,50px)}.van-popup--safeTop{padding-top:env(safe-area-inset-top)}.van-popup__close-icon{color:var(--popup-close-icon-color,#969799);font-size:var(--popup-close-icon-size,18px);position:absolute;z-index:var(--popup-close-icon-z-index,1)}.van-popup__close-icon--top-left{left:var(--popup-close-icon-margin,16px);top:var(--popup-close-icon-margin,16px)}.van-popup__close-icon--top-right{right:var(--popup-close-icon-margin,16px);top:var(--popup-close-icon-margin,16px)}.van-popup__close-icon--bottom-left{bottom:var(--popup-close-icon-margin,16px);left:var(--popup-close-icon-margin,16px)}.van-popup__close-icon--bottom-right{bottom:var(--popup-close-icon-margin,16px);right:var(--popup-close-icon-margin,16px)}.van-popup__close-icon:active{opacity:.6}.van-scale-enter-active,.van-scale-leave-active{transition-property:opacity,transform}.van-scale-enter,.van-scale-leave-to{opacity:0;transform:translate3d(-50%,-50%,0) scale(.7)}.van-fade-enter-active,.van-fade-leave-active{transition-property:opacity}.van-fade-enter,.van-fade-leave-to{opacity:0}.van-center-enter-active,.van-center-leave-active{transition-property:opacity}.van-center-enter,.van-center-leave-to{opacity:0}.van-bottom-enter-active,.van-bottom-leave-active,.van-left-enter-active,.van-left-leave-active,.van-right-enter-active,.van-right-leave-active,.van-top-enter-active,.van-top-leave-active{transition-property:transform}.van-bottom-enter,.van-bottom-leave-to{transform:translate3d(0,100%,0)}.van-top-enter,.van-top-leave-to{transform:translate3d(0,-100%,0)}.van-left-enter,.van-left-leave-to{transform:translate3d(-100%,-50%,0)}.van-right-enter,.van-right-leave-to{transform:translate3d(100%,-50%,0)}
  117. </style>