share.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import config from '../config.js';
  2. export default {
  3. data() {
  4. return {
  5. share: {}
  6. }
  7. },
  8. onShareAppMessage(res) { //发送给朋友
  9. //禁止二次转发--
  10. uni.showShareMenu({
  11. withShareTicket: true
  12. });
  13. wx.updateShareMenu({
  14. isPrivateMessage: true,
  15. withShareTicket: true,
  16. success(res) {
  17. console.log('updateShareMenu: ', res);
  18. },
  19. fail() {}
  20. });
  21. return {
  22. title: config.share.title,
  23. path: config.share.path,
  24. imageUrl: config.share.imageUrl,
  25. success(res) {
  26. uni.showToast({
  27. title: '分享成功'
  28. })
  29. },
  30. fail(res) {
  31. uni.showToast({
  32. title: '分享失败',
  33. icon: 'none'
  34. })
  35. }
  36. }
  37. },
  38. onShareTimeline(res) { //分享到朋友圈
  39. return {
  40. title: config.share.title,
  41. path: config.share.path,
  42. imageUrl: config.share.imageUrl,
  43. success(res) {
  44. uni.showToast({
  45. title: '分享成功'
  46. })
  47. },
  48. fail(res) {
  49. uni.showToast({
  50. title: '分享失败',
  51. icon: 'none'
  52. })
  53. }
  54. }
  55. },
  56. }