Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
hybrid-api
Advanced tools
```html <script src="https://nnapp.cloudbae.cn:38080/storage/api/v1/file/hybrid/hybrid-api-4.0.3.js"></script> ``` 也可以通过 npm 安装,如果是以 import 形式导入项目,那则不需要 YBB 的命名空间,直接使用 hybrid 即可。 ```bash npm install hybrid-api@4.0.0 ``` ```js // 示例 import { hybri
<script src="https://nnapp.cloudbae.cn:38080/storage/api/v1/file/hybrid/hybrid-api-4.0.3.js"></script>
也可以通过 npm 安装,如果是以 import 形式导入项目,那则不需要 YBB 的命名空间,直接使用 hybrid 即可。
npm install hybrid-api@4.0.0
// 示例
import { hybrid } from 'hybrid-api';
hybrid.location.get().then(result => {
console.log(result);
})
开启debug模式,混合开发框架会在控制台打印调用信息
hybrid.debug = true;
// 调用原生方法
hybrid.apiRegister.callHandler('methodName', {paramKey: 'paramValue'}).then(function(result) {
console.log(result);
});
// 注册方法给原生调用
hybrid.apiRegister.registerHandler('methodName', function(data, nativeCallback) {
console.log(data);
nativeCallback();
});
// 监听原生事件
hybrid.apiRegister.listen('methodName', {paramKey: 'paramValue'}, function() {
console.log('事件触发了')
})
YBB.hybrid.device.getUUID().then(function(info) {
console.log(info.uuid);
});
var params = {
cancelButton: '取消',
otherButtons: ['拍照', '相册']
};
YBB.hybrid.device.selectImg(params).then(function(info) {
// info.imgPath 为本地地址
console.log(info.imgPath);
});
var params = {
cancelButton: '取消',
otherButtons: ['拍照', '相册']
};
YBB.hybrid.device.chooseImg(params).then(function(info) {
// info = {result: boolean, picPath: string}
// info.picPath 为网络地址
console.log(info.picPath);
});
var min = 1;
var max = 10;
var options = {
url: 'http://www.example.com/upload-api',
method: 'post';
// headers?: { [key: string]: string };
// params?: { [key: string]: any };
// body?: any;
}
YBB.hybrid.device.uploadImages(min, max, options).then(function(result) {
console.log(result);
})
YBB.hybrid.device.fetchWearableDeviceData().then(function(result) {
/*
result = {
deviceInfo: {firmwareVersion: string};
stepArray: [{steps: number
distance: number;
calories: number;
timestamp: number;}];
sleepArray: [{
score: any;
timestamp: string;
}];
hrArray: [{
pulse: number;
timestamp: number;
}];
spO2Array: [{
spo2: number;
timestamp: number;
}];
}
*/
console.log(result);
})
YBB.hybrid.device.bindingWearableDevice();
YBB.hybrid.device.unbindingWearableDevice();
YBB.hybrid.location.get().then(function(location) {
/**
* location = {
* longitude: string; // 经度
* latitude: string; // 纬度
* detailAddress: string; // 详细地址
* cityName: string; // 城市
* region: string; // 区域名称
* }
*/
console.log(location);
});
YBB.hybrid.navigation.close();
YBB.hybrid.navigation.hide();
YBB.hybrid.navigation.show();
var isShow = true; // 是否显示
var options = {
text: 'string', // 按扭文字
icon: 'string' // 可选的,icon 图片url
};
YBB.hybrid.navigation.setRightBtn(isShow, options).click(function() {
console.log('按扭被点击了');
});
YBB.hybrid.navigation.setTitle({title: 'string'})
var titles = ['标题1', '标题2'];
YBB.hybrid.navigation.setSegments(titles).click(function(index) {
console.log('第' + index + '个标题被点击了');
});
var appId = 'appId';
YBB.hybrid.user.certification(appId).then(function(data) {
/**
* data = {
* certSuccess: string; // '0' 失败, '1' 成功,'2'审核中
* username: string; // 用户名
* idCardNo: string; // 身份证号码
* mobile: string; // 手机号码
* }
*/
console.log(data);
});
var targetUrl = 'http://user.test.com';
YBB.hybrid.user.authorization(targetUrl).then(function(data) {
/**
* data = {
* state: string;
* code: string;
* }
*/
console.log(data);
});
// params 可选
var params = {
returnUrl: 'xxx' // 登录成功后重定向url
}
YBB.hybrid.user.login(params).then(function(result) {
if (result.isLogin) {
console.log('登录成功');
}
});
// params 是可选的
var params = {
certType: '', // 刷脸方式 取值:字段不传默认为 - 三版, zhima- 芝麻认证, ps - 公安, ss - 社保
certName: '', // 刷脸人姓名
mobile: '', // 手机号(暂只有公安刷脸需要)
certNo: '' // 刷脸人身份证
};
YBB.hybrid.user.eyePatternRecognition(parmas).then(function(result) {
// result = { code: number, key?: any }
// code = -1, // 用户主动取消
// code = 0,// 认证成功
// code = 1, // 认证失败
// code = 2, // 审核中
// code = 3, // 认证渠道不可用
console.log(result);
});
var params = {
type: 'stepCount',
startDate: '2018-03-23', // 时间支持两种格式: yyy-MM-dd 或者 yyyy-MM-dd hh:mm:ss
endDate: '2018-04-01'
};
YBB.hybrid.user.healthData(params).then(function(result) {
console.log(result.stepCount);
})
var params = {
type : 'pwdValidate'
};
YBB.hybrid.user.essc(params).then(function(result) {
console.log(result.busiSeq);
})
var url = 'http://user.test.com';
var params = {name: 'name'};
// params 是可选的
YBB.hybrid.util.openLink(url, params);
var url = 'http://user.test.com';
var params = {name: 'name'};
// params 是可选的
YBB.hybrid.util.openSchemeURI(url, params);
// 免密支付签约示例代码
var url = '签约url';
YBB.hybrid.util.openSchemeURI(url, {
paySign: 'wx' // 或者 'alipay'
}).then(function(result) {
if (result.signStatus) {
console.log('签约成功');
}
});
var args = {
title: '标题', // 标题
content: '分享内容', // 分享内容
imageUrl: 'http://test.user.com/a.jpg', // 分享图片地址
targetUrl: 'http://test.user.com/target', // 分享跳转的目标地址
description: '', // 运营文案
type: 'webpage' // 分享类型 'image' | 'text' | 'imageAndText' | 'webpage' | 'music'
};
YBB.hybrid.util.share(args).then(function() {
console.log('分享成功!');
}).cache(function(error) {
console.log(error);
console.log('分享失败!');
})
var scanType = 'qrCode';
YBB.hybrid.util.scan(scanType).then(function(result) {
// result = {text: 'text text'}
console.log(result);
});
var params = '{key: value}'; // 由后台提供的字符串
var type = 'Pay'; // type 是可选参数,根据不同应用,传递 'Pay' 或者 'InputPassword'
YBB.hybrid.util.pay(params, type).then(function(response) {
/**
* response = {
* stateCode?: number; // 1. 支付成功 2.支付失败 3.用户主动取消支付 4.版本不支持或 type 不支持
* errCode?: any; // 支付出错时,支付平台返回的errorCode,具体值参考:
* // 支付宝:https://docs.open.alipay.com/204/105301/
* // 微信:https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=8_5
* resultDes?: string; // 结果描述,具体描述为各个支付平台对应的错误描述
* payPassword?: string; // 加密后的支付密码
* }
*/
console.log(response);
});
YBB.hybrid.util.getIP().then(function(response) {
console.log(response.clientIP);
});
YBB.hybrid.util.fingerprint().then(function(result) {
console.log(result);
});
拿到指纹采集的结果和IP,并传给后台,由后台生成微信支付的 url,前端跳转到对应地址即可。示例如下:
Promise.all([YBB.hybrid.util.fingerprint(), YBB.hybrid.util.getIP()]).then(function(result) {
var fingerprint = result[0];
var ip = result[1].clientIP;
$.ajax({
url: '此URL为商户生成预支付charge对象后端服务地址',
method: 'post',
// 必传参数
data: {
// 浏览器指纹
fingerprint: fingerprint,
// 当前客户端IP地址
ip: ip
}
}).success(function(response) {
// 若 failureCode 为 null 即为预支付成功
// 若 failureCode 不为 null 则预支付生成存在异常,具体异常信息请查看 response.failureMsg
if (response.failureCode === null) {
// 获得到订单号
var orderNo = response.orderNo;
// 经过encodeURIComponent转义
var url = encodeURIComponent('此URL为商户支付完毕后的回传地址?orderNo=' + orderNo);
location.href = response.credential.wx.mweb_url + '&redirect_url=' + url;
}
});
});
在调用微信支付后的回调页面,可以调用弹出窗,由用户选择是支付成功,还是重新支付,不管用户选择什么,真正的支付结果,均以查询后台接口为准
YBB.hybrid.util.showWeixinPayModal().then(function(selectResult) {
if (selectResult) {
console.log('用户选择了支付成功');
} else {
console.log('用户选择了重新支付');
}
});
YBB.hybrid.util.getAppVersion().then(function(result) {
console.log(result.appVersion);
console.log(result.updateUrl);
});
YBB.hybrid.util.snapshot();
/**
*@param username {string} 表示小程序原始ID
*@param miniProgramType {string} 小程序类型,正式版:WXMiniProgramTypeRelease 测试版: WXMiniProgramTypeTest; 体验版: WXMiniProgramTypePreview;
*@param path {string} 可选, 表示要跳转到目标小程序的具体 page 页面,默认到首页
*/
var username = '';
var miniProgramType = '';
var path = '';
YBB.hybrid.util.openWeiXinMiniProgram(username, miniProgramType, path).then(function() {
console.log('打开成功')
})
var params = {
ios: '', // schemaURL
android: '' // 包名
};
YBB.hybrid.util.canOpenURL(params).then(function(result) {
console.log(result.isCanOpen);
})
FAQs
```html <script src="https://nnapp.cloudbae.cn:38080/storage/api/v1/file/hybrid/hybrid-api-4.0.3.js"></script> ``` 也可以通过 npm 安装,如果是以 import 形式导入项目,那则不需要 YBB 的命名空间,直接使用 hybrid 即可。 ```bash npm install hybrid-api@4.0.0 ``` ```js // 示例 import { hybri
The npm package hybrid-api receives a total of 0 weekly downloads. As such, hybrid-api popularity was classified as not popular.
We found that hybrid-api demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.