让unisocket通用化;把showToast(...)集成在 cToast库里
This commit is contained in:
@@ -33,10 +33,10 @@ based on
|
||||
methods:{
|
||||
open:function(toast){
|
||||
//生成uuid
|
||||
let uuid=this.guid();
|
||||
toast.uuid=uuid;
|
||||
let uuid=this.guid()
|
||||
toast.uuid=uuid
|
||||
//添加动画
|
||||
toast.animator='fade_Down';
|
||||
toast.animator='fade_Down'
|
||||
|
||||
toast.clickable = toast.clickable || false //判断是否可点击消失/可控制消失
|
||||
toast.duration = toast.duration || 1500
|
||||
@@ -44,13 +44,13 @@ based on
|
||||
toast.type = toast.type || 'info'
|
||||
|
||||
//添加进数组
|
||||
this.popup_list.push(toast);
|
||||
this.popup_list.push(toast)
|
||||
|
||||
if(!toast.clickable){
|
||||
this.disappear(toast.uuid,toast.duration);
|
||||
this.disappear(toast.uuid,toast.duration)
|
||||
}//可点击消失
|
||||
else{
|
||||
this.$emit('uuidCallback',toast.uuid);
|
||||
this.$emit('uuidCallback',toast.uuid)
|
||||
}
|
||||
|
||||
},
|
||||
@@ -62,23 +62,23 @@ based on
|
||||
for(let i=0;i<this.popup_list.length;i++){
|
||||
if(this.popup_list[i].uuid==res){
|
||||
//移除本元素
|
||||
this.popup_list.splice(i,1);
|
||||
this.popup_list.splice(i,1)
|
||||
this.$forceUpdate()
|
||||
}
|
||||
}
|
||||
},250)
|
||||
});
|
||||
})
|
||||
},
|
||||
fade_out_animator:function(uuid,duration){
|
||||
//duration秒后退出
|
||||
if(!duration||typeof(duration)!='number'){duration=1500;}
|
||||
if(!duration||typeof(duration)!='number'){duration=1500}
|
||||
return new Promise(res=>{
|
||||
setTimeout(()=>{
|
||||
for(let i=0;i<this.popup_list.length;i++){
|
||||
if(this.popup_list[i].uuid==uuid){
|
||||
//添加退出动画
|
||||
this.popup_list[i].animator='fade_Top';
|
||||
res(uuid);
|
||||
this.popup_list[i].animator='fade_Top'
|
||||
res(uuid)
|
||||
}
|
||||
}
|
||||
},duration)
|
||||
@@ -94,8 +94,8 @@ based on
|
||||
for(let i=0;i<this.popup_list.length;i++){
|
||||
if(this.popup_list[i].uuid==res){
|
||||
//移除本元素
|
||||
this.popup_list.splice(i,1);
|
||||
this.$emit('closeCallback',uuid);
|
||||
this.popup_list.splice(i,1)
|
||||
this.$emit('closeCallback',uuid)
|
||||
this.$forceUpdate()
|
||||
}
|
||||
}
|
||||
@@ -107,9 +107,9 @@ based on
|
||||
return new Promise(res=>{
|
||||
for (var i = 0; i < this.popup_list.length; i++) {
|
||||
if(this.popup_list[i].uuid==uuid){
|
||||
this.popup_list[i].animator='fade_Top';
|
||||
this.popup_list[i].animator='fade_Top'
|
||||
res(uuid)
|
||||
break;
|
||||
break
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -120,18 +120,18 @@ based on
|
||||
for (var i = 0; i < this.popup_list.length; i++) {
|
||||
if(this.popup_list[i].uuid==update_list.uuid){
|
||||
this.popup_list[i].type=update_list.type;
|
||||
this.init(this.popup_list[i]);
|
||||
this.popup_list[i].content=update_list.content;
|
||||
break;
|
||||
this.init(this.popup_list[i])
|
||||
this.popup_list[i].content=update_list.content
|
||||
break
|
||||
}
|
||||
}
|
||||
},
|
||||
//生成uuid
|
||||
guid:function() {
|
||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
||||
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
|
||||
return v.toString(16);
|
||||
});
|
||||
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8)
|
||||
return v.toString(16)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user