export default { data() { return { //设置默认的分享参数 //如果页面不设置share,就触发这个默认的分享 share: { title: '', path: '', imageUrl: 'https://huli-app.wenlvti.net/app_static/WenWuGuanJia/image/search.png', desc: '', content: '' } } }, onShareAppMessage(res) { console.log(this.share.path); if (this.share.path == '') { var pages = getCurrentPages() // 获取栈实例 let currentRoute = pages[pages.length - 1].route; // 获取当前页面路由 let currentPage = pages[pages.length - 1]['$page']['fullPath'] //当前页面路径(带参数) this.share.path = currentPage; } let user = this.$common.userInfo(); if (user) { if (this.share.path.indexOf('from_userid') < 0) { if (this.share.path.indexOf('?') > 0) { this.share.path = this.share.path + '&from_userid=' + user.id } else { this.share.path = this.share.path + '?from_userid=' + user.id } } } return { title: this.share.title, path: this.share.path, imageUrl: this.share.imageUrl, desc: this.share.desc, content: this.share.content, success(res) { uni.showToast({ title: '分享成功' }) }, fail(res) { uni.showToast({ title: '分享失败', icon: 'none' }) } } }, onShareTimeline(res) { return { title: this.share.title, path: this.share.path, imageUrl: this.share.imageUrl, success(res) { uni.showToast({ title: '分享成功' }) }, fail(res) { uni.showToast({ title: '分享失败', icon: 'none' }) } } } }