uni小程序分享到朋友圈朋友,uniapp分享给好友,通过小程序打开分享界面

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
			},

}

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值