share.js 949 B

123456789101112131415161718192021222324252627282930313233343536
  1. export default{
  2. data(){
  3. return {
  4. //设置默认的分享参数
  5. //如果页面不设置share,就触发这个默认的分享
  6. share:{
  7. title:'沸城湖里',
  8. path:'/pages/index/index',
  9. imageUrl:'',
  10. desc:'',
  11. content:''
  12. }
  13. }
  14. },
  15. onShareAppMessage(res) {
  16. console.log(this.share.path);
  17. return {
  18. title:this.share.title,
  19. path:this.share.path,
  20. imageUrl:this.share.imageUrl,
  21. desc:this.share.desc,
  22. content:this.share.content,
  23. success(res){
  24. uni.showToast({
  25. title:'分享成功'
  26. })
  27. },
  28. fail(res){
  29. uni.showToast({
  30. title:'分享失败',
  31. icon:'none'
  32. })
  33. }
  34. }
  35. }
  36. }