从网上少的各种信息总结的,有什么问题欢迎大家指正
一、安装微信sdk
二、支付
三、分享
1、shareToTimeline是分享到朋友圈的方法,shareToSession 是分享给朋友或者群的方法
WeChat.shareToSession({ //微信好友分享链接
title:'微信好友测试的链接',
description: '分享的标题内容',
thumbImage: '分享的标题图片',
type: 'news',
webpageUrl: '分享的链接'
}).then(res=>{
console.log(res)
}).catch((error) => {
console.log(res)
// Alert.alert(error.message);
});
WeChat.shareToTimeline({ //微信朋友圈分享的文本
type: 'text', description: '测试微信朋友圈分享的文本内容'
}).catch((error) => {
Alert.alert(error.message);
});
WeChat.shareToTimeline({ //微信朋友圈分享的链接
title:'分享的标题',
description: '分享的标题内容',
thumbImage: '分享的标题图片',
type: 'news',
webpageUrl: '分享的链接'
}).catch((error) => {
Alert.alert(error.message);
});
其中title是分享时显示的标题,description是描述的内容体,webpageurl点击后打开的链接,
thumbImage,这个是分享时左侧现实的图片,
imageUrl,这个和webpageurl类似,是分享的图片地址,
videoUrl这是分享的视频地址
musicUrl这是分享的音乐地址
filePath这是分享文件地址,可以分享文件
fileExtension,这个是分享的文件的后缀,如果分享的是doc文档,如:fileExtension:‘.doc’;
此外还有监听的方法:addListener(eventType, listener[, context])
2、分享方式
1)分享链接
thumbImage: '分享的标题图片',
type: 'news',
webpageUrl: '分享的链接'
2)分享纯图片
type:'imageFile'
imageUrl: 图片路径
3)分享文本
type: 'text'
description: '测试微信朋友圈分享文本'
link:
type:可以是{news | text | imageUrl | imageFile | imageResource | video | audio | file}
title:是分享时显示的标题,
description:是描述的内容体,
webpageurl:点击后打开的链接,
thumbImage:这个是分享时左侧现实的图片,
imageUrl:这个和webpageurl类似,是分享的图片地址,
videoUrl:这是分享的视频地址
musicUrl:这是分享的音乐地址
filePath:这是分享文件地址,可以分享文件
fileExtension:这个是分享的文件的后缀,如果分享的是doc文档,如:fileExtension:‘.doc’;
mediaTagName
messageAction
messageExt
let result = await WeChat.shareToTimeline({
type: 'imageUrl',
title: 'web image',
description: 'share web image to time line',
mediaTagName: 'email signature',
messageAction: undefined,
messageExt: undefined,
imageUrl: 'http://www.ncloud.hk/email-signature-262x100.png'
});
let result = await WeChat.shareToTimeline({
type: 'imageFile',
title: 'image file download from network',
description: 'share image file to time line',
mediaTagName: 'email signature',
messageAction: undefined,
messageExt: undefined,
imageUrl: "file://" + savePath // require the prefix on both iOS and Android platform
});
四、跳转小程序
1.找一个在react-native-wechat基础上,增加了支持跳转小程序的第三方库
https://gitee.com/putixie/react-native-wechat
2.安装
修改package.json
"react-native-wechat": "git+https://gitee.com/putixie/react-native-wechat.git"
WeChat.launchMini({
userName: "xxxxxxxx", // 拉起的小程序的username
miniProgramType: 0, // 拉起小程序的类型. 0-正式版 1-开发版 2-体验版
path: 'page/xxx' // 拉起小程序页面的可带参路径,不填默认拉起小程序首页
});