@sinosun/lib
Version:
sinosun jsbridge and net toolkit
121 lines (91 loc) • 3.73 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
var _defineProperty = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/define-property"));
(0, _defineProperty["default"])(exports, "__esModule", {
value: true
});
/*
* @Author: dingfeng
* @Description:
* @FilePath: \sinosunlib\src\AppApi\Bridge\IJsBridge.js
*/
/**
* @author miaoju
* @description jsbridge接口
*/
var IJsBridge =
/** @class */
function () {
function IJsBridge() {}
/**
* 调用native jsbridge接口
* @param {*} method 接口名称
* @param {*} data 参数对象
*/
IJsBridge.prototype.callHandler = function (method, data) {
console.log(method, data);
};
/**
* 注册app端提供的监听事件
* @param {*}} method
* @param {*} callback
*/
IJsBridge.prototype.registerHandler = function (method, callback) {
return console.log(method, callback);
};
/**
* 打开页面
* @param {*} url
*/
IJsBridge.prototype.openPage = function (url) {
console.log(url);
};
/**
* 监听app菜单监听事件
* @param {Object} menuList
* {
List<MenuItem> menuList;
}
MenuItem {
String name; // 如果是菜单,用name显示菜单文字
String iconNormalBase64; // 如果是图标按钮,用来显示 正常图标(JS交互时,用base64转码,如果图片超过5k,提出来让UI重新切图)
String iconPressedBase64; // 如果是图标按钮,用来显示 按下效果 图标(JS交互时,用base64转码,如果图片超过5k,提出来让UI重新切图)
String menuId; //必填 菜单ID (不区分是 图标按钮 或是 菜单项),列表中的menuId必须相互唯一
Int type; // 必填 类型 1 ActionBar上的图标按钮,2 下拉菜单项 3 title显示(一般情况下,只有一个图标按钮,可以有多个下拉菜单项)
}
注意
name 和 iconNormalBase64 至少需要填写一个;
name 和iconNormalBase64 都有值时ActionBar上的按钮优先显示name,下拉菜单项会左边显示图标,右边显示name;
当有多个type 为1的item时,app会取第一个值;
下拉菜单项显示顺序默认按menuList的顺序排序;
_this.initTitle = ['考勤统计',{name:'设置',menuId:'but_1_1',type: 1,func:function(){openPage('setting.html')}}];
_this.initTitle = ['考勤统计',{name:'设置',func:function(){openPage('setting.html')}}];
*/
IJsBridge.prototype.registerMenu = function (menuList) {
console.log(menuList);
};
/**
* 调用app回退页面
* @param {*} url 回退到制定url的页面
* @param {*} backSteps 回退页面数
* @param {*} loadData 回退页面后传给上一页面的数据
*/
IJsBridge.prototype.goBack = function (url, backSteps, loadData) {
console.log(url, backSteps, loadData);
}; // 从app获取真实线上地址
IJsBridge.prototype.getHost = function (key) {
console.log("getHost_ByApp_" + key);
}; // 获取真实地址
IJsBridge.prototype.getRealHost = function (key) {
console.log("getRealHost" + key);
};
IJsBridge.prototype.getUrlParam = function (key, urlParams) {
return console.log(key, urlParams);
}; //打开小应用,如果小应用入口地址不能配置全,需要做处理
IJsBridge.prototype.openAppRoute = function () {};
IJsBridge.prototype.fileUploadFunction = function () {}; //打开联系人
IJsBridge.prototype.selectContact = function (data) {}; //扫描二维码
IJsBridge.prototype.scanQrcode = function () {};
return IJsBridge;
}();
exports["default"] = IJsBridge;