shareMixin.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. export default {
  2. data() {
  3. return {
  4. share: {
  5. title: "开邻做题家",
  6. path: "/pages/index/index",
  7. imageUrl: "分享显示的图片链接",
  8. desc: "简介",
  9. },
  10. };
  11. },
  12. // 分享到微信好友功能
  13. onShareAppMessage(res) {
  14. return {
  15. title: this.share.title,
  16. path: this.share.path,
  17. desc: this.share.desc,
  18. imageUrl: this.share.imageUrl,
  19. success(res) {
  20. uni.showToast({
  21. title: "分享成功",
  22. });
  23. },
  24. fail(res) {
  25. uni.showToast({
  26. title: "分享失败",
  27. icon: "none",
  28. });
  29. },
  30. };
  31. },
  32. // 分享到朋友圈功能
  33. onShareTimeline(res) {
  34. return {
  35. title: this.share.title,
  36. path: this.share.path,
  37. desc: this.share.desc,
  38. imageUrl: this.share.imageUrl,
  39. success(res) {
  40. uni.showToast({
  41. title: "分享成功",
  42. });
  43. },
  44. fail(res) {
  45. uni.showToast({
  46. title: "分享失败",
  47. icon: "none",
  48. });
  49. },
  50. };
  51. },
  52. };