赞
踩
监听用户点击页面内转发按钮(button 组件 open-type=“share”)或右上角菜单“转发”按钮的行为,并自定义转发内容。
注意:只有定义了此事件处理函数,右上角菜单才会显示“转发”按钮
Page({ onShareAppMessage() { const promise = new Promise(resolve => { setTimeout(() => { resolve({ title: '自定义转发标题' }) }, 2000) }) return { title: '自定义转发标题', path: '/page/user?id=123', promise } } })
onShareAppMessage(res){ var that = this console.log(that.goods_data) if(res.from==='button'){//分享按钮 return { title:that.goods_data.share_title||that.goods_data.goods_name, // path: '', imageUrl:that.goods_data.share_img||that.goods_data.main_img, success: function (res) { if(res.errMsg == 'shareAppMessage:ok'){ console.log("成功",res) } }, fail:function(res){ console.log("失败",res) } } }else{ return { title:that.goods_data.share_title||that.goods_data.goods_name, // path: '', imageUrl:that.goods_data.share_img||that.goods_data.main_img, success: function (res) { if(res.errMsg == 'shareAppMessage:ok'){ console.log("成功",res) } }, fail:function(res){ console.log("失败",res) } } } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。