lzapi.min.js 2.56 KB
"use strict";var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},lzapi={default:void 0,call:function(t,i,o){var e="";"function"==typeof i&&(o=i,i={});var n={data:void 0===i?null:i};if("function"==typeof o){var s="dscb"+window.dscb++;window[s]=o,n._dscbstub=s}return n=JSON.stringify(n),window._dsbridge?e=_dsbridge.call(t,n):(window._dswk||-1!==navigator.userAgent.indexOf("_dsbridge"))&&(e=prompt("_dsbridge="+t,n)),JSON.parse(e||"{}").data},register:function(t,i,o){var e=o?window._dsaf:window._dsf;window._dsInit||(window._dsInit=!0,setTimeout(function(){bridge.call("_dsb.dsinit")},0)),"object"===(void 0===i?"undefined":_typeof(i))?e._obs[t]=i:e[t]=i},registerSyn:function(t,i){this.register(t,i,!1)},registerAsyn:function(t,i){this.register(t,i,!0)},closePage:function(){this.call("_dsb.closePage",{})},hasNativeMethod:function(t,i){return this.call("_dsb.hasNativeMethod",{name:t,type:i||"all"})},disableJavascriptDialogBlock:function(t){this.call("_dsb.disableJavascriptDialogBlock",{disable:!1!==t})},getUserInfo:function(){return JSON.parse(this.call("getUserInfo"))},getNfcInfo:function(){return JSON.parse(this.call("getNfcInfo"))},getLocationInfo:function(t){var i=JSON.parse(this.call("getLocationInfo"));t(i.lon,i.lat)},getDeviceInfo:function(){return JSON.parse(this.call("getDeviceInfo"))},stopAudio:function(){this.call("stopAudio")},toast:function(t){this.call("toast",t)},setTitle:function(t){this.call("setTitle",t)},showWaterMark:function(){this.call("showWaterMark",!0)},hideWaterMark:function(){this.call("showWaterMark",!1)}};!function(){if(!window._dsf){var t={_dsf:{_obs:{}},_dsaf:{_obs:{}},dscb:0,lzapi:lzapi,_handleMessageFromNative:function(t){var i=JSON.parse(t.data),o={id:t.callbackId,complete:!0},e=this._dsf[t.method],n=this._dsaf[t.method],s=function(t,e){o.data=t.apply(e,i),bridge.call("_dsb.returnValue",o)},a=function(t,e){i.push(function(t,i){o.data=t,o.complete=!1!==i,bridge.call("_dsb.returnValue",o)}),t.apply(e,i)};if(e)s(e,this._dsf);else if(n)a(n,this._dsaf);else{var r=t.method.split(".");if(r.length<2)return;var f=r.pop(),d=r.join("."),l=this._dsf._obs,c=l[d]||{},u=c[f];if(u&&"function"==typeof u)return void s(u,c);l=this._dsaf._obs,c=l[d]||{},u=c[f],u&&"function"==typeof u&&a(u,c)}}};for(var i in t)window[i]=t[i];lzapi.register("_hasJavascriptMethod",function(t,i){var o=t.split(".");if(o.length<2)return!(!_dsf[o]&&!_dsaf[o]);var e=o.pop(),n=o.join("."),s=_dsf._obs[n]||_dsaf._obs[n];return s&&!!s[e]})}}();