import{s as t,n as i,q as s,o as e,c as o,w as n,t as a,A as r,v as m,x as p,G as u,R as h,i as l,H as f}from"./index-DL8B2Mxu.js";import{_ as c}from"./u-icon.CLOPtL2B.js";import{r as g}from"./uni-app.es.BSVEa1f2.js";import{_ as C}from"./_plugin-vue_export-helper.BCo6x5W8.js";const d=C({name:"u-toast",props:{zIndex:{type:[Number,String],default:""}},data:()=>({isShow:!1,timer:null,config:{params:{},title:"",type:"",duration:2e3,isTab:!1,url:"",icon:!0,position:"center",callback:null,back:!1},tmpConfig:{}}),computed:{iconName(){if(["error","warning","success","info"].indexOf(this.tmpConfig.type)>=0&&this.tmpConfig.icon){return this.$u.type2icon(this.tmpConfig.type)}},uZIndex(){return this.isShow?this.zIndex?this.zIndex:this.$u.zIndex.toast:"999999"}},methods:{show(t){this.tmpConfig=this.$u.deepMerge(this.config,t),this.timer&&(clearTimeout(this.timer),this.timer=null),this.isShow=!0,this.timer=setTimeout((()=>{this.isShow=!1,clearTimeout(this.timer),this.timer=null,"function"==typeof this.tmpConfig.callback&&this.tmpConfig.callback(),this.timeEnd()}),this.tmpConfig.duration)},hide(){this.isShow=!1,this.timer&&(clearTimeout(this.timer),this.timer=null)},timeEnd(){if(this.tmpConfig.url){if("/"!=this.tmpConfig.url[0]&&(this.tmpConfig.url="/"+this.tmpConfig.url),Object.keys(this.tmpConfig.params).length){let t="";/.*\/.*\?.*=.*/.test(this.tmpConfig.url)?(t=this.$u.queryParams(this.tmpConfig.params,!1),this.tmpConfig.url=this.tmpConfig.url+"&"+t):(t=this.$u.queryParams(this.tmpConfig.params),this.tmpConfig.url+=t)}this.tmpConfig.isTab?t({url:this.tmpConfig.url}):i({url:this.tmpConfig.url})}else this.tmpConfig.back&&this.$u.route({type:"back"})}}},[["render",function(t,i,C,d,y,x){const b=g(s("u-icon"),c),w=l,_=f;return e(),o(w,{class:u(["u-toast",[y.isShow?"u-show":"","u-type-"+y.tmpConfig.type,"u-position-"+y.tmpConfig.position]]),style:h({zIndex:x.uZIndex})},{default:n((()=>[a(w,{class:"u-icon-wrap"},{default:n((()=>[y.tmpConfig.icon?(e(),o(b,{key:0,class:"u-icon",name:x.iconName,size:30,color:y.tmpConfig.type},null,8,["name","color"])):r("",!0)])),_:1}),a(_,{class:"u-text"},{default:n((()=>[m(p(y.tmpConfig.title),1)])),_:1})])),_:1},8,["class","style"])}],["__scopeId","data-v-aa0b93e8"]]);export{d as _};
