import { mapState } from 'vuex' export default { data() { return { // 默认的全局分享内容 Gshare: { title: '遗产里的景徳镇', path: '/pages_order/auth/wxLogin', // 全局分享的路径,比如 首页 // imageUrl: '/static/image/login/logo.png', // 全局分享的图片(可本地可网络) } } }, computed: { ...mapState(['configList', 'userInfo']), currentPagePath() { const pages = getCurrentPages(); const currentPage = pages[pages.length - 1]; let path = `/${currentPage.route}`; // 获取当前页面的参数 const options = currentPage.options; if (options && Object.keys(options).length > 0) { const params = this.$utils.objectToUrlParams(options); path += `?${params}`; } return path; }, }, onLoad(query) { if (query.shareId) { uni.setStorageSync('shareId', query.shareId) } }, // 定义全局分享 // 1.发送给朋友 onShareAppMessage(res) { let o = { ...this.Gshare, } if(this.userInfo.id){ if(this.Gshare.path.includes('?')){ o.path += '&shareId=' + this.userInfo.id }else{ o.path += '?shareId=' + this.userInfo.id } } return o }, //2.分享到朋友圈 onShareTimeline(res) { let o = { ...this.Gshare, } if(this.userInfo.id){ if(this.Gshare.path.includes('?')){ o.path += '&shareId=' + this.userInfo.id }else{ o.path += '?shareId=' + this.userInfo.id } } return o }, methods: { } }