UNPKG

eapp

Version:
1 lines 7.43 kB
Ibox("IEappApi.base",function(iboxLoad,exports,ibox){var IEappApi=iboxLoad("IEappApi"),utils=Ibox.utils,url="http://injection/www/cordova.js";utils.addJavaScript(url,function(){utils.showLog("addJavaScript成功--\x3e",url),coreApi.initialize()},function(e){utils.showLog("addJavaScript--cordova.js失败--\x3e",e)}),IEappApi.isAndroid()?utils.showLog("base--android--\x3e"):IEappApi.isIos()&&(utils.showLog("base--ios--\x3e"),document.body.addEventListener("touchstart",function(){}));var coreApi={initialize:function(){document.addEventListener("deviceready",this.onDeviceReady.bind(this),!1)},onDeviceReady:function(){this.receivedEvent("deviceready")},receivedEvent:function(e){utils.showLog("Eappbase--receivedEvent--deviceready--\x3e"),ready=!0;for(var t=IEappApi.eventListeners.EappReady,o=0;o<t.length;o++)t[o]();window.EappReadListener&&window.EappReadListener();var n=IEappApi.eventListeners.EappBack;0<n.length&&document.addEventListener("backbutton",function(){for(var e=0;e<n.length;e++)n[e]()},!1);var i=IEappApi.eventListeners.NetWork,r=IEappApi.eventListeners.EappNetWorkOnline;document.addEventListener("online",function(){for(var e=0;e<r.length;e++)r[e]();for(var t=0;t<i.length;t++)i[t](navigator.connection.type)},!1);var s=IEappApi.eventListeners.EappNetWorkOffLine;document.addEventListener("offline",function(){for(var e=0;e<s.length;e++)s[e]();for(var t=0;t<i.length;t++)i[t](navigator.connection.type)},!1)}};utils.showLog("Eapp core核心库初始化完成----\x3e");var ready=!1;exports.isReady=function(){return ready},exports.getValueByKey=function(keyName){try{return eval(keyName)}catch(e){return utils.showErrorLog("base--getValueByKey--\x3e",e),null}},exports.takePhotoFromCamera=function(e,t,o){var n=Camera.PictureSourceType.CAMERA;exports.takePhoto(n,e,t,o)},exports.takePhotoFromCamera=function(e,t,o){var n=Camera.PictureSourceType.CAMERA;exports.takePhoto(n,e,t,o)},exports.takePhotoFromAlbum=function(e,t,o){var n=Camera.PictureSourceType.SAVEDPHOTOALBUM;exports.takePhoto(n,e,t,o)},exports.takePhoto=function(e,t,o,n){null!=e&&"undefined"!=e||(e=Camera.PictureSourceType.CAMERA),navigator.camera.getPicture(function(e){o(e)},function(e){n(e)},{quality:t,destinationType:Camera.DestinationType.DATA_URL,sourceType:e,encodingType:Camera.EncodingType.JPEG})},exports.takeScan=function(e,t,o){sky.plugin.barcodeScanne(function(e){t&&t(e)},function(e){o&&o(e)})},exports.goThirdUrl=function(e){cordova.InAppBrowser.open(e,"_blank","location=no")},exports.startAPP=function(e,t){(IEappApi.isIos()?startApp.set(e):startApp.set({action:"ACTION_MAIN",type:"text/css",package:e,component:[e,t]})).start(function(){console.warn("启动APP成功")},function(e){console.warn("启动APP失败:"+e)})},exports.goInstallIosPage=function(e){cordova.InAppBrowser.open(e,"_blank","location=no")},exports.getPermissionApi=function(){return cordova.plugins.permissions},exports.checkPermission=function(e,t,o){exports.getPermissionApi().checkPermission(e,t,o)},exports.requestPermissions=function(e,t,o){exports.getPermissionApi().requestPermissions(e,t,o)},exports.requestWriteStorage=function(t,o){var n=exports.getPermissionApi();exports.checkPermission(n.WRITE_EXTERNAL_STORAGE,function(e){e.hasPermission?t&&t():exports.requestPermissions([n.WRITE_EXTERNAL_STORAGE,n.READ_EXTERNAL_STORAGE],function(e){e.hasPermission?t&&t():o&&o("申请写入失败!")},o)},o)},exports.checkAndRequestPermission=function(t,o,n){exports.checkPermission(t,function(e){e.hasPermission?o&&o():exports.requestPermissions([t],function(e){e.hasPermission?o&&o():n&&n("申请写入失败!")},n)},n)},exports.downloadApk=function(e,t){exports.downloadAndInstallApk(e,t,!1)},exports.downloadAndInstallApk=function(o,n,i){var t={status:200,error:""},r="temp.apk";i=i||!0,window.requestFileSystem(LocalFileSystem.PERSISTENT,0,function(e){e.root.getFile(r,{create:!0,exclusive:!1},function(e){var t=cordova.file.externalDataDirectory+r;exports.downloadFile(t,o,function(e){n&&n(e),i&&202==e.status&&(exports.exitApp(),exports.installApk(e.filePath))})},function(e){utils.showLog("文件创建失败!"+e),t.status=400,t.error=e,n&&n(t)})},function(e){utils.showLog("文件系统加载失败!"+e),t.status=400,t.error=e,n&&n(t)})},exports.exitApp=function(){IEappApi.isIos()?sky.plugin.exitApp():navigator.app.exitApp()},exports.goBack=function(){IEappApi.isIos()||navigator.app.backHistory()},exports.clearHistory=function(){IEappApi.isIos()||navigator.app.clearHistory()},exports.clearCache=function(){IEappApi.isIos()||navigator.app.clearCache()},exports.showSplash=function(){navigator.splashscreen.show()},exports.hideSplash=function(){navigator.splashscreen.hide()},exports.titleBarColor=function(e,t){utils.isEmpty(e)||window.StatusBar.backgroundColorByHexString(e),0==(t=t||0)?window.StatusBar.styleLightContent():window.StatusBar.styleDefault()},exports.titleBarTextColor=function(e){0==e?window.StatusBar.styleLightContent():window.StatusBar.styleDefault()},exports.getNetWorkType=function(){return navigator.connection.type},exports.toSettingApn=function(){SkyApn.toSettingApn()},exports.getAppVersionNameAndCode=function(t){var o={version:"",code:0};cordova.getAppVersion.getVersionNumber(function(e){o.version=e,cordova.getAppVersion.getVersionCode(function(e){IEappApi.isAndroid(),o.code=e,t(o)})})},exports.downloadApk=function(e,t,o){exports.downloadFile(e,t,o)},exports.installApk=function(e){cordova.plugins.fileOpener2.open(e,"application/vnd.android.package-archive")},exports.downloadFile=function(e,t,o){var n={status:200,progress:0,filePath:"",error:"",status:200};o(n);var i=new FileTransfer;utils.showLog("filePath---\x3e",e);var r=0;i.onprogress=function(e){if(e.lengthComputable){var t=100*(e.loaded/e.total);.01<(t=t.toFixed(2))-r&&(n.status=201,n.progress=t,o(n)),r=t}},i.download(t,e,function(e){var t=e.toURL();utils.showLog("下载完成--文件位置--\x3e",t),n.status=202,n.filePath=t,o(n)},function(e){utils.showErrorLog("下载失败-error--\x3e",JSON.stringify(e)),n.status=203,n.error=e,o(n)},null,{})},exports.getCurrentPosition=function(t){var o={success:!0,result:"",error:""};baidumap_location.getCurrentPosition(function(e){o.success=!0,o.result=e,t(o)},function(e){o.success=!1,o.error=e,t(o)})},exports.refeshPage=function(){window.location.reload()},exports.StartVoiceRecognizer=function(e,t,o,n){xunfeiListenSpeaking.startListen(e,t,o,n)},exports.StopVoiceRecognizer=function(){xunfeiListenSpeaking.stopListen()},exports.CancelVoiceRecognizer=function(){xunfeiListenSpeaking.cancelListening()},exports.StartSpeack=function(e,t,o){xunfeiListenSpeaking.startSpeak(e,t,o)},exports.PauseSpeack=function(){xunfeiListenSpeaking.pauseSpeaking()},exports.ResumeSpeack=function(){xunfeiListenSpeaking.resumeSpeaking()},exports.StopSpeack=function(){xunfeiListenSpeaking.stopSpeak()},exports.HttpRequest=function(e,t,o,n,i,r){"get"===e?cordova.plugin.http.get(t,o,n,i,r):cordova.plugin.http.post(t,o,n,i,r)},exports.goNewAppPage=function(e,t,o,n){var i;i="right"==t?sky.plugin.TYPE.BY_RIGHT:sky.plugin.TYPE.BY_BOTTOM,sky.plugin.openNewView(i,e,o,n)},exports.exitAppPage=function(e,t){sky.plugin.viewBack(e,t)},exports.openIosApp=function(e,t,o){startApp.set(o).start(e,t)},exports.getIosAppList=function(){return startApp.TYPE},exports.setValueForApp=function(e,t,o){sky.plugin.setValueForApp(o[0],o[1],e,t)},exports.getValueFromApp=function(e,t,o){sky.plugin.getValueFromApp(o[0],e,t)}});