// Page劫持 每个页面塞入分享方法
let originalPage = Page
Page = function(obj) {
//获取当前页面路由
let routerUrl = ""
wx.onAppRoute(function (res) {
//获取到页面路由
let pages = getCurrentPages(),
view = pages[pages.length - 1];
routerUrl = view.route
})
obj = Object.assign({
onShareAppMessage: function() {
return {
title: '测试分享title',
path: routerUrl,
imageUrl: ''
}
}
},obj)
return originalPage(obj)
}
网友评论