uniapp-微信小程序分享功能-onShareAppMessage

  1. 页面内放置分享按钮,用户A点击分享给用户B且传参,比如邀请码;
<button open-type="share" style="margin: 0;padding: 0;border: none;background-color: transparent;">
	<view class="flex">
		<image src="https://jsfzapi.zexun.tech/getfile/statics/cdn/dyt_images/level/wx_icon.png" mode="widthFix"
			class="wx_icon" />
		<text>微信分享</text>
	</view>
</button>
// 分享
onShareAppMessage(res) {
	console.log(res);
	if (res.from === 'button') {// 来自页面内分享按钮
		console.log(res.target)
	}
	return {
		title: 'xxx小程序',
		path: `/pages/index/index?inviteCode=${this.inviteCode}`
	}
},
  1. 用户B点击被分享过来的卡片进入小程序首页(也可以是登录页面等),进入后在首页拿到邀请码,存起来,用户登录时,作为邀请者的标识进行关联;
    注:分享时跳转的是哪个页面就在哪个页面监听参数;
onLoad(options) {
	console.log(options, 'options');
	// 分享卡片给朋友
	if(options.inviteCode){
		let inviteCode = options.inviteCode
		uni.$u.vuex("$inviteCode", inviteCode)
	}
},

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值