diff --git a/YT_Client_api.js b/YT_Client_api.js new file mode 100644 index 0000000..1d70ae6 --- /dev/null +++ b/YT_Client_api.js @@ -0,0 +1,61 @@ +/** + * @author 何杰 + * @date 2016-08-01 12:00:00 + * @address www.yitong.com.cn + * @mail hj@yitong.com.cn + * @desc: 屹通客户端组件api + */ +var Fw = {}; +Fw.device = {}; +Fw.device.Device = function () { + var userAgent = navigator.userAgent; + //ios 事件队列 + var eventQueue = []; + return { + //是否iOS设备 + is_ios: userAgent.indexOf('iPhone') > -1 || userAgent.indexOf('iPad') > -1, + //是否Android设备 + is_android: userAgent.indexOf('Android') > -1, + /** + * ios + * 注册事件 + * @param code 事件编码 + * @param options 参数 + */ + addEvent: function (code, options) { + if (options && code) { + eventQueue.push(JSON.stringify({ + code: code, + name: options + })); + } + }, + /** + * ios + * 原生调用,从队列中获取事件 + * @returns {string} + */ + getEvent: function () { + return eventQueue.length > 0 ? eventQueue.shift() : '0'; + } + }; +}(); +/** + * 供第三方调用API + */ +Fw.device.api = function () { + var device = Fw.device.Device; + return { + /** + * @brief app跳转微信小程序 + */ + openWXMiniProgram: function (param) { + if (!device.is_ios && !device.is_android) { + alert("请在ios/android设备上使用!"); + return; + } + device.is_ios && device.addEvent("openWXMiniProgram", JSON.stringify(param)); + device.is_android && GetInfoJs.openWXMiniProgram(JSON.stringify(param)); + }, + } +}(); \ No newline at end of file diff --git a/combining.html b/combining.html index b375249..eb79522 100644 --- a/combining.html +++ b/combining.html @@ -14,6 +14,7 @@ +