acdr-ui/dist/build/mp-weixin/sheep/ui/su-popup/su-popup.js

2 lines
6.2 KiB
JavaScript
Raw Normal View History

2024-09-19 07:20:14 +08:00
"use strict";var t=Object.defineProperty,s=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,e=Object.prototype.propertyIsEnumerable,i=(s,o,e)=>o in s?t(s,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[o]=e,a=(t,a)=>{for(var r in a||(a={}))o.call(a,r)&&i(t,r,a[r]);if(s)for(var r of s(a))e.call(a,r)&&i(t,r,a[r]);return t};const r=require("../../index.js"),n=require("../../../common/vendor.js"),p={name:"SuPopup",components:{},emits:["change","maskClick","close"],props:{show:{type:Boolean,default:!1},space:{type:Number,default:0},round:{type:[String,Number],default:0},showClose:{type:Boolean,default:!1},animation:{type:Boolean,default:!0},type:{type:String,default:"bottom"},isMaskClick:{type:Boolean,default:null},maskClick:{type:Boolean,default:null},backgroundColor:{type:String,default:"#ffffff"},backgroundImage:{type:String,default:""},safeArea:{type:Boolean,default:!0},maskBackgroundColor:{type:String,default:"rgba(0, 0, 0, 0.4)"},zIndex:{type:[String,Number],default:10075}},watch:{show:{handler:function(t,s){(void 0!==s||t)&&(t?this.open():this.close())},immediate:!0},type:{handler:function(t){this.config[t]&&this[this.config[t]](!0)},immediate:!0},isDesktop:{handler:function(t){this.config[t]&&this[this.config[this.type]](!0)},immediate:!0},maskClick:{handler:function(t){this.mkclick=t},immediate:!0},isMaskClick:{handler:function(t){this.mkclick=t},immediate:!0},showPopup(t){}},data(){return{sheep:r.sheep,duration:300,ani:[],showPopup:!1,showTrans:!1,popupWidth:0,popupHeight:0,config:{top:"top",bottom:"bottom",center:"center",left:"left",right:"right",message:"top",dialog:"center",share:"bottom"},maskClass:{position:"fixed",bottom:0,top:0,left:0,right:0,backgroundColor:"rgba(0, 0, 0, 0.4)"},transClass:{position:"fixed",left:0,right:0},maskShow:!0,mkclick:!0,popupstyle:this.isDesktop?"fixforpc-top":"top"}},computed:{isDesktop(){return this.popupWidth>=500&&this.popupHeight>=500},bg(){return""===this.backgroundColor||"none"===this.backgroundColor?"transparent":this.backgroundColor},borderRadius(){if(this.round){if("bottom"===this.type)return{"border-top-left-radius":parseFloat(this.round)+"px","border-top-right-radius":parseFloat(this.round)+"px"};if("center"===this.type)return{"border-top-left-radius":parseFloat(this.round)+"px","border-top-right-radius":parseFloat(this.round)+"px","border-bottom-left-radius":parseFloat(this.round)+"px","border-bottom-right-radius":parseFloat(this.round)+"px"};if("top"===this.type)return{"border-bottom-left-radius":parseFloat(this.round)+"px","border-bottom-right-radius":parseFloat(this.round)+"px"}}}},mounted(){(()=>{const{windowWidth:t,windowHeight:s,windowTop:o,safeArea:e,screenHeight:i,safeAreaInsets:a}=r.sheep.$platform.device;this.popupWidth=t,this.popupHeight=s+(o||0),e&&this.safeArea?this.safeAreaInsets=i-e.bottom:this.safeAreaInsets=0})()},unmounted(){this.setH5Visible()},created(){null===this.isMaskClick&&null===this.maskClick?this.mkclick=!0:this.mkclick=null!==this.isMaskClick?this.isMaskClick:this.maskClick,this.animation?this.duration=300:this.duration=0,this.messageChild=null,this.clearPropagation=!1,this.maskClass.backgroundColor=this.maskBackgroundColor},methods:{setH5Visible(){},closeMask(){this.maskShow=!1},disableMask(){this.mkclick=!1},clear(t){t.stopPropagation(),this.clearPropagation=!0},open(t){this.showPopup&&(clearTimeout(this.timer),this.showPopup=!1);t&&-1!==["top","center","bottom","left","right","message","dialog","share"].indexOf(t)||(t=this.type),this.config[t]&&(this[this.config[t]](),this.$emit("change",{show:!0,type:t}))},close(t){this.showTrans=!1,this.$emit("change",{show:!1,type:this.type}),this.$emit("close"),clearTimeout(this.timer),this.timer=setTimeout((()=>{this.showPopup=!1}),300)},touchstart(){this.clearPropagation=!1},onTap(){this.clearPropagation?this.clearPropagation=!1:(this.$emit("maskClick"),this.mkclick&&this.close())},top(t){this.popupstyle=this.isDesktop?"fixforpc-top":"top",this.ani=["slide-top"],this.transClass={position:"fixed",left:0,right:0,top:this.space+"px",backgroundColor:this.bg},t||(this.showPopup=!