微信(sdk)的支付、分享、拉起小程序

从网上少的各种信息总结的,有什么问题欢迎大家指正		

一、安装微信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' // 拉起小程序页面的可带参路径,不填默认拉起小程序首页
  });
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值