美文网首页微信小程序
微信小程序API 转发给好友 (Page.onShareAppM

微信小程序API 转发给好友 (Page.onShareAppM

作者: 贤总_ | 来源:发表于2019-04-29 10:19 被阅读1次
wxml部分

转发事件一定是绑在 button 组件上面.给button组件设置属性:open-type="share"
点击按钮直接就会触发转发的方法,可以转发给指定的微信好友.
但是这个需求还不够,用户那边收到的是 转发的那个页面,点进去以后也是那个页面

 <button class='weixin' open-type="share">
     <view class='wechatImg'>
         <image class='wechatIcon' src='../../images/wechat.png'></image>
     </view>
     <view class='sentFriend'>发送给好友</view>
</button>
js部分
/**
   * 用户点击右上角分享
   */
  onShareAppMessage: function(res) {
    let that = this;
    // console.log('主图------------->',that.data.goodsObj.MainImages)
    return {
      title: "发送给好友",
      imageUrl: that.data.goodsObj.MainImages,
      success: function(res) {
        console.log(res, "转发成功")
      },
      fail: function(res) {
        console.log(res, "转发失败")
      }
    }

  },

相关文章

网友评论

    本文标题:微信小程序API 转发给好友 (Page.onShareAppM

    本文链接:https://www.haomeiwen.com/subject/bpbenqtx.html