让 showToast 可以回调 complete
This commit is contained in:
parent
ff7dc3ce3a
commit
6c3819c544
25
index.js
25
index.js
@ -78,22 +78,21 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
showToast({type, icon, image, title, duration}){
|
showToast({type, icon, image, title, duration, ...rest}){
|
||||||
let pageNow = getCurrentPages().pop()
|
let pageNow = this.$store ? this : getCurrentPages().pop()
|
||||||
if (pageNow.$refs && pageNow.$refs.toast) {
|
if (pageNow.$refs && pageNow.$refs.toast) { // 在 ios app 里,虽然能获得 pageNow,但是不存在 pageNow.$refs,不知为何。android app 没有测试
|
||||||
pageNow.$refs.toast.open({type, content:title, duration})
|
pageNow.$refs.toast.open({type, content:title, duration, ...rest})
|
||||||
}else {
|
}else {
|
||||||
// #ifndef APP-PLUS
|
// #ifdef APP-PLUS
|
||||||
|
if (uni.getSystemInfoSync().platform==='android') {
|
||||||
|
uni.showToast({icon:'none', title, duration, ...rest})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// #endif
|
||||||
if (!image){
|
if (!image){
|
||||||
image = `../static/Common.${type?type:'info'}.png`
|
image = `../static/Common.${type?type:'info'}.png`
|
||||||
}
|
}
|
||||||
uni.showToast({icon, image, title, duration})
|
uni.showToast({icon, image, title, duration, ...rest})
|
||||||
// #endif
|
|
||||||
// #ifdef APP-PLUS
|
|
||||||
if (uni.getSystemInfoSync().platform==='android') {
|
|
||||||
uni.showToast({icon:'none', title, duration})
|
|
||||||
}
|
|
||||||
// #endif
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -116,7 +115,7 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
formatPercent(value, decimal){
|
formatPercent(value, decimal){
|
||||||
return `${Number(value*100).toFixed(decimal||2)}%`
|
return `${Number(value*100).toFixed(decimal||2)}`
|
||||||
},
|
},
|
||||||
|
|
||||||
formatDate(date, format){
|
formatDate(date, format){
|
||||||
|
@ -47,7 +47,7 @@ based on
|
|||||||
this.popup_list.push(toast)
|
this.popup_list.push(toast)
|
||||||
|
|
||||||
if(!toast.clickable){
|
if(!toast.clickable){
|
||||||
this.disappear(toast.uuid,toast.duration)
|
this.disappear(toast.uuid,toast.duration,toast.complete)
|
||||||
}//可点击消失
|
}//可点击消失
|
||||||
else{
|
else{
|
||||||
this.$emit('uuidCallback',toast.uuid)
|
this.$emit('uuidCallback',toast.uuid)
|
||||||
@ -55,7 +55,7 @@ based on
|
|||||||
|
|
||||||
},
|
},
|
||||||
//自动消失
|
//自动消失
|
||||||
disappear:function(uuid,duration){
|
disappear:function(uuid,duration,complete){
|
||||||
//退出动画之后,短暂延迟后移除本元素
|
//退出动画之后,短暂延迟后移除本元素
|
||||||
this.fade_out_animator(uuid,duration).then(res=>{
|
this.fade_out_animator(uuid,duration).then(res=>{
|
||||||
setTimeout(()=>{
|
setTimeout(()=>{
|
||||||
@ -66,6 +66,9 @@ based on
|
|||||||
this.$forceUpdate()
|
this.$forceUpdate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (typeof(complete)==='function'){
|
||||||
|
complete()
|
||||||
|
}
|
||||||
},250)
|
},250)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user