2026-05-28 09:48:42 +08:00

2 lines
4.9 KiB
JavaScript

"use strict";const t=require("../../../../common/vendor.js"),o={name:"u-popup",mixins:[t.mpMixin,t.mixin,t.props$11],data(){return{overlayDuration:this.duration+50,touchStartY:0,touchStartHeight:0,isTouching:!1,currentHeight:"auto"}},watch:{show(t,o){if(!0===t){const t=this.$children;this.retryComputedComponentRect(t)}}},computed:{transitionStyle(){const o={display:"flex"};return this.pageInline||(o.zIndex=this.zIndex,o.position="fixed"),o[this.mode]=0,"left"===this.mode||"right"===this.mode?t.deepMerge(o,{bottom:0,top:0}):"top"===this.mode||"bottom"===this.mode?t.deepMerge(o,{left:0,right:0}):"center"===this.mode?t.deepMerge(o,{alignItems:"center","justify-content":"center",top:0,left:0,right:0,bottom:0}):void 0},contentStyleWrap(){const o={};return"bottom"===this.mode&&this.touchable&&("auto"!==this.currentHeight&&(o.height=this.currentHeight),this.maxHeight&&(o.maxHeight=t.addUnit(this.maxHeight)),this.minHeight&&(o.minHeight=t.addUnit(this.minHeight))),o},contentStyle(){const o={};if(t.getWindowInfo(),"center"!==this.mode&&(o.flex=1),o.backgroundColor=this.bgColor,this.round){const e=t.addUnit(this.round);"top"===this.mode?(o.borderBottomLeftRadius=e,o.borderBottomRightRadius=e):"bottom"===this.mode?(o.borderTopLeftRadius=e,o.borderTopRightRadius=e):"center"===this.mode&&(o.borderRadius=e)}return t.deepMerge(o,t.addStyle(this.customStyle))},position(){return"center"===this.mode?this.zoom?"fade-zoom":"fade":"left"===this.mode?"slide-left":"right"===this.mode?"slide-right":"bottom"===this.mode?"slide-up":"top"===this.mode?"slide-down":void 0}},emits:["open","close","click","update:show"],methods:{overlayClick(){this.closeOnClickOverlay&&(this.$emit("update:show",!1),this.$emit("close"))},open(t){this.$emit("update:show",!0)},close(t){this.$emit("update:show",!1),this.$emit("close")},afterEnter(){this.$emit("open")},clickHandler(){"center"===this.mode&&this.overlayClick(),this.$emit("click")},retryComputedComponentRect(o){const e=["u-calendar-month","u-album","u-collapse-item","u-dropdown","u-index-item","u-index-list","u-line-progress","u-list-item","u-rate","u-read-more","u-row","u-row-notice","u-scroll-list","u-skeleton","u-slider","u-steps-item","u-sticky","u-subsection","u-swipe-action-item","u-tabbar","u-tabs","u-tooltip"];for(let i=0;i<o.length;i++){const n=o[i],s=n.$children;e.includes(n.$options.name)&&"function"==typeof(null==n?void 0:n.init)&&t.sleep(50).then(()=>{n.init()}),s.length&&this.retryComputedComponentRect(s)}},onTouchStart(t){this.touchable&&"bottom"===this.mode&&(this.isTouching=!0,this.touchStartY=t.touches[0].clientY,this.touchStartHeight=this.$el.querySelector(".u-popup__content—transition").offsetHeight)},onTouchMove(o){if(!this.isTouching||!this.touchable||"bottom"!==this.mode)return;const e=o.touches[0].clientY-this.touchStartY;if(0!==e){const o=this.touchStartHeight-e,i=parseFloat(t.addUnit(this.minHeight))||200,n=this.maxHeight?this.maxHeight.toString().includes("%")?t.getWindowInfo().windowHeight*(parseFloat(this.maxHeight)/100):parseFloat(t.addUnit(this.maxHeight)):.8*t.getWindowInfo().windowHeight;o>=i&&o<=n&&(this.currentHeight=o+"px")}o.preventDefault()},onTouchEnd(t){if(!this.isTouching||!this.touchable||"bottom"!==this.mode)return;this.isTouching=!1;const o=t.changedTouches[0].clientY-this.touchStartY,e=Math.abs(o)/(t.timeStamp-t.changedTouches[0].timestamp);(o>100||o>30&&e>.5)&&this.close()}}};if(!Array){(t.resolveComponent("u-overlay")+t.resolveComponent("u-status-bar")+t.resolveComponent("up-icon")+t.resolveComponent("u-safe-bottom")+t.resolveComponent("u-transition"))()}Math||((()=>"../u-overlay/u-overlay.js")+(()=>"../u-status-bar/u-status-bar.js")+(()=>"../u-icon/u-icon.js")+(()=>"../u-safe-bottom/u-safe-bottom.js")+(()=>"../u-transition/u-transition.js"))();const e=t._export_sfc(o,[["render",function(o,e,i,n,s,h){return t.e({a:t.o((...t)=>h.open&&h.open(...t)),b:o.overlay},o.overlay?{c:t.o(h.overlayClick),d:t.p({show:o.show&&0==o.pageInline,zIndex:o.zIndex,duration:s.overlayDuration,customStyle:o.overlayStyle,opacity:o.overlayOpacity})}:{},{e:o.safeAreaInsetTop},(o.safeAreaInsetTop,{}),{f:o.touchable&&"bottom"===o.mode},o.touchable&&"bottom"===o.mode?{g:t.o((...t)=>h.onTouchStart&&h.onTouchStart(...t)),h:t.o((...t)=>h.onTouchMove&&h.onTouchMove(...t)),i:t.o((...t)=>h.onTouchEnd&&h.onTouchEnd(...t)),j:t.o((...t)=>h.onTouchEnd&&h.onTouchEnd(...t))}:{},{k:o.closeable},o.closeable?{l:t.p({name:"close",color:"#909399",size:"18",bold:!0}),m:t.o((...t)=>h.close&&h.close(...t)),n:t.n("u-popup__content__close--"+o.closeIconPos)}:{},{o:o.safeAreaInsetBottom},(o.safeAreaInsetBottom,{}),{p:t.s(h.contentStyle),q:t.o((...t)=>o.noop&&o.noop(...t)),r:t.o((...t)=>o.noop&&o.noop(...t)),s:t.s(h.contentStyleWrap),t:t.o(h.afterEnter),v:t.o(h.clickHandler),w:t.p({show:!!o.pageInline||o.show,customStyle:h.transitionStyle,mode:o.pageInline?"none":h.position,duration:o.duration}),x:t.n(o.customClass),y:0==o.show?"0px":"",z:0==o.show?"0px":""})}],["__scopeId","data-v-37f0266c"]]);wx.createComponent(e);