share.js 909 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. export default {
  2. data() {
  3. return {
  4. }
  5. },
  6. onLoad: function() {
  7. wx.showShareMenu({
  8. withShareTicket: true,
  9. menus: ["shareAppMessage", "shareTimeline"]
  10. })
  11. },
  12. onShareAppMessage(res) {
  13. debugger
  14. let that = this;
  15. let imageUrl = that.shareUrl || '';
  16. if (res.from === 'button') {
  17. //这块需要传参,不然链接地址进去获取不到数据
  18. let path = `/` + that.$scope.route + `?item=` + that.$scope.options.item;
  19. return {
  20. title: '商品分享~',
  21. path: path,
  22. imageUrl: imageUrl
  23. };
  24. }
  25. // if (res.from === 'menu') {
  26. // return {
  27. // title: '商通线上商城',
  28. // path: '/pages/tabBarPro/index/index',
  29. // imageUrl: imageUrl
  30. // };
  31. // }
  32. },
  33. // 分享到朋友圈
  34. onShareTimeline() {
  35. return {
  36. title: '商通线上商城',
  37. path: '/pages/index/index',
  38. imageUrl: 'https://cdn.uviewui.com/uview/swiper/1.jpg'
  39. };
  40. },
  41. methods: {
  42. }
  43. }