const app = getApp(); Page({ pid: '', onLoad: function (options) { var that = this; this.pid = options.id; app.request('product.api.poster',{product_id: this.pid},{ success: function(data, res){ app.set(that, 'imgUrl', data); } }) }, /** * 保存好报分享到朋友圈 */ savePoster: function(){ var imgUrl = this.data.imgUrl; wx.getImageInfo({ src: imgUrl, success: function (sres){ console.log('wx.getImageInfo', sres.path); wx.saveImageToPhotosAlbum({ filePath: sres.path, success: function (fres){ console.log('wx.saveImageToPhotosAlbum', fres); } }) } }) }, /** * 用户点击右上角分享 */ onShareAppMessage: function (options) { //打开好友列表 wx.showShareMenu({ withShareTicket: true, success: function (res) { console.log('wx.showShareMenu success', res.data); }, fail: function (res) { console.log('wx.showShareMenu fail', res.data); } }); if (app.getUid() != '') {//拼接分享参数 var scene = app.getUid() + ',' + this.pid; return { title: '', desc: '', path: '/template/home/index?scene=' + encodeURIComponent(scene) }; } } })