wxml part
Forwarding events must be tied to a button on top of the component assembly to set properties button:. Open-type = "share "
click on the button will trigger direct forwarding method, it can be forwarded to the designated micro-letter friends.
But the demand is not enough, the user side received was forwarded that page, that page is the point into the future
<button class='weixin' open-type="share">
<view class='wechatImg'>
<image class='wechatIcon' src='../../images/wechat.png'></image>
</view>
<view class='sentFriend'>发送给好友</view>
</button>
js part
/**
* 用户点击右上角分享
*/
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, "转发失败")
}
}
},
If you only keep the page forward button to close the upper right corner of the micro-channel can be forwarded:
1. Close 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)
}
},