dsp_sdk.js 10.4 KB
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):n.Ald=e()}(this,function(){function n(n,e){var t=(65535&n)+(65535&e);return(n>>16)+(e>>16)+(t>>16)<<16|65535&t}function e(n,e){return n<<e|n>>>32-e}function t(t,o,r,a,i,s){return n(e(n(n(o,t),n(a,s)),i),r)}function o(n,e,o,r,a,i,s){return t(e&o|~e&r,n,e,a,i,s)}function r(n,e,o,r,a,i,s){return t(e&r|o&~r,n,e,a,i,s)}function a(n,e,o,r,a,i,s){return t(e^o^r,n,e,a,i,s)}function i(n,e,o,r,a,i,s){return t(o^(e|~r),n,e,a,i,s)}function s(e){for(var t=1732584193,s=-271733879,u=-1732584194,c=271733878,f=0;f<e.length;f+=16){var p=t,d=s,h=u,l=c;t=o(t,s,u,c,e[f+0],7,-680876936),c=o(c,t,s,u,e[f+1],12,-389564586),u=o(u,c,t,s,e[f+2],17,606105819),s=o(s,u,c,t,e[f+3],22,-1044525330),t=o(t,s,u,c,e[f+4],7,-176418897),c=o(c,t,s,u,e[f+5],12,1200080426),u=o(u,c,t,s,e[f+6],17,-1473231341),s=o(s,u,c,t,e[f+7],22,-45705983),t=o(t,s,u,c,e[f+8],7,1770035416),c=o(c,t,s,u,e[f+9],12,-1958414417),u=o(u,c,t,s,e[f+10],17,-42063),s=o(s,u,c,t,e[f+11],22,-1990404162),t=o(t,s,u,c,e[f+12],7,1804603682),c=o(c,t,s,u,e[f+13],12,-40341101),u=o(u,c,t,s,e[f+14],17,-1502002290),s=o(s,u,c,t,e[f+15],22,1236535329),t=r(t,s,u,c,e[f+1],5,-165796510),c=r(c,t,s,u,e[f+6],9,-1069501632),u=r(u,c,t,s,e[f+11],14,643717713),s=r(s,u,c,t,e[f+0],20,-373897302),t=r(t,s,u,c,e[f+5],5,-701558691),c=r(c,t,s,u,e[f+10],9,38016083),u=r(u,c,t,s,e[f+15],14,-660478335),s=r(s,u,c,t,e[f+4],20,-405537848),t=r(t,s,u,c,e[f+9],5,568446438),c=r(c,t,s,u,e[f+14],9,-1019803690),u=r(u,c,t,s,e[f+3],14,-187363961),s=r(s,u,c,t,e[f+8],20,1163531501),t=r(t,s,u,c,e[f+13],5,-1444681467),c=r(c,t,s,u,e[f+2],9,-51403784),u=r(u,c,t,s,e[f+7],14,1735328473),s=r(s,u,c,t,e[f+12],20,-1926607734),t=a(t,s,u,c,e[f+5],4,-378558),c=a(c,t,s,u,e[f+8],11,-2022574463),u=a(u,c,t,s,e[f+11],16,1839030562),s=a(s,u,c,t,e[f+14],23,-35309556),t=a(t,s,u,c,e[f+1],4,-1530992060),c=a(c,t,s,u,e[f+4],11,1272893353),u=a(u,c,t,s,e[f+7],16,-155497632),s=a(s,u,c,t,e[f+10],23,-1094730640),t=a(t,s,u,c,e[f+13],4,681279174),c=a(c,t,s,u,e[f+0],11,-358537222),u=a(u,c,t,s,e[f+3],16,-722521979),s=a(s,u,c,t,e[f+6],23,76029189),t=a(t,s,u,c,e[f+9],4,-640364487),c=a(c,t,s,u,e[f+12],11,-421815835),u=a(u,c,t,s,e[f+15],16,530742520),s=a(s,u,c,t,e[f+2],23,-995338651),t=i(t,s,u,c,e[f+0],6,-198630844),c=i(c,t,s,u,e[f+7],10,1126891415),u=i(u,c,t,s,e[f+14],15,-1416354905),s=i(s,u,c,t,e[f+5],21,-57434055),t=i(t,s,u,c,e[f+12],6,1700485571),c=i(c,t,s,u,e[f+3],10,-1894986606),u=i(u,c,t,s,e[f+10],15,-1051523),s=i(s,u,c,t,e[f+1],21,-2054922799),t=i(t,s,u,c,e[f+8],6,1873313359),c=i(c,t,s,u,e[f+15],10,-30611744),u=i(u,c,t,s,e[f+6],15,-1560198380),s=i(s,u,c,t,e[f+13],21,1309151649),t=i(t,s,u,c,e[f+4],6,-145523070),c=i(c,t,s,u,e[f+11],10,-1120210379),u=i(u,c,t,s,e[f+2],15,718787259),s=i(s,u,c,t,e[f+9],21,-343485551),t=n(t,p),s=n(s,d),u=n(u,h),c=n(c,l)}return[t,s,u,c]}function u(n){for(var e="0123456789abcdef",t="",o=0;o<4*n.length;o++)t+=e.charAt(15&n[o>>2]>>o%4*8+4)+e.charAt(15&n[o>>2]>>o%4*8);return t}function c(n){for(var e=1+(n.length+8>>6),t=Array(16*e),o=0;o<16*e;o++)t[o]=0;for(var o=0;o<n.length;o++)t[o>>2]|=(255&n.charCodeAt(o))<<o%4*8;return t[o>>2]|=128<<o%4*8,t[16*e-2]=8*n.length,t}function f(n){return u(s(c(n)))}function p(){return""+Date.now()+Math.floor(1e7*Math.random())}function d(n){if(!(wn>=5)){wn++;var e=Date.now()+k()+z.app_key.replace(/(^\s*)|(\s*$)/g,"");wx.request({url:N+"/authorize/mini_program_openid",data:{jc:n,ai:ln,reqid:f(e)},method:"post",success:function(e){if(200!=e.data.code)return void setTimeout(function(){d(n)},500);wx.setStorageSync("xm_m_openid",e.data.data.openid),h()},fail:function(e){setTimeout(function(){d(n)},500)}})}}function h(){for(var n=0;n<gn.length;n++)I(),gn[n]()}function l(n){rn=!0;var e=y(n.path),t={};for(var o in X.query)"ald_share_src"===o&&(t[o]=X.query[o]);var r="";if(r=n.path.indexOf("?")==-1?n.path+"?":n.path.substr(0,n.path.indexOf("?"))+"?",""!==e)for(var o in e)t[o]=e[o];t.ald_share_src?t.ald_share_src.indexOf(tn)==-1&&t.ald_share_src.length<200&&(t.ald_share_src=t.ald_share_src+","+tn):t.ald_share_src=tn;for(var a in t)a.indexOf("ald")==-1&&(r+=a+"="+t[a]+"&");return n.path=r+"ald_share_src="+t.ald_share_src,n}function w(n){cn++,n.at=F,n.et=Date.now(),n.uu=k(),n.v=K,n.ak=z.app_key.replace(/(^\s*)|(\s*$)/g,""),n.wsr=X,n.ifo=on,n.rq_c=cn,n.ls=B;let e=Date.now()+n.ak+n.uu;n.reqid=f(e),n.op=J,n.user_info=n.user_info?n.user_info:dn?dn.userInfo:"",wx.request({url:N+"/api/v3/app",data:n,header:{AldStat:"xmad",se:Q||"",op:J||"",img:un},method:"POST",success:function(n){n.statusCode},fail:function(){}})}function g(n){function e(){w(n),A()}I(),J?e():gn.push(e)}function _(){var n={};for(var e in pn)n[e]=pn[e];return n}function v(n){var e={};for(var t in n)"rawData"!=t&&"errMsg"!=t&&(e[t]=n[t]);return e}function y(n){if(n.indexOf("?")==-1)return"";var e={};return n.split("?")[1].split("&").forEach(function(n){var t=n.split("=")[1];e[n.split("=")[0]]=t}),e}function S(n){for(var e="",t=0;t<n.length;t++)n[t].length>e.length&&(e=n[t]);return e}function x(n,e,t){t.ev=n,t.life=e,t.ec=hn,t.st=Date.now(),t.dr=Date.now()-V,nn&&(t.qr=nn,t.sr=nn),Z&&(t.usr=Z),g(t)}function m(n){hn++}function q(){function n(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return n()+n()+n()+n()+n()+n()+n()+n()}function k(){var n="";try{n=wx.getStorageSync("ald_dsp_uuid")}catch(e){n="uuid_getstoragesync_error"}if(!n){n=q();try{wx.setStorageSync("ald_dsp_uuid",n)}catch(n){wx.setStorageSync("ald_dsp_uuid","uuid_getstoragesync_error")}}return n}function I(){var n="";try{J=n=wx.getStorageSync("xm_m_openid")}catch(e){J=n=wx.getStorageSync("xm_m_openid")}if(""===n)try{n&&wx.setStorageSync("xm_m_openid",n)}catch(e){n&&wx.setStorageSync("xm_m_openid",n)}return n}function A(){console.warn("heartbeat",J),_n=""==J?"0":"1",wx.request({url:`${N}/api/v3/health?appkey=${z.app_key}&op=${_n}`,method:"GET",success:function(){}})}function D(n){z.getOpenid&&!I()&&wx.login({success:function(n){d(n.code)}}),pn.pk=n.query.pakey?n.query.pakey:n.query.scene,pn.sa=n.referrerInfo?n.referrerInfo.appId:n.query.appid?n.query.appid:"",R="pa"===n.query.bside;var e,t=_();e=n.scene!=Y,Y=n.scene,cn=0,X=n,Z=n.query.ald_share_src,nn=n.query.aldsrc||"",en=n.query.ald_share_src,V=Date.now(),fn||(on=!1),fn=!1,rn||(0!==W&&Date.now()-W>3e4?F=p():e&&(F=p())),0!==W&&Date.now()-W<3e4&&(an=!0),n.query.ald_share_src&&"1044"==n.scene&&n.shareTicket?wx.getShareInfo({shareTicket:n.shareTicket,success:function(n){sn=n}}):n.query.ald_share_src,""===dn?wx.getSetting({withCredentials:!0,success:function(n){n.authSetting["scope.userInfo"]?wx.getUserInfo({withCredentials:!0,success:function(n){on=!1,dn=n,t.user_info=v(n).userInfo,un=S(n.userInfo.avatarUrl.split("/")),x("app","show",t)}}):(on=!0,x("app","show",t))},fail(){}}):(on=!1,t.user_info=v(dn).userInfo,un=S(dn.userInfo.avatarUrl.split("/")),x("app","show",t))}function M(n){R="pa"===n.query.bside,B=p(),X=n}function b(){A();var n=_();W=Date.now(),""===dn?wx.getSetting({success:function(e){e.authSetting["scope.userInfo"]?wx.getUserInfo({withCredentials:!0,success:function(e){dn=e,un=S(e.userInfo.avatarUrl.split("/")),n.user_info=v(e).userInfo,x("app","hide",n)}}):x("app","hide",n)}}):(un=S(dn.userInfo.avatarUrl.split("/")),n.user_info=v(dn).userInfo,x("app","hide",n))}function H(n){Sn=n}function O(){vn=G?this.$mp.page.route:this.route,an=!1}function U(){yn=vn}function L(){yn=vn}function T(n){var e={};for(var t in n)"onLaunch"!==t&&"onShow"!==t&&"onHide"!==t&&"onError"!==t&&(e[t]=n[t]);return e.onLaunch=function(e){M.call(this,e),"function"==typeof n.onLaunch&&n.onLaunch.call(this,e)},e.onShow=function(e){D.call(this,e),n.onShow&&"function"==typeof n.onShow&&n.onShow.call(this,e)},e.onHide=function(){b.call(this),n.onHide&&"function"==typeof n.onHide&&n.onHide.call(this)},e.onError=function(e){m.call(this,e),n.onError&&"function"==typeof n.onError&&n.onError.call(this,e)},e}function E(n){var e={};for(var t in n)"onLoad"!==t&&"onShow"!==t&&"onHide"!==t&&"onUnload"!==t&&"onShareAppMessage"!==t&&(e[t]=n[t]);return e.onLoad=function(e){H.call(this,e),"function"==typeof n.onLoad&&n.onLoad.call(this,e)},e.onShow=function(e){O.call(this),"function"==typeof n.onShow&&n.onShow.call(this,e)},e.onHide=function(e){U.call(this),"function"==typeof n.onHide&&n.onHide.call(this,e)},e.onUnload=function(e){L.call(this),"function"==typeof n.onUnload&&n.onUnload.call(this,e)},n.onShareAppMessage&&"function"==typeof n.onShareAppMessage&&(e.onShareAppMessage=function(e){var t=n.onShareAppMessage.call(this,e);return void 0===t?(t={},t.path=this.route):void 0===t.path&&(t.path=this.route),l.call(this,t)}),e}function j(n){return App(T(n))}function C(n){return Page(E(n))}function P(n){return G=!0,T(n)}function $(n){return E(n)}const z=require("./dsp_sdk_config");var G=!1,K="1.0.4";const N="https://log.xmadx.net";z.app_key&&32===z.app_key.length||console.warn("小盟提示:配置错误,请在dsp_sdk.js中正确配置您的app_key。");var R=!1,V=0,W=0,B="",F="",J=(Date.now(),""),Q="",X="",Y="",Z="",nn="",en="",tn=k(),on="",rn=!1,an=!1,sn="",un="",cn=0,fn=!0,pn={},dn="",hn=0,ln=__wxConfig.accountInfo.appId,wn=0,gn=[],_n="",vn="",yn="",Sn="";try{var xn=wx.getSystemInfoSync();pn.br=xn.brand,pn.pm=xn.model,pn.pr=xn.pixelRatio,pn.ww=xn.windowWidth,pn.wh=xn.windowHeight,pn.lang=xn.language,pn.wv=xn.version,pn.wvv=xn.platform,pn.wsdk=xn.SDKVersion,pn.sv=xn.system}catch(n){}wx.getNetworkType({success(n){pn.nt=n.networkType}}),wx.dsp?"Object"===Object.prototype.toString.call(wx.dsp).slice(8,-1)&&0===Object.keys(wx.dsp).length&&"ald_dsp"===wx.dsp.name||console.error("wx.dsp已被占用,请联系小盟广告技术人员"):(wx.dsp={},wx.dsp.name="ald_dsp"),wx.dsp.setOpenid=function(n){if(!z.getOpenid){if("string"!=typeof n)return void console.error("openid格式错误");if(28!==n.length)return void console.error("openid位数错误");try{wx.setStorageSync("xm_m_openid",n)}catch(e){wx.setStorageSync("xm_m_openid",n)}h(),J=n;var e=_();e.st=Date.now(),e.tp="openid",e.ev="event",e.ct="openid"}},A();var mn=function(n,e,t){var o=n[e];n[e]=function(n){o&&o.call(this,n),t.call(this,n)}};return z.plugin?{App:j,Page:C,MpvueApp:P,MpvuePage:$}:function(){!function(){var n=App,e=Page;App=function(e){mn(e,"onLaunch",M),mn(e,"onShow",D),mn(e,"onHide",b),mn(e,"onError",m),n(e)},Page=function(n){var t=n.onShareAppMessage;mn(n,"onLoad",H),mn(n,"onUnload",L),mn(n,"onShow",O),mn(n,"onHide",U),void 0!==t&&null!==t&&(n.onShareAppMessage=function(n){if(void 0!==t){var e=t.call(this,n);return void 0===e?(e={},e.path=this.route):void 0===e.path&&(e.path=this.route),l(e)}}),e(n)}}()}()});