forked from AlanZhang001/H5CallUpNative
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
1 lines (1 loc) · 4.99 KB
/
index.js
1
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Callup=t():e.Callup=t()}("undefined"!=typeof self?self:this,function(){return function(e){var t={};function n(i){if(t[i])return t[i].exports;var r=t[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:i})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){var i=n(1),r=n(2),o={PROTOCAL:"",HOME:"",FAILBACK:{ANDROID:"",IOS:""},APK_INFO:{PKG:"",CATEGORY:"android.intent.category.DEFAULT",ACTION:"android.intent.action.VIEW"},LOAD_WAITING:3e3},a={hiddenStyle:"display:none;width:0px;height:0px;",createIfr:function(e){var t=document.createElement("iframe");return t.className="call_up_iframe",t.src=e,t.style.cssText=this.hiddenStyle,t},createALink:function(e){var t=document.createElement("a");return t.className="call_up_a_link",t.href=e,t.style.cssText=this.hiddenStyle,t},isDocHidden:function(){return document.hidden||document.webkitHidden||document.msHidden},visibilityChangeName:function(){var e;return void 0!==document.hidden?e="visibilitychange":void 0!==document.msHidden?e="msvisibilitychange":void 0!==document.webkitHidden&&(e="webkitvisibilitychange"),e}};function c(e){e&&(this.appConfig=i({},o,e,!0))}i(c.prototype,{generateSchema:function(e){var t="";return t=e||this.appConfig.HOME,t=r.isChrome()&&r.isAndroid()&&!1===r.isUC()&&!1===r.isQQBrowser()?"intent://"+t+"#Intent;scheme="+this.appConfig.PROTOCAL+";package="+this.appConfig.APK_INFO.PKG+";category="+this.appConfig.APK_INFO.CATEGORY+";action="+this.appConfig.APK_INFO.ACTION+";S.browser_fallback_url="+encodeURIComponent(this.appConfig.FAILBACK.ANDROID)+";end":this.appConfig.PROTOCAL+"://"+t},loadSchema:function(e){var t=this.generateSchema(e.targetURI),n=document.body;if(r.isWx()||r.isBaidu()||r.isIOS()&&r.isMobileQQ()||r.isIOS()&&r.isAlipay()||r.isWeibo())r.isAndroid()?window.location.href=this.appConfig.FAILBACK.ANDROID:r.isIOS()&&(window.location.href=this.appConfig.FAILBACK.IOS);else if(r.isChrome()&&r.isAndroid()||r.isUC()||r.isSafari()||r.isQQBrowser()){var i=a.createALink(t);n.appendChild(i),i.click()}else{var o=a.createIfr(t);n.appendChild(o)}this.checkLoadStatus(e.success,e.fail)},checkLoadStatus:function(e,t){var n=(new Date).getTime(),i=this,o=setTimeout(function(){a.isDocHidden()||Date.now()-n>i.appConfig.LOAD_WAITING+200||(t?t():window.location.href=r.isIOS()?i.appConfig.FAILBACK.IOS:i.appConfig.FAILBACK.ANDROID)},this.appConfig.LOAD_WAITING);document.addEventListener(a.visibilityChangeName(),function(){a.isDocHidden&&clearTimeout(o)},!1),window.addEventListener("pagehide",function(){clearTimeout(o),e&&e()},!1)}}),e.exports=c},function(e,t,n){"use strict";var i=Object.prototype.hasOwnProperty,r=Object.prototype.toString,o=Object.defineProperty,a=Object.getOwnPropertyDescriptor,c=function(e){return"function"==typeof Array.isArray?Array.isArray(e):"[object Array]"===r.call(e)},s=function(e){if(!e||"[object Object]"!==r.call(e))return!1;var t,n=i.call(e,"constructor"),o=e.constructor&&e.constructor.prototype&&i.call(e.constructor.prototype,"isPrototypeOf");if(e.constructor&&!n&&!o)return!1;for(t in e);return void 0===t||i.call(e,t)},u=function(e,t){o&&"__proto__"===t.name?o(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},f=function(e,t){if("__proto__"===t){if(!i.call(e,t))return;if(a)return a(e,t).value}return e[t]};e.exports=function e(){var t,n,i,r,o,a,d=arguments[0],p=1,l=arguments.length,h=!1;for("boolean"==typeof d&&(h=d,d=arguments[1]||{},p=2),(null==d||"object"!=typeof d&&"function"!=typeof d)&&(d={});p<l;++p)if(null!=(t=arguments[p]))for(n in t)i=f(d,n),d!==(r=f(t,n))&&(h&&r&&(s(r)||(o=c(r)))?(o?(o=!1,a=i&&c(i)?i:[]):a=i&&s(i)?i:{},u(d,{name:n,newValue:e(h,a,r)})):void 0!==r&&u(d,{name:n,newValue:r}));return d}},function(e,t){var n={isAndroid:function(){return!!navigator.userAgent.match(/Android/i)},isMobileQQ:function(){var e=navigator.userAgent;return/(iPad|iPhone|iPod).*? (IPad)?QQ\/([\d\.]+)/.test(e)||/\bV1_AND_SQI?_([\d\.]+)(.*? QQ\/([\d\.]+))?/.test(e)},isIOS:function(){return!!navigator.userAgent.match(/iPhone|iPad|iPod/i)},isWx:function(){return!!navigator.userAgent.match(/micromessenger/i)},isChrome:function(){return!(!navigator.userAgent.match(/Chrome\/([\d.]+)/)&&!navigator.userAgent.match(/CriOS\/([\d.]+)/))},isBaidu:function(){return!!navigator.userAgent.match(/baidubrowser/i)},isUC:function(){return!!navigator.userAgent.match(/UCBrowser/i)},isSafari:function(){return!!navigator.userAgent.match(/safari/i)},isQQBrowser:function(){return!!navigator.userAgent.match(/MQQBrowser/i)},isWeibo:function(){return!!navigator.userAgent.match(/weibo/i)},isAlipay:function(){return!!navigator.userAgent.match(/Alipay/i)}};e.exports=n}])});