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-smart

v1.2.0

Published

爱上租插件

Downloads

26

Readme

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

目前实现功能

  • 分享

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

  • 登录

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

  • 支付

微信支付(未测试),阿里支付(未测试)

  • 活体检测

  • 百度定位,地理编码,逆地理编码

  • POI,地图

安装

npm install react-native-isz-smart

自动link

react-native link react-native-isz-smart

手动link

  • Android

Application文件 getPackages增加new IShangZuSmartPackage()

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

app下build.gradle添加依赖

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

settings.gradle文件添加

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

1、手动导入 BaiduMap_IOSSDK_v3 (百度SDK) Liveness (活体检测SDK) Alipay2.2(支付宝SDK) libWeiboSDK (新浪微博SDK) QQ(tencentSDK) 到主工程目录下

2、在主工程target下面->General->Linked Frameworks and Libraries 添加系统库 libstdc++.6.0.9.tbd Security.framework OpenGLES.framework QuartzCore.framework CoreLocation.framework MapKit.framework VideoToolbox.framework MobileCoreServices.framework CoreTelephony.framework libiconv.tbd libsqlite3.0.tbd libz.tbd SystemConfiguration.framework CFNetwork.framework

3、图片资源在主工程目录下的images.xcassets

配置

Android

项目app build 文件配置

        manifestPlaceholders = [
                "QQ_APPID"    : "申请的app-id",
                "WEIBO_APPKEY": "申请的key",
                "WECHAT_APPID": "申请的appid",
                "ALIPAY_APPID": "申请的appid",
                "BAIDU_KEY"   : "百度ak"
        ]

项目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

项目第三方key 配置 加入头文件

1.在主工程AppDelegate.h 写入 #pragma mark - 第三方配置

//QQ配置
extern NSString *const QQ_APP_ID;
extern NSString *const QQ_APP_KEY;
//微信配置
extern NSString *const WX_APP_ID;
extern NSString *const WX_APP_SECRET;
//微博配置
extern NSString *const WEIBO_APP_KEY;
extern NSString *const WEIBO_APP_SECRET;
extern NSString *const WEIBO_REDIRECT_URL;

2.在主工程AppDelegate.m 写入

//QQ配置
NSString *const QQ_APP_ID = @"1104826425";
NSString *const QQ_APP_KEY = @"eKIgY6XsUfAOFUOq";
//微信配置
NSString *const WX_APP_ID = @"wx0b54368a00a465dc";
NSString *const WX_APP_SECRET = @"bdf36ace669593da6b3c741472bfcb40";
//微博配置
NSString *const WEIBO_APP_KEY = @"3435956347";
NSString *const WEIBO_APP_SECRET = @"56ad266c56c49dd94396d9fe24453377";
NSString *const WEIBO_REDIRECT_URL = @"https://api.weibo.com/oauth2/default.html";


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  NSURL *jsCodeLocation;

  jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];

  RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
                                                      moduleName:@"Examples"
                                               initialProperties:nil
                                                   launchOptions:launchOptions];
  rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];

  //分享配置
  [[ASShareManager sharedManager]bindSharedConfigInformationWithQQ:^(ASShareConfig *config){
    config.appid = QQ_APP_ID;
    config.appkey = QQ_APP_KEY;
  } weixinConfig:^(ASShareConfig *config){
    config.appid = WX_APP_ID;
    config.appSecret = WX_APP_SECRET;
  } weiboConfig:^(ASShareConfig *config){
    config.appkey = WEIBO_APP_KEY;
    config.appSecret = WEIBO_APP_SECRET;
    config.app_redirect_url = WEIBO_REDIRECT_URL;
  }];

  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [UIViewController new];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];

  return YES;
}
#ifdef __IPHONE_9_0 //这里主要是针对iOS 9.0

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString*, id> *)options{

  return  [[ASShareManager sharedManager] handleOpenURL:url];
}
#endif
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
  return [[ASShareManager sharedManager] handleOpenURL:url];
}

API使用

引入

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

说明

下面展示使用所有接口使用Promise写法,then是成功,catch是失败。无论成功失败都返回的有参数errCode,和msg(失败时失败原因)。登录接口统一返回 ,如下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"
}

活体检测返回数据,cvFinanceFrame是一个数据,长度以及顺序根据设置的检测序列motionArray返回,motion表示检测序列类型。imageBytes是一个Base64编码的图片。检测成功和失败依然根据errCode是否为0判断。0是成功,其他失败(包括返回)。

{
    "msg":"活体检测成功!",
    "cvFinanceFrame":[
        {
            "motion":"BLINK",
            "imageBytes":""
        },
        {
            "motion":"MOUTH",
            "imageBytes":""
        }
    ],
    "sign_id":"siafishi",
    "errCode":0
}

登录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.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 {Boolean} data.rsa2 -  是否为RSA2加密  非必填,默认false
 * @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
 */

活体检测Api

/**
 * 活体检测
 * @method openLiveness
 * @param {Object} data
 * @param {String} data.signId - 非必填,此参数,作为参数返回,有参数时返回内容可以直接作为请求数据实现爱上租当前业务请求,否则,自己对数据中sign_id字段赋值。
 * @param {String} data.complexity - complexity检测难易,支持四种难度,easy, normal, hard, hell. 非必填,默认easy,使用时通过OcrApi.Complexity调用
 * @param {Boolean} data.isSoundNotice - 是否打开声音 非必填 默认true(打开声音)
 * @param {Array} data.motionArray - 动作检测序列配置,支持四种检测动作, BLINK(眨眼), MOUTH(张嘴), NOD(点头), YAW(摇头)。
 * 推荐第一个动作为BLINK,非必填默认[BLINK,MOUTH, YAW,NOD],通过OcrApi.Motion.BLINK使用
 *
 */


        OcrApi.openLiveness({
            signId: "siafishi",
            complexity: OcrApi.Complexity.EASY,
            isSoundNotice: false,
            motionArray: [OcrApi.Motion.BLINK, OcrApi.Motion.MOUTH]
        }).then(message => {
            console.log(message)
        }).catch(err => {
            console.log(err)
        })

定位api

              LocationApi.locate().then(result => {
                        this.show(result)
                    }).catch(err => {
                        this.show(err)
                    })

返回数据类型

{
    "errCode":0,
    "operationers":1,
    "direction":-1,
    "longitude":120.146105,
    "timestamp":"2018-04-21 18:53:23",
    "coordinateType":"bd09ll",
    "altitude":5e-324,
    "latitude":30.191204,
    "accuracy":40,
    "street":"六和路",
    "city":"杭州市",
    "contry":"中国",
    "cityCode":"179",
    "locationType":161,
    "province":"浙江省",
    "msg":"网络定位成功",
    "speed":0,
    "addressStr":"中国浙江省杭州市滨江区六和路"
}

地理编码

/**
 * 地理编码(根据位置信息解析经纬度)
 * @param data{Object}
 * @param data.city {String} 城市 必填例如“杭州市”
 * @param data.address {String} 地址 必填 例如“滨江区六合路”
 * @returns {Promise<any>}
 */

LocationApi.geoCode({city: "杭州市", address: "滨江区海创基地"}).then(result => {
                            this.show(result)
                        }).catch(err => {
                            this.show(err)
                        })

返回数据

{
    "longitude":120.1923699266653,
    "latitude":30.18758692436436
}

逆地理编码

/**
 * 逆地理编码(根据经纬度转地址)
 * @param data
 * @param data.longitude {Double}  经度,必填
 * @param data.latitude {Double} 纬度 必填
 * @returns {Promise<any>}
 */

 LocationApi.reverseGeoCode({latitude: 30.1911, longitude: 120.146116}).then(result => {
                            this.show(result)
                        }).catch(err => {
                            this.show(err)
                        })

返回数据

{
    "countryCode":0,
    "streetNumber":"",
    "countryName":"中国",
    "district":"滨江区",
    "street":"六和路",
    "province":"浙江省",
    "city":"杭州市",
    "cityCode":179,
    "address":"浙江省杭州市滨江区六和路"
}

POI

/**
 * 获取poi
 * @param data
 * @param data.longitude {Double}  经度,必填
 * @param data.latitude {Double} 纬度 必填
 * @param data.keyWord {String}  搜索关键词,必填
 * @param data.radius {int}  搜索半径,选填,默认1000
 * @param data.pageCapacity {int} 查询数量 ,选填默认20
 *
 * @returns {Promise<any>}
 */
   LocationApi.getNearbyPoi({
            ...position,
            keyWord: keyWord,
            pageCapacity: 20,
            radius: 1000
        }).then((result) => {
            let poi = result.poi;
        }).catch(err => {
        });

返回数据

{
    "poi":[
        {
            "latitude":30.18877317718689,
            "longitude":120.16136940351595,
            "phoneNum":"",
            "name":"江南大道东信大道口",
            "city":"杭州市",
            "address":"124路;139路;315路;354路"
        },
        {
            "latitude":30.189139976125272,
            "longitude":120.16054296244677,
            "phoneNum":"",
            "name":"江南大道东信大道口",
            "city":"杭州市",
            "address":"124路;139路;315路;354路"
        },
        {
            "latitude":30.18828150836035,
            "longitude":120.1639295742194,
            "phoneNum":"",
            "name":"江南大道伟业路口",
            "city":"杭州市",
            "address":"124路;315路;354路"
        },
        {
            "latitude":30.18830492121784,
            "longitude":120.16439669308458,
            "phoneNum":"",
            "name":"江南大道伟业路口",
            "city":"杭州市",
            "address":"124路;139路;315路;354路"
        },
        {
            "latitude":30.189506773683753,
            "longitude":120.1597075383225,
            "phoneNum":"",
            "name":"江南大道东信大道口",
            "city":"杭州市",
            "address":"124路;315路"
        }
    ],
    "msg":"成功",
    "errCode":0
}

地图

地图使用及参数参考demo.