3
0

mpShare.js 767 B

1234567891011121314151617181920212223242526
  1. import { defineMixin } from '../vue'
  2. import { queryParams } from '../function/index'
  3. export const mpShare = defineMixin({
  4. data() {
  5. return {
  6. mpShare: {
  7. title: '', // 默认为小程序名称
  8. path: '', // 默认为当前页面路径
  9. imageUrl: '' // 默认为当前页面的截图
  10. }
  11. }
  12. },
  13. async onLoad(options) {
  14. var pages = getCurrentPages();
  15. var page = pages[pages.length - 1];
  16. this.mpShare.path = page.route + queryParams(options);
  17. },
  18. onShareAppMessage(res) {
  19. if (res.from === 'button') {// 来自页面内分享按钮
  20. console.log(res.target)
  21. }
  22. return this.mpShare;
  23. }
  24. })
  25. export default mpShare