微信分享接口

只能在App使用

<template>
	<view class="content">
		<button class="renzheng" v-on:click="shareFriend">点击分享朋友</button>
		<button class="renzheng" v-on:click="shareFriendcricle">分享到微信朋友圈</button>
		<button class="renzheng" v-on:click="shareFriendcricle3">App分享为微信小程序</button>
	</view>
</template>


<script src="http://res.wx.qq.com/open/js/jweixin-1.4.0.js" type="text/javascript"></script>
<script>
	
	import wx from 'weixin-js-sdk'
	export default {
		data() {
			return {

			}
		},
		methods: {
			shareFriend: function() {
				//分享到微信朋友
				uni.share({
					provider: "weixin",
					scene: "WXSceneSession",
					type: 0,
					href: "http://uniapp.dcloud.io/",
					title: "uni-app分享",
					summary: "我正在使用HBuilderX开发uni-app,赶紧跟我一起来体验!",
					imageUrl: "https://bjetxgzv.cdn.bspapp.com/VKCEYUGU-uni-app-doc/d8590190-4f28-11eb-b680-7980c8a877b8.png",
					success: function(res) {
						console.log("success:" + JSON.stringify(res));
					},
					fail: function(err) {
						console.log("fail:" + JSON.stringify(err));
					}
				});
			},
			//分享到微信朋友圈
			shareFriendcricle: function() {
				uni.share({
					provider: "weixin",
					scene: "WXSenceTimeline",
					type: 0,
					href: "http://uniapp.dcloud.io/",
					title: "uni-app分享",
					summary: "我正在使用HBuilderX开发uni-app,赶紧跟我一起来体验!",
					imageUrl: "https://bjetxgzv.cdn.bspapp.com/VKCEYUGU-uni-app-doc/d8590190-4f28-11eb-b680-7980c8a877b8.png",
					success: function(res) {
						console.log("success:" + JSON.stringify(res));
					},
					fail: function(err) {
						console.log("fail:" + JSON.stringify(err));
					}
				});
			},
			//App分享为微信小程序(App中分享一个内容到微信好友,对方微信中呈现的是一个小程序卡片)
			shareFriendcricle3: function() {
				//uni.showShareMenu(); //微信小程序实现当前页面转发

				// uni.share({
				// 	provider: 'weixin',
				// 	scene: "WXSceneSession",
				// 	type: 5,
				// 	imageUrl: 'https://bjetxgzv.cdn.bspapp.com/VKCEYUGU-uni-app-doc/962fc340-4f2c-11eb-bdc1-8bd33eb6adaa.png',
				// 	title: '欢迎体验uniapp',
				// 	miniProgram: {
				// 		id: 'gh_abcdefg',
				// 		path: 'pages/index/index',
				// 		type: 0,
				// 		webUrl: 'http://uniapp.dcloud.io'
				// 	},
				// 	success: ret => {
				// 		console.log(JSON.stringify(ret));
				// 	}
				// });
			}
		}
	}
</script>

<style>
	button {
		color: #DD524D;
	}
</style>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值