uniapp方法二开发微信小程序实现分享链接给朋友

avatar
作者
猴君
阅读量:5

注意: 在微信 里面有两种分享 :

1、点击 按钮分享

2、微信小程序右上角自带分享功能

以下说的是 第一种做法 第二种做法在另外一篇文章

1、绑定

 // 按钮 绑定  ->     open-type="share"

<u-button type="info" color="transparent" class="custom-button" open-type="share"> 	分享 			</u-button>

2、事件

可以携带一些参数 过去

	//左侧分享功能  		onShareAppMessage(res) { 			let customerId = uni.getStorageSync('customerId');  			let userId = uni.getStorageSync('userId');    			let sceneStr = ''; 			let scene = { 				a: userId,//用户id 				b: customerId,//客户id 				d: this.activityType == 4 ? 5 : this.activityType, // 活动类型  如果传过来的值是 4 那么就传 5过去 				c: 1//c=海报类型1客户2员工 			}; 			if (res.from === 'button') {	// 来自页面内分享按钮 				console.log(res.target); 			} 			return { 				title: '推荐有礼', //分享的名称 				path: '/pages/Login/index?scene=' + encodeURIComponent(JSON.stringify(scene)) + '&tiaozhuan=' + 1, 				mpId: 'wx363402ec173d7c4f' //微信小程序的AppId	 			}; 		},

再另一个页面获取数据 

 onLoad(data) { let scene = JSON.parse(decodeURIComponent(data.scene)); }

可以看这篇文章

广告一刻

为您即时展示最新活动产品广告消息,让您随时掌握产品活动新动态!