mpShare.js 673 B

1234567891011121314151617181920212223242526
  1. module.exports = {
  2. onLoad() {
  3. // 设置默认的转发参数
  4. this.$u.mpShare = {
  5. title: '', // 默认为小程序名称
  6. path: '', // 默认为当前页面路径
  7. imageUrl: '' // 默认为当前页面的截图
  8. }
  9. },
  10. onShareAppMessage(res) {
  11. if (res && res.from === 'button' && res.target && res.target.dataset && res.target.dataset.shareType === 'product') {
  12. const dataset = res.target.dataset;
  13. return {
  14. title: dataset.title || '',
  15. path: `/pages-sell/pages/detail?isbn=${dataset.isbn}`,
  16. imageUrl: dataset.image || ''
  17. }
  18. }
  19. return this.$u.mpShare
  20. },
  21. // #ifdef MP-WEIXIN
  22. onShareTimeline() {
  23. return this.$u.mpShare
  24. }
  25. // #endif
  26. }