From 76a58883be638df4c5b1a3ce9e1ad1e829526e33 Mon Sep 17 00:00:00 2001 From: Luk Lu Date: Sun, 24 May 2020 09:18:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=20showToast=EF=BC=8C?= =?UTF-8?q?=E8=B0=83=E7=94=A8getCurrentPages()=E8=8E=B7=E5=8F=96=E5=BD=93?= =?UTF-8?q?=E5=89=8D=E9=A1=B5=E9=9D=A2=EF=BC=8C=E4=BD=BF=E5=BE=97=E4=B8=8D?= =?UTF-8?q?=E9=9C=80=E8=A6=81=20call(this,=20...)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cToast/cToast.js | 17 ----------------- index.js | 22 +++++++++++++++++++++- 2 files changed, 21 insertions(+), 18 deletions(-) delete mode 100644 cToast/cToast.js diff --git a/cToast/cToast.js b/cToast/cToast.js deleted file mode 100644 index 93bdbe4..0000000 --- a/cToast/cToast.js +++ /dev/null @@ -1,17 +0,0 @@ -module.exports = function showToast({type, icon, image, title, duration}){ - if (this.$refs && this.$refs.toast) { - this.$refs.toast.open({type, content:title, duration}) - }else { - // #ifndef APP-PLUS - if (!image){ - image = `../static/Common.${type?type:'info'}.png` - } - uni.showToast({icon, image, title, duration}) - // #endif - // #ifdef APP-PLUS - if (uni.getSystemInfoSync().platform==='android') { - uni.showToast({icon:'none', title, duration}) - } - // #endif - } -} \ No newline at end of file diff --git a/index.js b/index.js index 9e576e0..82f868f 100644 --- a/index.js +++ b/index.js @@ -72,5 +72,25 @@ module.exports = { default: return 'unknown' } }, - + + showToast({type, icon, image, title, duration}){ + let pageStack = getCurrentPages() + let pageNow = pageStack[pageStack.length-1] + if (pageNow.$refs && pageNow.$refs.toast) { + pageNow.$refs.toast.open({type, content:title, duration}) + }else { + // #ifndef APP-PLUS + if (!image){ + image = `../static/Common.${type?type:'info'}.png` + } + uni.showToast({icon, image, title, duration}) + // #endif + // #ifdef APP-PLUS + if (uni.getSystemInfoSync().platform==='android') { + uni.showToast({icon:'none', title, duration}) + } + // #endif + } + }, + } \ No newline at end of file