diff --git a/packages/uni-stat/dist/index.js b/packages/uni-stat/dist/index.js index e97f0a6e45517294a03718b2830ba7520a3916d0..f943cba931c5ed914fa43e4b0a69c7b67e2e00a8 100644 --- a/packages/uni-stat/dist/index.js +++ b/packages/uni-stat/dist/index.js @@ -836,7 +836,15 @@ const lifecycle = { stat.ready(this); }, onLoad(options) { - stat.load(options, this); + stat.load(options, this); + // 重写分享,获取分享上报事件 + if (this.$scope && this.$scope.onShareAppMessage) { + let oldShareAppMessage = this.$scope.onShareAppMessage; + this.$scope.onShareAppMessage = function(options) { + stat.interceptShare(false); + return oldShareAppMessage.call(this, options) + }; + } }, onShow() { isHide = false; @@ -855,9 +863,6 @@ const lifecycle = { }, onError(e) { stat.error(e); - }, - onShareAppMessage() { - stat.interceptShare(false); } }; diff --git a/packages/uni-stat/src/index.js b/packages/uni-stat/src/index.js index ba2b4026cb3ba23bda3265d53c54c12cfd62b0d9..5b4a027ddfb23b1d3aa55f7b9074f5ec31e1c3fe 100644 --- a/packages/uni-stat/src/index.js +++ b/packages/uni-stat/src/index.js @@ -9,7 +9,15 @@ const lifecycle = { stat.ready(this); }, onLoad(options) { - stat.load(options, this); + stat.load(options, this); + // 重写分享,获取分享上报事件 + if (this.$scope && this.$scope.onShareAppMessage) { + let oldShareAppMessage = this.$scope.onShareAppMessage; + this.$scope.onShareAppMessage = function(options) { + stat.interceptShare(false); + return oldShareAppMessage.call(this, options) + } + } }, onShow() { isHide = false @@ -28,9 +36,6 @@ const lifecycle = { }, onError(e) { stat.error(e) - }, - onShareAppMessage() { - stat.interceptShare(false) } }