优化utils的toast
This commit is contained in:
parent
63d313ed2f
commit
2a85c906dd
|
@ -187,11 +187,24 @@ function toPage(url, options, type) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let toastTimer;
|
||||||
function toast(title, options) {
|
function toast(title, options) {
|
||||||
|
if (typeof options === "undefined") {
|
||||||
|
options = {};
|
||||||
|
}
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
if (!options.duration) {
|
||||||
|
options.duration = 1500;
|
||||||
|
}
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
...{ title: title, icon: "none" },
|
...{ title: title, icon: "none" },
|
||||||
...options
|
...options
|
||||||
});
|
});
|
||||||
|
clearTimeout(toastTimer);
|
||||||
|
toastTimer = setTimeout(() => {
|
||||||
|
resolve();
|
||||||
|
}, options.duration);
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatNumber(num, limit) {
|
function formatNumber(num, limit) {
|
||||||
|
|
Loading…
Reference in New Issue