app分享好友界面
<uni-popup ref="popup" type="center" @touchmove.stop.prevent="moveHandle">
<view class="share">
<view class="weixin" @tap="weixin()">
<image src="../../static/weixin.png"></image>
<view>微信</view>
</view>
<!-- <view class="pengyouquan" @click="pengyouquan()">
<image src="../../static/pengyouquan.png"></image>
<view>朋友圈</view>
</view> -->
</view>
</uni-popup>
小程序是自带分享朋友圈和好友,但是需要在onLoad中允许
onLoad(options) {
//#ifdef MP-WEIXIN
wx.showShareMenu({
withShareTicket: true,
//设置下方的Menus菜单,才能够让发送给朋友与分享到朋友圈两个按钮可以点击
menus: ["shareAppMessage", "shareTimeline"]
})
//#endif
}
触发的方法methods
methods: {
//app分享
weixin() {
this.ShareAppMessage();
},
// 微信好友分享
ShareAppMessage() {
//#ifdef MP-WEIXIN
return {
title: this.beizu+':'+this.title,
imageUrl: this.img,
path: '/pages/product/product?id=' + this.id + '&group_buy_no=' + this.share
}
//#endif
//#ifdef APP-PLUS
uni.share({
provider: 'weixin',
scene: "WXSceneSession",
type: 5,
title: this.beizu+':'+this.title,
imageUrl: this.img,
miniProgram: {
id: 'gh_bccd28377f05',
// +'&goods=' + JSON.stringify(this.goodsdetails)
path: '/pages/product/product?id=' + this.id + '&group_buy_no=' + this.share,
type: 0,
webUrl: 'https://bjetxgzv.cdn.bspapp.com/index.html'
},
success: ret => {
console.log(JSON.stringify(ret));
}
});
//#endif
},
// 微信朋友圈
ShareTimeline() {
//#ifdef MP-WEIXIN
let dec='欢迎一起购'+this.title;
return {
title: this.beizu+':'+this.title,
query: 'id=' + this.id + '&group_buy_no=' + this.share+'&flag='+true+"&img=" + this.img+"&price="+this.price+"&sales=" + this.sales+'&stock='+this.stock+ '&title='+this.title+'&dec='+dec,
imageUrl: this.img
}
//#endif
//#ifdef APP-PLUS
uni.share({
provider: "weixin",
scene: "WXSenceTimeline",
type: 0,
href: 'https://bjetxgzv.cdn.bspapp.com/index.html?id=' + this.id + '&group_buy_no=' + this.share+'&goods=' + JSON.stringify(this.goodsdetails),
title: this.beizu+':'+this.title,
// summary: this.title,
imageUrl: this.img,
success: function(res) {
console.log("success:" + JSON.stringify(res));
},
fail: function(err) {
console.log("fail:" + JSON.stringify(err));
}
});
//#endif
},
}