index.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. const app = getApp();
  2. Page({
  3. pid: '',
  4. onLoad: function (options) {
  5. var that = this;
  6. this.pid = options.id;
  7. app.request('product.api.poster',{product_id: this.pid},{
  8. success: function(data, res){
  9. app.set(that, 'imgUrl', data);
  10. }
  11. })
  12. },
  13. /**
  14. * 保存好报分享到朋友圈
  15. */
  16. savePoster: function(){
  17. var imgUrl = this.data.imgUrl;
  18. wx.getImageInfo({
  19. src: imgUrl,
  20. success: function (sres){
  21. console.log('wx.getImageInfo', sres.path);
  22. wx.saveImageToPhotosAlbum({
  23. filePath: sres.path,
  24. success: function (fres){
  25. console.log('wx.saveImageToPhotosAlbum', fres);
  26. }
  27. })
  28. }
  29. })
  30. },
  31. /**
  32. * 用户点击右上角分享
  33. */
  34. onShareAppMessage: function (options) {
  35. //打开好友列表
  36. wx.showShareMenu({
  37. withShareTicket: true,
  38. success: function (res) {
  39. console.log('wx.showShareMenu success', res.data);
  40. },
  41. fail: function (res) {
  42. console.log('wx.showShareMenu fail', res.data);
  43. }
  44. });
  45. if (app.getUid() != '') {//拼接分享参数
  46. var scene = app.getUid() + ',' + this.pid;
  47. return {
  48. title: '',
  49. desc: '',
  50. path: '/template/home/index?scene=' + encodeURIComponent(scene)
  51. };
  52. }
  53. }
  54. })