小程序分享转发

1、小程序分享转发(法一)

a:右上角菜单栏显示转发

wx.showShareMenu({
  withShareTicket: true,
  success: function(res) {
  },
  fail: function(res) {
  }
})
b:
onShareAppMessage(options) {
  let shareObj = {
    title: '精选优惠券', 
    path: '/pages/selected',  // 默认当前页的url
    imageUrl: '../images/logo.png',
    success: function(res) {
      console.log(res, '成功')
    },
    fail: function(res) {
      console.log(res, '失败')
    }
  }
  return shareObj
}
2、小程序分享转发(法二)
a:自定义转发分享
<button data-name="shareBtn" open-type="share">转发</button>
b:
onShareAppMessage(options) {
  let shareObj = {
    title: '精选优惠券', 
    path: '/pages/selected',  // 默认当前页的url
    imageUrl: '../images/logo.png',
    success: function(res) {
      console.log(res, '成功')
    },
    fail: function(res) {
      console.log(res, '失败')
    }
  }
  if(option.form === 'button'){
    var eData = options.target.dataset;
    console.log( eData.name ); 
  }
  return shareObj
}
posted @ 2019-05-27 11:30  凌珊  阅读(170)  评论(0编辑  收藏  举报