dthpm
Version:
hybirdApp package manager
1 lines • 9.14 kB
JavaScript
!function(e,t){"undefined"!=typeof module&&module.exports?module.exports=t():"function"==typeof define&&(define.amd||define.cmd)?define(t):(e.ant=e.Ali=e.Ali||{},t.call(e,e.Ali))}(this,function(e){"use strict";function t(){return/android/i.test(e.ua)}function o(){return/iphone|ipad/i.test(e.ua)}function n(e){return"function"===l(e)}function a(e){return"string"===l(e)}function i(e){return"object"===l(e)}function r(e){return"number"===l(e)}function l(e){return Object.prototype.toString.call(e).replace(/\[object (\w+)\]/,"$1").toLowerCase()}function s(e,t){if(t)for(var o in t)e[o]=t[o];return e}function c(){if(e.debug>0){var t=+new Date,o=[].slice.call(arguments);console.log(t,o),e.debug>1&&e.diagnose(t+"^"+JSON.stringify(o))}}function u(e,t){return e=e||{},e.errorCode=e.error||0,e.errorCode>0&&e.errorCode<10?console.error(t+" error: errorCode: "+e.errorCode+", errorMessage: "+e.errorMessage):c(t+", callback:",e),e}function d(t){var o=e.alipayVersion.split(".");t=t.split(".");for(var n,a,i=0;i<o.length;i++){if(n=parseInt(t[i],10)||0,a=parseInt(o[i],10)||0,n>a)return-1;if(a>n)return 1}return 0}return e=e||{},e.ua=navigator.userAgent,e.version="1.1.0",e.isAlipay=function(){return e.ua.indexOf("AlipayClient")>-1||e.ua.indexOf("AliApp(AP")>-1}(),e.isAlipay||console.warn("Run antBridge.js in AlipayClient please!"),e.alipayVersion=function(){if(e.isAlipay){var t=e.ua.match(/AlipayClient\/(.*)/);return t&&t.length?t[1]:""}}(),e.appinfo={engine:"alipay",engineVer:e.alipayVersion,name:"alipay",ver:e.alipayVersion},e.on=function(e,t){e.split(/\s+/g).forEach(function(e){document.addEventListener(e,t,!1)})},e.call=function(){var t=[].slice.call(arguments);if(window.AlipayJSBridge&&window.AlipayJSBridge.call){var o=t[0],r=t[1]||{},l=t[2];if(!a(o))return void console.error("apiName error:",o);if(void 0===l&&n(r)&&(l=r,r={}),!i(r))return void console.error(o+": options is not object");var s=l;l=function(e){e=u(e,o),s&&s(e)},"remoteLog"!==o&&c("AlipayJSBridge.call:",o,r,s),window.AlipayJSBridge.call(o,r,l)}else e._apiQueue=e._apiQueue||[],e._apiQueue.push(t)},e._ready=function(t){window.AlipayJSBridge&&window.AlipayJSBridge.call?t&&t():e.on("AlipayJSBridgeReady",t)},e.ready=e.ready||e._ready,e.toast=function(o,n){(a(o)||r(o))&&(o={text:o+""}),o=o||{},o.content=o.text,o.duration=o.duration||2e3,n&&r(o.duration)&&t()?(o.duration=o.duration<2500?2e3:3e3,e.call("toast",o),setTimeout(n,o.duration)):e.call("toast",o,n)},e.setTitle=function(t,o){var n={type:"title"};return a(t)&&(t={title:t}),t.title=t.title||t.text,s(n,t),null===n.title?(console.error("setTitle: title is required!"),!1):void e.call("setTitle",n,o)},e.showTitle=function(t){e.call("showTitlebar",t)},e.hideTitle=function(t){e.call("hideTitlebar",t)},e.showLoading=function(t,n){if((a(t)||r(t))&&(t={text:t+""}),t=t||{},t.delay=t.delay||1e3,r(t.delay)&&o()){var i=t.delay;delete t.delay;var l=setTimeout(function(){e.call("showLoading",t,n)},i);return e._stLoadingQueue=e._stLoadingQueue||[],e._stLoadingQueue.push(l),l}e.call("showLoading",t,n)},e.hideLoading=function(t){if("array"===l(e._stLoadingQueue)&&e._stLoadingQueue.length)for(c("clearLoadingCount: "+e._stLoadingQueue.length);e._stLoadingQueue.length;)clearTimeout(e._stLoadingQueue.shift());e.call("hideLoading",t)},e.pushWindow=function(o,n){return a(o)&&(o={url:o}),o=o||{},o.url?(o.param&&t()&&d("8.3")<0&&console.warn('Ali.pushWindow: can not use "param" in android\'s client 8.3-'),void e.call("pushWindow",o,n)):(console.error("Ali.pushWindow: url is required!"),!1)},e.popWindow=function(t,o){e.call("popWindow",t,o)},e.popTo=function(t,o){r(t)?t={step:t}:a(t)&&(t={urlPattern:t}),void 0!==t.step&&(t.index=t.step),e.call("popTo",t,o)},e.login=function(t){e.call("login",t)},e.tradePay=function(t,o){e.call("tradePay",t,o)},e.h5TradePay=function(e,t){console.error("alpayClient don't support Ali.h5TradePay,please use Ali.tradePay"),t&&t({errorCode:1,errorMessage:"接口不存在"})},e.geolocation={},e.geolocation.getCurrentPosition=function(t,o){void 0===o&&n(t)&&(o=t,t=null),t=t||{timeout:15e3};var a=setTimeout(function(){a=null,console.error("geolocation.getCurrentPosition: timeout");var e={errorCode:5,errorMessage:"调用超时"};o&&o(e)},t.timeout);e.call("getLocation",function(e){a&&(clearTimeout(a),e.coords={},e.coords.latitude=+e.latitude,e.coords.longitude=+e.longitude,e.city=e.city?e.city:e.province,e.cityCode=e.citycode,e.address=e.pois,o&&o(e))})},e.shake={},e.shake.watch=function(t,o){e.call("watchShake",t,o)},e.vibration={},e.vibration.vibrate=function(t,o){r(t)&&(t={duration:t}),e.call("vibrate",t,o)},e.network={},e.network.getType=function(t,o){void 0===o&&n(t)&&(o=t,t=null),t=t||{timeout:15e3};var a=setTimeout(function(){a=null,console.error("network.getType: timeout");var e={errorCode:5,errorMessage:"调用超时"};o&&o(e)},t.timeout);e.call("getNetworkType",function(e){a&&(clearTimeout(a),e.networkAvailable="fail"!==e.networkType,e.is3G=e.is2G=e.isE=e.isG=e.isH=!1,e.isWifi="wifi"===e.networkType,e.isOnline=e.networkAvailable,e.type=e.networkType,o&&o(e,e.networkAvailable))})},e.calendar={},e.calendar.add=function(t,o){d("8.3")<0?(console.error("Ali.calendar.add: 在 8.3 及以上版本使用"),o&&o({errorCode:1,errorMessage:"接口不存在"})):e.call("addEventCal",t,o)},e.photo=function(t,o){void 0===o&&n(t)&&(o=t,t={});var a={format:"jpg",dataType:"dataurl",quality:50,allowEdit:!1,src:void 0,cameraType:void 0,maskImg:void 0,maskWidth:void 0,maskHeight:void 0};s(a,t),a.imageFormat=a.format,"remoteurl"==a.dataType&&(a.dataType="dataurl"),a.dataType=a.dataType.slice(0,-3)+a.dataType.slice(-3).toUpperCase(),e.call("photo",a,function(e){e.dataURL&&(e.dataURL="data:image/"+a.imageFormat+";base64,"+e.dataURL),e.photo=e.dataURL||e.fileURL,e.errorMessage=10==e.error?"用户取消":e.errorMessage,o&&o(e)})},e.contacts={},e.contacts.get=function(t,o){void 0===o&&n(t)&&(o=t,t=null),t=t||{},t.multiple&&console.error("仅支持单选"),e.call("contact",t,function(e){switch(e.results=[],e.results[0]={phoneNumber:e.mobile,email:void 0,name:e.name},e.errorCode){case 10:e.errorMessage="没有权限";break;case 11:e.errorMessage="用户取消操作"}o&&o(e)})},e.share=function(o,n){var a={1:"Weixin",2:"Weibo",4:"SMS",8:"LaiwangContacts",16:"LaiwangTimeline",32:"WeixinTimeLine",64:"CopyLink"};o=o||{};var i=o;if(o.channels&&0!==o.channels.length)t()&&o.channels.forEach(function(e){"qzone"===e.name.toLowerCase()&&(e.name="QQZone")});else{o.title=o.title||"",o.content=o.text,o.imageUrl=o.image,o.captureScreen=!!o.captureScreen,o.url=o.url||"",i={channels:[]},"undefined"==typeof o.shareType&&(o.shareType=-1);for(var r in a)Number(r)&o.shareType&&i.channels.push({name:a[r],param:o})}e.call("share",i,n)},e.debugEnabled=function(t){e.debug=t===!0?2:1},e.getLaunchParams=function(t){e._ready(function(){e.launchParams=AlipayJSBridge.startupParams,t&&t(e.launchParams)})},e.setOptionMenu=function(t,o){a(t)&&(t=/^http/i.test(t)?{icon:t}:{title:t}),e.call("setOptionMenu",t,o)},e.alert=function(t,o){(a(t)||r(t))&&(t={message:t+""}),e.call("alert",t,o)},e.confirm=function(t,o){(a(t)||r(t))&&(t={message:t+""}),e.call("confirm",t,o)},e.openInBrowser=function(t,o){a(t)&&(t={url:t}),e.call("openInBrowser",t,o)},e.diagnose=function(t){if(!o())return console.warn("diagnose only in iOS"),!1;if(i(t)||"array"===l(t))t=JSON.stringify(t);else if(!a(t)&&!r(t))return console.error("diagnose must be string or json"),!1;t=location.href+": "+t,t={type:"diagnose",seedId:"H5_DIAGNOSED_JSLOG",param1:t};var n=["remoteLog",t];window.AlipayJSBridge&&window.AlipayJSBridge.call?window.AlipayJSBridge.call("remoteLog",t):(e._apiQueue=e._apiQueue||[],e._apiQueue.push(n))},e.requestAnimationFrame=function(e){var t=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame;return t?t(e):void console.error("Not support requestAnimationFrame!")},e._ready(function(){function t(){e.requestAnimationFrame(function(){var n=o.shift();e.call.apply(null,n),o.length&&t()})}c("AlipayJSBridgeReady");var o=e._apiQueue||[];!!o.length&&t()}),["startApp","showOptionMenu","hideOptionMenu","showToolbar","hideToolbar","closeWebview","sendSMS","scan","getSessionData","setSessionData","checkJSAPI","checkApp","isInstalledApp","deposit","chooseContact","alipayContact","getConfig","getCities","rsa","getWifiList","connectWifi","notifyWifiShared","thirdPartyAuth","getThirdPartyAuthcode","setToolbarMenu","exitApp","actionSheet","hideBackButton","startApp","startPackage","getSharedData","setSharedData","removeSharedData","setClipboard","startDownload","stopDownload","getDownloadInfo","detectBeacons","startBeaconsBeep","stopBeaconsBeep","startIndoorLocation","stopIndoorLocation","addEventCal","startSpeech","stopSpeech","getWifiInfo","clearAllCookie","getMtopToken","getClientInfo","sinasso","getClipboard","checkBLEAvalability","scanBeacons","isSpeechAvailable","speechRecognizer","contactSync","setGestureBack","remoteLog","httpRequest","rpc","ping","snapshot","imageViewer","upload","networkAnalysis"].forEach(function(t){e[t]=function(){var o=[].slice.call(arguments);e.call.apply(null,[t].concat(o))}}),e});