npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-isz-share

v1.0.1

Published

分享和支付插件

Downloads

3

Readme

react-native-isz-share 爱上租插件

实现功能

  • 分享

微信好友及朋友圈分享,qq好友及空间分享,微博分享

  • 登录

微信登录,qq登录,微博登录

  • 支付

微信支付,阿里支付

安装

npm install react-native-isz-share  
yarn add  react-native-isz-share 

自动link

react-native link react-native-isz-share

手动link

  • Android

Application文件 getPackages增加new IShangZuSmartPackage()

 @Override
        protected List<ReactPackage> getPackages() {
            return Arrays.<ReactPackage>asList(
                    new MainReactPackage(),
                    new ISZSharePayPackage()
            );
        }

app下build.gradle添加依赖

compile project(':react-native-isz-share')

settings.gradle文件添加

include ':react-native-isz-share'
project(':react-native-isz-share').projectDir = new File(settingsDir, '../../android')

ios

进入ios目录,在podfile文件加入:
  pod 'react-native-isz-share', :path => '../node_modules/react-native-isz-share'
执行:
  pod install

配置

Android

项目app build 文件配置

        manifestPlaceholders = [
                "QQ_APPID"    : "申请的app-id",
                "WEIBO_APPKEY": "申请的key",
                "WECHAT_APPID": "申请的appid",
                "WECHAT_SECRET": "申请的WECHAT_SECRET",
        ]

项目gradle文件

//微博sdk仓库
 maven { url "https://dl.bintray.com/thelasterstar/maven/" }

使用微信相关

在项目包名下创建包wxapi,并在其中创建如下Activity,(不创建无法使用该功能)

//使用分享登录时创建
public class WXEntryActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        WeChatApiModule.handleIntent(getIntent());
        finish();
    }
}

//使用支付时创建
public class WXPayEntryActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
		WeChatApiModule.handleIntent(getIntent());
		finish();
    }
}


//将上面Activity在AndroidManifest.xml文件注册。
        <activity
            android:name=".wxapi.WXEntryActivity"
            android:exported="true"
            android:label="@string/app_name"
            android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
        <activity
            android:name=".wxapi.WXPayEntryActivity"
            android:exported="true"
            android:label="@string/app_name"
            android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />

IOS

API使用

引入

import {LoginApi, PayApi, ShareApi} from 'react-native-isz-share'

说明

下面展示使用所有接口使用Promise写法,登录接口统一返回 ,如下uid是openid,gender性别,name登录第三方账号名字,iconUrl是头像。

{
    "uid":"2414135401",
    "gender":"男",
    "name":"Code4Android",
    "msg":"登录成功",
    "iconUrl":"http://tva1.sinaimg.cn/crop.0.0.180.180.50/8fe4c869jw1e8qgp5bmzyj2050050aa8.jpg",
    "errCode":0,
    "type":"WeiBoLoginRes"
}

登录Api

  • 微信登录
/**
 * 微信登录
 * @method WeChat
 * @param {Object} data
 * @param {String} data.scopes - 字符串.应用授权作用域,snsapi_base (不弹出授权页面,直接跳转,只能获取用户openid),snsapi_userinfo (弹出授权页面,可通过openid拿到昵称、性别、所在地 非必填
 * @param {String} data.state - 重定向后会带上state参数,开发者可以填写a-zA-Z0-9的参数值,最多128字节,该值会被微信原样返回,我们可以将其进行比对,防止别人的攻击.  非必填
 */
      LoginApi.loginWithWeChat().then((message) => console.log(message)).catch(err => {
            console.log(err)
        });

  • QQ登录

参数:

/**
 * QQ登录
 * @method loginWithQQ
 * @param {Object} data
 * @param {String} data.scopes - 字符串.应用授权作用域,非必填
 */
        LoginApi.loginWithQQ()
            .then(message => {
                console.log( message)
            }).catch(err => {
            console.log( err)
        })
  • 微博登录
        LoginApi.loginWithWeiBo()
            .then(message => {
                console.log(message)
            }).catch(err => {
            console.log(err)
        })

分享API

数据

        let shareMessage = {
            type: "news",
            title: "我是测试标题",
            content: "我是测试内容",
            url: 'http://baidu.com',
            imageUrl: 'http://dev.umeng.com/images/tab2_1.png',
        };
  • 微博分享
/**
 * 分享消息到微博
 * @method shareToWeiBo
 * @param {Object} data
 * @param {String} data.title - 分享标题.
 * @param {String} data.content - 分享内容.
 * @param {String} data.type - 分享类型,默认是分享成文本 {news(新闻网页形式)|text(文本)|image(图片)}
 * @param {String} data.url - 分享的网页
 * @param {String} data.imageUrl - 分享的图片链接.
 * @param {String} data.imagePath - 分享的图片本地路径.(imageUrl和此字段都传时优先使用此字段)
 */
 ShareApi.shareToWeiBo(shareMessage).then(message => {
                console.log(message);
            }).catch(err => {
                 console.log(err);
            })
  • QQ分享

//分享到好友

/**
 * 分享消息到QQ好友
 * @method shareToQQ
 * @param {Object} data
 * @param {String} data.title - 分享标题.
 * @param {String} data.content - 分享内容.
 * @param {String} data.type - 分享类型,默认是分享成文本 {news(新闻网页形式)|text(文本)|image(图片)}
 * @param {String} data.url - 分享的网页
 * @param {String} data.imageUrl - 分享的图片链接.
 * @param {String} data.imagePath - 分享的图片本地路径.(分享本地图片必须使用此字段,否则无法分享)
 */
  ShareApi.shareToQQ(shareMessage).then((message) => this.show("成功" + message))
                .catch(err => this.show("失败" + err))
//分享到空间

/**
 * 分享消息到QQ空间
 * @method shareToQZone
 * @param {Object} data
 * @param {String} data.title - 分享标题.
 * @param {String} data.content - 分享内容.
 * @param {String} data.type - 分享类型,默认是分享成文本 {news(新闻网页形式)|text(文本)|image(图片)}
 * @param {String} data.url - 分享的网页
 * @param {String} data.imageUrl - 分享的图片链接.
 * @param {String} data.imagePath - 分享的图片本地路径.(分享本地图片必须使用此字段,否则无法分享)
 */
 ShareApi.shareToQZone(shareMessage).then((message) => this.show("成功" + message))
                .catch(err => this.show("失败" + err))
  • 微信分享
//分享到好友
/**
 * 分享消息到微信好友
 * @method shareToWeChatSession
 * @param {Object} data
 * @param {String} data.title - 分享标题. 非必填
 * @param {String} data.content - 分享内容. 非必填
 * @param {String} data.type - 分享类型,默认是分享成文本 {news(新闻网页形式)|text(文本)|image(图片)}
 * @param {String} data.url - 分享的网页 非必填
 * @param {String} data.imageUrl - 分享的图片链接.
 * @param {String} data.imagePath - 分享的图片本地路径.(imageUrl和此字段都传时优先使用此字段)
 */
 ShareApi.shareToWeChatSession(shareMessage).then(message => {
                console.log(message);
            }).catch(err => {
                console.log(err);
            });
//分享到朋友圈

/**
 * 分享消息到微信朋友圈
 * @method shareToWeChatTimeline
 * @param {Object} data
 * @param {String} data.title - 分享标题.
 * @param {String} data.content - 分享内容.
 * @param {String} data.type - 分享类型,默认是分享成文本 {news(新闻网页形式 此时url必填)|text(文本)|image(图片 此时imageUrl必填)}
 * @param {String} data.url - 分享的网页
 * @param {String} data.imageUrl - 分享的图片链接.
 * @param {String} data.imagePath - 分享的图片本地路径.(imageUrl和此字段都传时优先使用此字段)
 */
  ShareApi.shareToWeChatTimeline(shareMessage).then(message => {
                console.log(message);
            }).catch(err => {
                console.log(err);
            });

支付API

  • 微信支付
/**
 * 微信支付
 * @method payWithWeChat
 * @param {Object} data
 * @param {String} data.appId -微信appid   必填
 * @param {String} data.partnerId -商户号   必填
 * @param {String} data.prepayId -预支付交易会话ID 必填
 * @param {String} data.sign -  签名  必填
 * @param {String} data.nonceStr -随机字符串  非必填
 * @param {String} data.timeStamp - 时间戳 非必填
 */
      PayApi.payWithWeChat({prepayId: '1111', partnerId: '4325435', sign: "wgtrfsdnjknjghuyry8"}).then(message => {
            console.log(message)
        }).catch(err => {
            console.log(err)
        })
  • 支付宝
/**
 * 支付宝支付
 * @method AliPay
 * @param {Object} data
 * @param {String} data.amount -支付金额   必填
 * @param {String} data.privateKey -私钥 必填
 * @param {String} data.pid -  商户id  必填
 * @param {String} data.orderNo -  订单编号  必填
 * @param {String} data.body -商品详情信息,支付时提醒  非必填,默认显示订单号
 * @param {String} data.account - 支付宝收款账户id。 非必填,默认为商户签约账号对应的支付宝用户ID
 * @param {String} data.notify_url - 支付宝服务器主动通知商户服务器里指定的页面http/https路径。 非必填
 * @param {String} data.timeout_express - 订单过期时间,取值范围:1m~15d。m-分钟,h-小时,d-天,1c-当天 非必填,默认30m
 */
 
 PayApi.payWithAli({})