友人へ転送マイクロ手紙アプレットのAPI(Page.onShareAppMessage)

wxml一部

プロパティ]ボタンを設定するには、コンポーネントアセンブリの上部にあるボタンに接続する必要があります:.オープン型=「共有イベントの転送 」
ボタンをクリックして直接転送方式をトリガーする、それが指定されたマイクロ手紙の友人に転送することができる。
しかし、需要が十分にユーザ側ではありません受信は、ページが未来へのポイントであると、そのページに転送されました

 <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, "转发失败")
      }
    }

  },

あなたが唯一のマイクロチャネルの右上隅を閉じるには、ページ送りボタンを続ける場合は、転送することができます:
1.閉じるonloadイベントを

 onLoad: function(options) {

    // 隐藏右上角分享
    wx.hideShareMenu()
}
/**
   * 用户点击右上角分享
   */
  onShareAppMessage: function(res) {
    if (res.from === "button") {
      console.log(res)
      let that = this;
      let v = that.data.OrderNumber;
      that.setData({
        flag: false,
        v: v
      })
      console.log(v, 'v===========')
      return {
        title: that.data.BrandName,
        path: 'pages/index/index?t=' + 50 + '&v=' + v,
        success: function(res) {
          console.log(res, "转发成功")

        },
        fail: function(res) {
          console.log(res, "转发失败")
        }
      }
    } else {
      console.log(res)
    }
  },

おすすめ

転載: www.cnblogs.com/jessie-xian/p/11571635.html