uniapp Wechat applet to share with friends and share circle of friends

1. You need to call uni.showShareMenu in mounted to display the share button in the native menu of the applet

onMounted(() => {
    
    
	uni.showShareMenu({
    
    
		withShareTicket: true,
		menus: ["shareAppMessage", "shareTimeline"]
	})
}) 

To disable sharing for this page, uni.hideShareMenu().

2. Retweet to friends (Click the three dots on the capsule button to trigger ···)

onShareAppMessage((res) => {
    
    
return {
    
    
	title: '标题',
	imageUrl: '要分享的图片的路径',
	//如果有参数的情况可以写path
	path: "/pages/index/indexDetail?isShare=1&id=" + id,
	};
});

3. Forward Moments (click the capsule button to trigger the three small dots ···)

onShareTimeline(() => {
    
    
return {
    
    
	title: '标题',
	//分享朋友圈的参数
	query: "isShare=1&id=" + id,
	}
})

4. Button triggers forwarding

(1) Forward to friends,open-type="share"

<button open-type="share">发送给好友</button>

(2) WeChat does not currently support the custom button to trigger the function of forwarding Moments

Guess you like

Origin blog.csdn.net/honeymoon_/article/details/123840122