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

hj-js-sdk

v0.6.0

Published

``` 安装:npm install hj-js-sdk

Downloads

20

Readme

安装及使用说明

    安装:npm install hj-js-sdk

    使用:
    导入:
    const hj = require('hj-js-sdk')
    import hj from 'hj-js-sdk'

    例子:
    hj.getUserInfo({
     success: function(userInfo) {
       // userinfo为用户信息
       id:用户id,
       token: token,
       account: 账号,
       name: 姓名,
       mobile: 手机号,
       email: 邮箱,
       orgId: 公司id,
       orgName: 公司名称,
       roleIds: 用户权限id,
       roleNames: 用户权限名称,
       entCodes: 企业code,
       entNames: 企业名称,
       model: 当前登录模式(园区模式1,综合模式0),
       icon: 头像,
       parkCode: 当前登录的园区(嘉兴港区1,山东蓝区2,江苏启东3,江苏赣榆4,新疆伊吾5),
     }
    })

    默认只打印error级别的错误。
    trace: 编写框架时,基础的方法调用顺序
    debug: 编写框架时的调试顺序
    info:  方法回调
    error: 提示框架级错误

    调试模式:
    开启:hj.openDebug()
    关闭: hj.closeDebug()

调试文档

请先阅读调试文档 下载二维码

版本更新

2023.07.20-版本号:0.6.0修复0.5.9 2023.07.20-版本号:0.5.9修复0.5.8产物更新 2023.07.19-版本号:0.5.8新增web__去掉延时返回逻辑 2023.06.15-版本号:0.5.7添加打开小程序 2023.05.15-版本号:0.5.6新增chooseLocation方法 2023.01.09-版本号:0.5.5NFC,录音和播放音频 2022.12.07-版本号:0.5.4getSingleToken传参修复和文档更新 2022.12.06-版本号:0.5.3获取当前应用的信息和单点登录令牌获取 2022.10.19-版本号:0.5.2视频和录音支持oss参数 2022.09.09-版本号:0.5.1新增h5登录后回调app方法 2021.07.05-版本号:0.5.0调整容器初始化判断 2021.05.29-版本号:0.4.7增加选择、播放视频,开始取消结束录音 2021.05.27-版本号:0.4.6增加打开地图app方法openMapApp 2021.05.13-版本号:0.4.5ua判断写法调整 2021.05.12-版本号:0.4.4添加微信容器判断 2021.05.10-版本号:0.4.3添加h5容器判断:恒嘉APP,浙政钉,浙里办,支付宝小程序 2021.03.11-版本号:0.4.2移除getUserInfoWithContact 2021.02.02-版本号:0.4.1更新文档调试部分及提供下载二维码 2021.01.29-版本号:0.4.0新增getUserInfoWithContact,getLocation,scanQRCode,checkJsApi 2021.01.25-版本号:0.3.9修复打包问题 2021.01.22-版本号:0.3.8所有方法添加超时逻辑 2021.01.22-版本号:0.3.7更新调试模式的使用文档 2021.01.22-版本号:0.3.6兼容vConsole 2021.01.21-版本号:0.3.5添加调试模式,添加异步超时逻辑 2021.01.08-版本号:0.3.4还原记录 2021.01.08-版本号:0.3.3测试 2021.01.08-版本号:0.3.2解决瞄点问题测试 2021.01.08-版本号:0.3.1修复文件丢失 2021.01.08-版本号:0.3.0移除开发依赖关系 2021.01.08-版本号:0.2.8依赖关系 2021.01.07-版本号:0.2.7支持ES5 2020.12.31-版本号:0.2.6更新文档 2020.12.31-版本号:0.2.5更新文档 2020.12.31-版本号:0.2.4未描述更新内容 2020.12.25-版本号:0.2.3更新demo地址 2020.11.26-版本号:0.2.2不支持?. 2020.11.26-版本号:0.2.1修复安卓js注册 2020.11.26-版本号:0.2.0删除init 2020.11.26-版本号:0.1.9解决log错误 2020.11.25-版本号:0.1.8android bridge init 2020.11.24-版本号:0.1.7修复低版本(iOS10)系统中异步获取用户信息问题 2020.11.23-版本号:0.1.6修复异步 2020.11.23-版本号:0.1.5添加log功能,支持模块和异步顺序输出 2020.11.23-版本号:0.1.4npm预览 2020.11.20-版本号:0.1.3文档更新到npm 2020.11.20-版本号:0.1.2修复异步问题 2020.11.20-版本号:0.1.1分离环信 2020.11.19-版本号:0.1.0新增环信模块 2020.11.10-版本号:0.0.9文档格式、支持异步个人信息

文档

index

恒嘉-HJ-JS桥 hj-js-sdk

Example

import hj from 'hj-js-sdk'
hj.getbridge 原生注册,供js调用原生
hj.setbridge h5注册,供原生调用

index~getUserInfo(params)

获取用户信息

Kind: inner method of index

| Param | Type | Description | | --- | --- | --- | | params | object | js传入参数 | | params.success | getUserInfoCallback | 原生回调调用函数. |

Example

hj.getUserInfo({
     success: function(userInfo) {
       // userinfo为用户信息
       id:用户id,
       token: token,
       account: 账号,
       name: 姓名,
       mobile: 手机号,
       email: 邮箱,
       orgId: 公司id,
       orgName: 公司名称,
       roleIds: 用户权限id,
       roleNames: 用户权限名称,
       entCodes: 企业code,
       entNames: 企业名称,
       model: 当前登录模式(园区模式1,综合模式0),
       icon: 头像,
       parkCode: 当前登录的园区(嘉兴港区1,山东蓝区2,江苏启东3,江苏赣榆4,新疆伊吾5),
     }
})

index~asyncGetUserInfo(params) ⇒ Promise.<object>

异步获取用户信息(推荐使用getUserInfoAsync,后期会移除该方法)

Kind: inner method of index
Returns: Promise.<object> - - 网络请求返回对象,参考getUserInfoCallback的userInfo

| Param | Type | Description | | --- | --- | --- | | params | object | js传给原生的参数 |

Example

const info = await hj.asyncGetUserInfo()

index~getUserInfoAsync(params) ⇒ Promise.<object>

异步获取用户信息

Kind: inner method of index
Returns: Promise.<object> - - 网络请求返回对象,参考getUserInfoCallback的userInfo

| Param | Type | Description | | --- | --- | --- | | params | object | js传给原生的参数 |

Example

const info = await hj.getUserInfoAsync()

index~loginApp(params, success)

h5登录

Kind: inner method of index

| Param | Type | Description | | --- | --- | --- | | params | object | 参数 | | params.parkCode | string | 园区code | | params.userName | string | 用户名 | | params.nickName | string | 昵称 | | params.userId | string | 用户名 | | params.phone | string | 手机号 | | success | Callback | 原生回调调用函数. |

Example

hj.loginApp({
    parkCode: '',
    userName: '',
    nickName: '',
    userId: '',
    phone: ''
}, success: function (res) {})

index~getAppInfo(params)

获取当前应用的信息

Kind: inner method of index

| Param | Type | Description | | --- | --- | --- | | params | object | js传入参数 | | params.success | getAppInfoCallback | 原生回调调用函数. |

Example

hj.getAppInfo({
     success: function(appInfo) {
     }
})

index~getSingleToken(params)

单点登录令牌获取

Kind: inner method of index

| Param | Type | Description | | --- | --- | --- | | params | object | js传入参数 | | params.showLoading | string | showLoading: true 原生显示弹窗 | | params.success | getSingleTokenCallback | 原生回调调用函数. |

Example

hj.getSingleToken({
     success: function(resp) {
     }
})

index~chooseImage(params)

选择图片

Kind: inner method of index

| Param | Type | Description | | --- | --- | --- | | params | object | 参数 | | params.count | string | 个数,不传默认为1. | | params.oss | string | oss | | params.original | string | original原始文件 | | params.success | chooseImageCallback | 原生回调调用函数. |

Example

hj.chooseImage({
    count: 1, // 每次选择图片的数量,可不传,默认1
    success: function (res) { // 获取app返回的base64图片数组res后,做处理
    }
})

index~chooseVideo(params)

选择视频

Kind: inner method of index

| Param | Type | Description | | --- | --- | --- | | params | object | 参数 | | params.count | string | 选择的视频数量,目前只支持每次选择1 | | params.oss | string | oss | | params.original | string | original原始文件 | | params.success | chooseVideoCallback | 原生回调调用函数. |

Example

hj.chooseVideo({
     count: 1, //选择的视频数量,目前只支持每次选择1
     time: 10,//限制拍摄视频的时长
     success: function (res) { // 返回oss相对地址数组
    }
})

index~playVideo(params)

播放视频

Kind: inner method of index

| Param | Type | Description | | --- | --- | --- | | params | object | 参数 | | params.url | string | 视频的url | | params.success | playVideoCallback | 原生回调调用函数. |

Example

hj.playVideo({
     url: xxx, // 视频的url
     success: function (res) { // 返回{code:0}  表示视频获取成功
    }
})

index~startRecord(params)

开始录音

Kind: inner method of index

| Param | Type | Description | | --- | --- | --- | | params | object | 参数 | | params.success | startRecordCallback | 原生回调调用函数. |

Example

hj.startRecord({
     success: function (res) { // 返回{code:0}  表示录音设置权限等成功,开始正式录音
    }
})

index~stopRecord(params)

停止录音

Kind: inner method of index

| Param | Type | Description | | --- | --- | --- | | params | object | 参数 | | params.oss | string | oss | | params.original | string | original原始文件 | | params.success | stopRecordCallback | 原生回调调用函数. |

Example

hj.stopRecord({
     success: function (res) { // 返回{url:xxx}  录音上传oss后的相对地址
    }
})

index~cancelRecord(params)

取消录音

Kind: inner method of index

| Param | Type | Description | | --- | --- | --- | | params | object | 参数 | | params.success | cancelRecordCallback | 原生回调调用函数. |

Example

hj.cancelRecord({
     success: function (res) {
    }
})

index~playAudio(params)

播放音频

Kind: inner method of index

| Param | Type | Description | | --- | --- | --- | | params | object | 参数 | | params.url | string | 音频的url | | params.success | playAudioCallback | 原生回调调用函数. |

Example

hj.playAudio({
     url: xxx, // 音频的url
     success: function (res) { // 返回{code:0}  表示音频获取成功
    }
})

index~nfcRead(params)

NFC

Kind: inner method of index

| Param | Type | Description | | --- | --- | --- | | params | object | 参数 | | params.success | nfcReadCallback | 原生回调调用函数. |

Example

hj.nfcRead({
    success: function (res) {
    }
})

index~openMapApp(params)

跳转地图

Kind: inner method of index

| Param | Type | Description | | --- | --- | --- | | params | object | 参数 | | params.type | string | 地图类型,bd:百度,tx:腾讯,gd:高德. | | params.success | openMapAppCallback | 原生回调调用函数. |

Example

hj.openMapApp({
     type: 'bd', //地图类型,bd:百度,tx:腾讯,gd:高德
     startLon: 0.000,//起点
     startLat: 0.00,//起点
     originRegion:'北京',//起点地区
     endLon: 0.000,//终点
     endLat: 0.00,//终点
     destinationRegion:'北京',//终点地区
     origin:'北京',//起点名称
     destination:'北京',//终点名称
     mode:'driving',//导航模式
     success: function (res) { // code:'0' 有安装地图app,code='1' 未安装地图app
    }
})

index~gotoLogin(params)

去登录

Kind: inner method of index

| Param | Type | Description | | --- | --- | --- | | params | object | 参数 | | params.success | jsCommodCallback | 原生回调调用函数. |

Example

hj.gotoLogin(
 {success: function(res) {
          console.log(res)
         }}
)

index~back(params)

关闭控制器

Kind: inner method of index

| Param | Type | Description | | --- | --- | --- | | params | object | 参数 | | params.success | jsCommodCallback | 原生回调调用函数. |

Example

hj.back(
 {success: function(res) {
          console.log(res)
         }}
)

index~openWeb(params)

通过原生打开新窗口

Kind: inner method of index

| Param | Type | Description | | --- | --- | --- | | params | object | 参数 | | params.new_path | string | 打开地址 | | params.success | jsCommodCallback | 原生回调调用函数. |

Example

hj.openWeb({
  new_path: new_path
  success: function(res) {
          console.log(res)
         }
})

index~openWXMiniPro(params)

打开微信小程序

Kind: inner method of index

| Param | Type | Description | | --- | --- | --- | | params | object | 参数 | | params.userName | string | 小程序username | | params.path | string | 小程序页面的路径。不填写默认首页 | | params.miniProgramType | number | 0正式、1开发、2体验。默认为0; | | params.extMsg | string | ext信息 | | params.extDic | object | 字典,可存放图片等比较大的数据。 | | params.success | jsCommodCallback | 原生回调调用函数. |

Example

hj.openWXMiniPro({
  userName: ''
  path: '',
  success: function(res) {
          console.log(res)
         }
})

index~openFile(params)

打开文档

Kind: inner method of index

| Param | Type | Description | | --- | --- | --- | | params | object | 参数 | | params.name | string | 文件名. | | params.url | string | 文件地址. | | params.success | jsCommodCallback | 原生回调调用函数. |

Example

hj.openFile({
  name: name,
  url: url
  success: function(res) {
      console.log(res)
    }
})

index~getLocation(params)

获取地理位置接口

Kind: inner method of index

| Param | Type | Description | | --- | --- | --- | | params | object | 参数 | | params.type | string | 默认为百度地图bd09,支持传入wgs84和gcj02 | | params.success | getLocationCallback | 原生回调调用函数. |

Example

hj.getLocation({
  type: 'bd09'
  success: function(info) {
    accuracy = 10,
    latitude = 30.62492979125895,
    longitude = 121.0690990771683,
    speed = -1,
    rgcData =     {
     adCode = 330482;
     city = "嘉兴市";
     cityCode = 334;
     country = "中国";
     countryCode = 0;
     district = "平湖市";
     locationDescribe = "在嘉兴市杭州湾新经济园附近";
     poiList =         (
                     {
             name = "嘉兴市杭州湾新经济园";
             relaiability = "0.99";
             uid = 736135013774233805;
         },
                     {
             name = "顾家门";
             relaiability = "0.99";
             uid = 17991853371446788095;
         },
                    {
             name = "顾庄桥";
             relaiability = "0.99";
             uid = 17670125394302337023;
         },
                     {
             name = "嘉兴长三角国际石材城";
             relaiability = "0.99";
            uid = 1258848691049988095;
         },
                    {
             name = "新经济园省重点科创园";
             relaiability = "0.99";
             uid = 10928305777578794476;
         }
     );
     province = "浙江省";
     street = "市场西路";
    };
   }
})

index~chooseLocation(params)

地图

Kind: inner method of index

| Param | Type | Description | | --- | --- | --- | | params | object | 参数 | | params.success | chooseLocationCallback | 原生回调调用函数. |

Example

hj.chooseLocation({
    success: function (res) { // 扫码结果
    }
})

index~scanQRCode(params)

扫码

Kind: inner method of index

| Param | Type | Description | | --- | --- | --- | | params | object | 参数 | | params.success | chooseImageCallback | 原生回调调用函数. |

Example

hj.scanQRCode({
    success: function (res) { // 扫码结果
    }
})

index~checkJsApi(params)

判断当前客户端版本是否支持指定JS接口

Kind: inner method of index

| Param | Type | Description | | --- | --- | --- | | params | object | 参数 | | params.jsApiList | array | 方法名数组 | | params.success | chooseImageCallback | 原生回调调用函数. |

Example

checkJsApi({
 jsApiList: ['chooseImage', 'chooseImage1],
 success: function (res) {
  console.log(res);
  // 以键值对的形式返回,可用的api值true,不可用为false
  // 如:{"checkResult":{"chooseImage":true},"errMsg":"checkJsApi:ok"}
  },
 })

index~h5InHTHJApp() ⇒ Bool

// 恒嘉APP

Kind: inner method of index
Returns: Bool - - Bool
Example

hj.h5InHTHJApp()

index~h5InZZD() ⇒ Bool

// 浙政钉

Kind: inner method of index
Returns: Bool - - Bool
Example

hj.h5InZZD()

index~h5InZLB() ⇒ Bool

// 浙里办

Kind: inner method of index
Returns: Bool - - Bool
Example

hj.h5InZLB()

index~h5InZFBXCX() ⇒ Bool

// 支付宝小程序

Kind: inner method of index
Returns: Bool - - Bool
Example

hj.h5InZFBXCX()

index~h5InWxClient() ⇒ Bool

// 微信容器

Kind: inner method of index
Returns: Bool - - Bool
Example

hj.h5InWxClient()

index~getUserInfoCallback : function

This callback is displayed as a global member.

Kind: inner typedef of index

| Param | Type | Description | | --- | --- | --- | | userInfo | object | 返回对象 | | userInfo.id | string | 用户id | | userInfo.account | string | 账号 | | userInfo.roleIds | string | 用户权限id | | userInfo.roleNames | string | 用户权限名 | | userInfo.icon | string | 头像, | | userInfo.parkCode | string | 当前登录的园区(嘉兴港区1,山东蓝区2,江苏启东3,江苏赣榆4,新疆伊吾5), |

index~chooseImageCallback : function

This callback is displayed as a global member.

Kind: inner typedef of index

| Param | Type | Description | | --- | --- | --- | | res | array | // 获取app返回的base64图片数组res后,做处理 |

index~getAppInfoCallback : function

This callback is displayed as a global member.

Kind: inner typedef of index

| Param | Type | Description | | --- | --- | --- | | appInfo | object | 返回对象 |

index~getSingleTokenCallback : function

This callback is displayed as a global member.

Kind: inner typedef of index

| Param | Type | Description | | --- | --- | --- | | resp | object | 返回对象 |

index~jsCommodCallback : function

This callback is displayed as a global member.

Kind: inner typedef of index

| Param | Type | Description | | --- | --- | --- | | object | object | // 原生同步返回 |

index~getLocationCallback : function

This callback is displayed as a global member.

Kind: inner typedef of index

| Param | Type | Description | | --- | --- | --- | | info | object | 返回对象 | | info.latitude | double | 纬度,浮点数,范围为90 ~ -90 | | info.longitude | double | 经度,浮点数,范围为180 ~ -180 | | info.speed | int | 速度,以米/每秒计 | | info.accuracy | int | 位置精度 | | info.rgcData | object | 地址数据 * @param {object} info.rgcData 地址数据 |

index~chooseLocationCallback : function

This callback is displayed as a global member.

Kind: inner typedef of index

| Param | Type | Description | | --- | --- | --- | | info | object | 返回对象 | | info.name | double | POI名称 | | info.address | double | POI地址信息 | | info.latitude | double | 纬度,浮点数,范围为90 ~ -90 | | info.longitude | double | 经度,浮点数,范围为180 ~ -180 | | info.province | string | POI所在省份 | | info.city | string | POI所在城市 | | info.area | string | POI所在行政区域 | | info.phoneNum | string | POI电话号码 |

hx

恒嘉-环信部分 hj.hx

Example

import hj from 'hj-js-sdk'
hj.hx.fun

hx~hxCreateConference(params) ⇒ Promise.<object>

创建会议 (js调用原生网络请求)

Kind: inner method of hx
Returns: Promise.<object> - - 网络请求返回对象

| Param | Type | Description | | --- | --- | --- | | params | object | 参数 | | params.serviceType | string | 会议业务标识 | | params.roomName | string | 会议名称 | | params.phones | string | 参会成员手机号,用于给这些用户推送 |

hx~hxInviteConference(params) ⇒ Promise.<object>

邀请加入会议 (js调用原生网络请求)

Kind: inner method of hx
Returns: Promise.<object> - - 网络请求接口格式

| Param | Type | Description | | --- | --- | --- | | params | object | 参数 | | params.serviceType | string | 会议业务标识 | | params.hxRoomId | string | 会议id | | params.phones | string | 参会成员手机号,用于给这些用户推送 |

hx~hxJoinConference(params) ⇒ Promise.<object>

加入会议 (js调用原生进入会议,此操作是使用者主动加入)

Kind: inner method of hx
Returns: Promise.<object> - - 加入结果

| Param | Type | Description | | --- | --- | --- | | params | object | 参数 | | params.serviceType | string | 会议业务标识 | | params.hxRoomId | string | 会议id | | params.hxRoomPassword | string | 会议密码 |

hx~hxGetConferenceIngList(params) ⇒ Promise.<object>

获取正在进行中的会议

Kind: inner method of hx
Returns: Promise.<object> - - 网络请求返回对象

| Param | Type | Description | | --- | --- | --- | | params | object | 参数 | | params.serviceType | string | 会议业务标识 | | params.pageSize | int | 原生回调调用函数 | | params.pageNum | int | 原生回调调用函数 |

hx~hxGetConferenceHistoryList(params) ⇒ Promise.<object>

获取正在进行中的会议

Kind: inner method of hx
Returns: Promise.<object> - - 网络请求返回对象

| Param | Type | Description | | --- | --- | --- | | params | object | 参数 | | params.serviceType | string | 会议业务标识 | | params.pageSize | int | 原生回调调用函数 | | params.pageNum | int | 原生回调调用函数 |

hx~hxLeaveConference(params)

离开会议 (原生告知js部分离开会议,原生调用js方法)

Kind: inner method of hx

| Param | Type | Description | | --- | --- | --- | | params | object | 参数 | | params.success | string | 原生回调调用函数 |

hx~hxCloneConference(params) ⇒ Promise.<object>

会议记录列表重新发起一个新的会议

Kind: inner method of hx
Returns: Promise.<object> - - 网络请求返回对象

| Param | Type | Description | | --- | --- | --- | | params | object | 参数 | | params.serviceType | string | 会议业务标识 | | params.hxRoomId | int | 原会议id |

JSbridge

恒嘉-JS桥 JSbridge

JSbridge~setbridge(funName, dataJson, callback)

js注册方法供原生调用

Kind: inner method of JSbridge

| Param | Type | Description | | --- | --- | --- | | funName | string | 注册函数名 | | dataJson | object | js传给原生的参数 | | callback | function | 回调函数 |

JSbridge~getbridge(funName, dataJson, callback)

js调用原生注册的方法

Kind: inner method of JSbridge

| Param | Type | Description | | --- | --- | --- | | funName | string | 调用原生的函数 | | dataJson | object | js传给原生的参数 | | callback | function | 回调函数 |