优化utils的toast

This commit is contained in:
TOP糯米 2023-03-08 14:55:21 +08:00
parent 63d313ed2f
commit 2a85c906dd
1 changed files with 17 additions and 4 deletions

View File

@ -187,11 +187,24 @@ function toPage(url, options, type) {
}
}
let toastTimer;
function toast(title, options) {
if (typeof options === "undefined") {
options = {};
}
return new Promise((resolve, reject) => {
if (!options.duration) {
options.duration = 1500;
}
uni.showToast({
...{ title: title, icon: "none" },
...options
});
clearTimeout(toastTimer);
toastTimer = setTimeout(() => {
resolve();
}, options.duration);
})
}
function formatNumber(num, limit) {