index.vue 5.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <template>
  2. <uni-shadow-root class="vant-popup-index"><van-overlay v-if="overlay" mask :show="show" :z-index="zIndex" :custom-style="overlayStyle" :duration="duration" @click="onClickOverlay"></van-overlay>
  3. <view v-if="inited" :class="'custom-class '+(classes)+' '+(utils.bem('popup', [position, { safe: isIPhoneX && safeAreaInsetBottom }]))" :style="'z-index: '+(zIndex)+'; -webkit-transition-duration:'+(currentDuration)+'ms; transition-duration:'+(currentDuration)+'ms; '+(display ? '' : 'display: none;')+' '+(customStyle)" @transitionend="onTransitionEnd">
  4. <view v-if="safeAreaInsetTop" class="van-popup__safe-top" :style="'padding-top: '+(statusBarHeight)+'px;'"></view>
  5. <slot></slot>
  6. </view></uni-shadow-root>
  7. </template>
  8. <wxs src="../wxs/utils.wxs" module="utils"></wxs>
  9. <script>
  10. import VanOverlay from '../overlay/index.vue'
  11. global['__wxVueOptions'] = {components:{'van-overlay': VanOverlay}}
  12. global['__wxRoute'] = 'vant/popup/index'
  13. import { VantComponent } from '../common/component';
  14. import { transition } from '../mixins/transition';
  15. import { safeArea } from '../mixins/safe-area';
  16. VantComponent({
  17. classes: [
  18. 'enter-class',
  19. 'enter-active-class',
  20. 'enter-to-class',
  21. 'leave-class',
  22. 'leave-active-class',
  23. 'leave-to-class'
  24. ],
  25. mixins: [transition(false), safeArea()],
  26. props: {
  27. transition: {
  28. type: String,
  29. observer: 'observeClass'
  30. },
  31. customStyle: String,
  32. overlayStyle: String,
  33. zIndex: {
  34. type: Number,
  35. value: 100
  36. },
  37. overlay: {
  38. type: Boolean,
  39. value: true
  40. },
  41. closeOnClickOverlay: {
  42. type: Boolean,
  43. value: true
  44. },
  45. position: {
  46. type: String,
  47. value: 'center',
  48. observer: 'observeClass'
  49. }
  50. },
  51. created() {
  52. this.observeClass();
  53. },
  54. methods: {
  55. onClickOverlay() {
  56. this.$emit('click-overlay');
  57. if (this.data.closeOnClickOverlay) {
  58. this.$emit('close');
  59. }
  60. },
  61. observeClass() {
  62. const { transition, position } = this.data;
  63. const updateData = {
  64. name: transition || position
  65. };
  66. if (transition === 'none') {
  67. updateData.duration = 0;
  68. }
  69. this.set(updateData);
  70. }
  71. }
  72. });
  73. export default global['__wxComponents']['vant/popup/index']
  74. </script>
  75. <style platform="mp-weixin">
  76. @import '../common/index.css';.van-popup{position:fixed;top:50%;left:50%;max-height:100%;overflow-y:auto;background-color:#fff;box-sizing:border-box;-webkit-animation:ease both;animation:ease both;-webkit-overflow-scrolling:touch;transition-timing-function:ease}.van-popup--center{-webkit-transform:translate3d(-50%,-50%,0);transform:translate3d(-50%,-50%,0)}.van-popup--top{top:0;right:auto;bottom:auto;left:50%;width:100%;-webkit-transform:translate3d(-50%,0,0);transform:translate3d(-50%,0,0)}.van-popup--right{top:50%;right:0;bottom:auto;left:auto;-webkit-transform:translate3d(0,-50%,0);transform:translate3d(0,-50%,0)}.van-popup--bottom{top:auto;right:auto;bottom:0;left:50%;width:100%;-webkit-transform:translate3d(-50%,0,0);transform:translate3d(-50%,0,0)}.van-popup--left{top:50%;right:auto;bottom:auto;left:0;-webkit-transform:translate3d(0,-50%,0);transform:translate3d(0,-50%,0)}.van-popup--bottom.van-popup--safe{padding-bottom:34px}.van-popup--left .van-popup__safe-top,.van-popup--right .van-popup__safe-top,.van-popup--top .van-popup__safe-top{height:44px}.van-popup--bottom .van-popup__safe-top,.van-popup--center .van-popup__safe-top{padding-top:0!important}.van-scale-enter-active,.van-scale-leave-active{transition-property:opacity,-webkit-transform;transition-property:opacity,transform;transition-property:opacity,transform,-webkit-transform}.van-scale-enter,.van-scale-leave-to{opacity:0;-webkit-transform:translate3d(-50%,-50%,0) scale(.7);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:-webkit-transform;transition-property:transform;transition-property:transform,-webkit-transform}.van-bottom-enter,.van-bottom-leave-to{-webkit-transform:translate3d(-50%,100%,0);transform:translate3d(-50%,100%,0)}.van-top-enter,.van-top-leave-to{-webkit-transform:translate3d(-50%,-100%,0);transform:translate3d(-50%,-100%,0)}.van-left-enter,.van-left-leave-to{-webkit-transform:translate3d(-100%,-50%,0);transform:translate3d(-100%,-50%,0)}.van-right-enter,.van-right-leave-to{-webkit-transform:translate3d(100%,-50%,0);transform:translate3d(100%,-50%,0)}
  77. </style>