2 lines
9.1 KiB
Java
2 lines
9.1 KiB
Java
|
var mtjwxsdk=function(e){"use strict";var o,t,g={logServerUrl:"https://hmma.baidu.com/mini.gif",maxRequestRetryCount:5,requestRetryFirstDelay:1e3,requestRetryMultiple:4,maxRequestDataLength:204800,maxUserPropertyCount:100,maxUserPropertyKeyValueLength:256,maxUint8:255,maxUint32:4294967295,enabledEvents:{app:["onShow","onHide","onError"],page:["onShow","onHide"]},storageKeys:{uuid:"mtj_uuid",userInfo:"mtj_user",userProperty:"mtj_user_property",shareCount:"mtj_scnt"}},p={type:1},h={aso:{}},r=function(){return"undefined"!=typeof crypto&&crypto.getRandomValues?crypto.getRandomValues(new Uint32Array(1))[0]:Math.floor(Math.random()*g.maxUint32)},a=function(e,t){return"[object "+t+"]"==={}.toString.call(e)},n=function n(r){return(a(r,"Object")||a(r,"Array"))&&Object.keys(r).forEach(function(e){var t=r[e];a(t,"Object")||a(t,"Array")?r[e]=n(t):r[e]=""+t}),r},u=function(e){return a(e,"String")&&/^\d{11}$/.test(e)},i=function(e){return a(e,"String")&&28===e.length},s=0,c=function(r){return new Promise(function(t,n){if(r.data=r.data||{},r.data.v="1.8.14",r.data.rqc=++s,e=r.data,!(JSON.stringify(e).length<=g.maxRequestDataLength))return s--,n(new Error("invalid data"));var e;r.success=function(e){return t(e)},r.fail=function(e){return n(e)},function t(n){var r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:g.requestRetryFirstDelay;return o.request({url:n.url,data:n.data,header:Object.assign({"content-type":"application/json"},n.header),method:n.method||"POST",dataType:n.dataType||"json",success:function(e){delete n.data.rtc,n.success&&n.success(e)},fail:function(e){n.data.rtc=(n.data.rtc||0)+1,n.data.rtc<=g.maxRequestRetryCount?setTimeout(function(){return t(n,r*g.requestRetryMultiple)},r):(delete n.data.rtc,n.fail&&n.fail(e))}})}(r)})},f=function(e,t){var n=a(t,"Object")?JSON.stringify(t):""+t;c({url:g.logServerUrl,dataType:"string",data:Object.assign({},p,{et:"error",en:e,ep:{ex:n},rid:r()})})},d=function(e){e.rid=r(),e.aso=e.aso||{};var t={url:g.logServerUrl,dataType:"string",data:Object.assign({},p,e)};c(t).catch(function(e){return f("sendRequest",e)})},y=function(e){try{return o.getStorageSync(e)}catch(e){f("getStorageSync",e)}},m=function(e,t){try{o.setStorageSync(e,t)}catch(e){f("setStorageSync",e)}},l=function(){return Promise.resolve().then(function(){var e=y(g.storageKeys.uuid);return a(e,"String")&&32===e.length||(e=([1e7]+1e3+4e3+8e3+1e11).replace(/[018]/g,function(e){return(e^("undefined"!=typeof crypto&&crypto.getRandomValues?crypto.getRandomValues(new Uint8Array(1))[0]:Math.floor(Math.random()*g.maxUint8))&15>>e/4).toString(16)}),m(g.storageKeys.uuid,e)),e})},v=function(){return t||(p.sid=r(),p.rqc=0,t=Promise.all([l(),new Promise(function(t){o.getSystemInfo({success:function(e){delete e.errMsg,t(e)},fail:function(){t({})}})}),new Promise(function(t){o.getNetworkType({success:function(e){delete e.errMsg,t(e)},fail:function(){t({})}})}),Promise.resolve().then(function(){var e=y(g.storageKeys.userInfo),n=a(e,"Object")?e:{};return new Promise(function(t){o.getSetting({success:function(e){e.authSetting&&e.authSetting["scope.userInfo"]?o.getUserInfo({success:function(e){delete e.userInfo.errMsg,t(Object.assign(n,e.userInfo))},fail:function(){t(n)}}):t(n)},fail:function(){t(n)}})})}),new Promise(function(t){if(!g.getLocation)return t({});o.getLocation({type:"wgs84",success:function(e){delete e.errMsg,t(e)},fail:function(){t({})}})}),Promise.resolve().then(function(){var e=y(g.storageKeys.userProperty);return a(e,"Object")?e:{}})]).then(function(e){p.uuid=e[0],h.system=n(e[1]),h.network=n(e[2]),0<Object.keys(e[3]).length&&(h.user=n(e[3])),0<Object.keys(e[4]).length&&(h.location=n(e[4])),0<Object.keys(e[5]).length&&(h.userProperty=JSON.stringify(e[5])),h.system.platform}))},j={onLaunch:function(){d({et:"app",en:"launch"})},onShow:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};return h.aso.scene=""+(t.scene||""),t.referrerInfo&&t.referrerInfo.appId?h.aso.referrerInfo=t.referrerInfo:delete h.aso.referrerInfo,h.aso.path=t.path||"",h.aso.query=Object.keys(t.query||{}).map(function(e){return{key
|