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