简要记录一下uniapp微信。QQ分享的过程!

1.manifest.json配置:

将自己申请好的Id,填到配置文件中:
截图示例

2.在page.json中添加个小图标:

       {
		    "path" : "pages/instrument/diary/diary",
		    "style" : {
				"navigationBarTitleText": "施工日志",
				"app-plus": {
					   "scrollIndicator":"none",// 移动端去掉滚动条
					   "titleNView": {
					       "buttons": [
					           {
					               "text": "\ue7c5",
					               "fontSrc": "/static/iconfont.ttf",
					               "fontSize": "18px"
					           }
					       ]
					   }
				   }
			}
		}

来张效果图;(右边小图标)
分享按钮图标

3.给小图标个点击事件:

备注:这里要用到uniapp自带方法哦!

onNavigationBarButtonTap() {
//这里可以根据需求,跳转页面或者直接打开分享的弹框即可!
//我是直接跳转页面了,在跳转后的页面实现分享链接
     	uni.navigateTo({
     		url:"../../share/shareApp"
     	})
},

4.微信分享,或者QQ分享:

分享

给各自图标加点击方法:

toShireqq(){
				let that = this
				let url = that.$http.shareUrl+that.accountId
				//判断是不是ios,苹果登录(发现的bug,如果不判断另外一个就无法分享)
				if(uni.getSystemInfoSync().platform =='ios'){
					uni.share({
					    provider: "qq",
					    scene: "WXSceneSession",
					    type: 1,
					    summary:'这里是发送出去的话加上可以点击的h5页面!'+ url,
					    success: function (res) {
					       that.$refs.popup.close()
					    },
					    fail: function (err) {
					        console.log("fail:" + JSON.stringify(err));
					    }
					});
				}else{
					uni.share({
						provider: "qq",
						scene: "WXSceneSession",
						title:'建助江湖',
						type: 1,
						href:url,
						summary:'这里是发送出去的话加上可以点击的h5页面!!'+ url,
						success: function (res) {
						   that.$refs.popup.close()
						},
						fail: function (err) {
							console.log("fail:" + JSON.stringify(err));
						}
					});	
				}
			},
			toShirewx(){
				let that = this
				let url = that.$http.shareUrl+that.accountId
				uni.share({
				    provider: "weixin",
				    scene: "WXSceneSession",
				    type: 1,
				    summary: '这里是发送出去的话加上可以点击的h5页面'+ url,
				    success: function (res) {
				       that.$refs.popup.close()
				    },
				    fail: function (err) {
				        console.log("fail:" + JSON.stringify(err));
				    }
				});
			},

到此结束分享!代码既粘即用。没有bug。如有问题,评论说明!!!!

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值