1 |
- !function(n,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):n.Ald=t()}(this,function(){function n(){this.concurrency=4,this.queue=[],this.tasks=[],this.activeCount=0;var n=this;this.push=function(t){this.tasks.push(new Promise(function(e,o){var a=function(){n.activeCount++,t().then(function(n){e(n)}).then(function(){n.next()})};n.activeCount<n.concurrency?a():n.queue.push(a)}))},this.all=function(){return Promise.all(this.tasks)},this.next=function(){n.activeCount--,n.queue.length>0&&n.queue.shift()()}}function t(){this.request=[],this.updata=!1,this.push=function(n){if(this.request.length>=8&&!this.updata&&(this.updata=!0,e()),this.request.length>=10){let t=this.request.shift();t().then(function(n){}).catch(n=>{}),this.request.push(n)}else this.request.push(n)},this.concat=function(){this.request.map(function(n){wx.Queue.push(n)}),this.request=[]}}function e(){"function"==typeof _n&&""===K&&_n().then(function(n){28===n.length&&(K=n,wx.setStorageSync("aldstat_op",n))})}function o(n){this.app=n}function a(n){B=m(),V=n,ln=n.scene,this.aldstat=new o(this)}function r(n){e();var t;if(t=n.scene!=ln,ln=n.scene,z=0,V=n,F=n.query.ald_share_src,X=n.query.aldsrc||"",Y=n.query.ald_share_src,hn||fn||vn||(W=!1),hn=!1,(0!==Q&&Date.now()-Q>3e4||t)&&(fn||(T=m(),N=Date.now(),wn=0)),0!==Q&&Date.now()-Q<3e4&&(an=!0),n.query.ald_share_src&&"1044"==n.scene&&n.shareTicket?wx.getShareInfo({shareTicket:n.shareTicket,success:function(n){nn=n,A("event","ald_share_click",JSON.stringify(n))}}):n.query.ald_share_src&&A("event","ald_share_click",1),""===tn&&wx.getSetting({withCredentials:!0,success:function(n){if(n.authSetting["scope.userInfo"]){wx.getUserInfo({withCredentials:!0,success:function(n){var t=v();tn=n,t.ufo=y(n),G=_(n.userInfo.avatarUrl.split("/")),g(t)}})}}}),D("app","show"),""===K){let n=wx.getAccountInfoSync().miniProgram.appId;wx.login({success(t){wx.request({url:"https://log.aldwx.com/authorize/mini_program_openid",data:{ai:n,uuid:$,jc:t.code,reqid:"1"},success(n){n.data.code||(K=n.data.data.openid,wx.setStorageSync("aldstat_op",n.data.data.openid))}})},fail(n){}})}}function i(){e(),Q=Date.now(),""===tn&&wx.getSetting({success:function(n){n.authSetting["scope.userInfo"]&&wx.getUserInfo({withCredentials:!0,success:function(n){tn=n,G=_(n.userInfo.avatarUrl.split("/"));var t=v();t.ufo=y(n),g(t)}})}}),D("app","hide")}function s(n){Z++,A("event","ald_error_message",n)}function c(n){cn=n}function u(){pn=Date.now(),rn=j?this.$mp.page.route:this.route,q("page","show"),an=!1}function h(){sn=rn,wn=Date.now()-pn}function f(){sn=rn,wn=Date.now()-pn}function l(){A("event","ald_pulldownrefresh",1)}function d(){A("event","ald_reachbottom",1)}function p(n){fn=!0;var t=S(n.path),e={};for(var o in V.query)"ald_share_src"!==o&&"ald_share_op"!==o||(e[o]=V.query[o]);var a="";if(a=n.path.indexOf("?")==-1?n.path+"?":n.path.substr(0,n.path.indexOf("?"))+"?",""!==t)for(var o in t)e[o]=t[o];e.ald_share_src?e.ald_share_src.indexOf($)==-1&&e.ald_share_src.length<200&&(e.ald_share_src=e.ald_share_src+","+$):e.ald_share_src=$,C.useOpen&&(e.ald_share_op?e.ald_share_op.indexOf(K)==-1&&e.ald_share_op.length<200&&(e.ald_share_op=e.ald_share_op+","+K):e.ald_share_op=K);for(var r in e)r.indexOf("ald")==-1&&(a+=r+"="+e[r]+"&");return n.path=a+(C.useOpen?"ald_share_op="+e.ald_share_op+"&":"")+"ald_share_src="+e.ald_share_src,A("event","ald_share_status",n),n}function w(){function n(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return n()+n()+n()+n()+n()+n()+n()+n()}function g(n){function t(){return new Promise(function(t,e){var o={AldStat:"MiniApp-Stat",se:J||"",op:K||"",img:G};""===E||(o.ai=E),wx.request({url:"https://"+b+".aldwx.com/d.html",data:n,header:o,method:"GET",success:function(n){t(200==n.statusCode?"":"status error")},fail:function(){t("fail")}})})}z++,n.at=T,n.uu=$,n.v=H,n.ak=C.app_key.replace(/(\t)|(\s)/g,""),n.wsr=V,n.ifo=W,n.rq_c=z,n.ls=B,n.te=U,n.et=Date.now(),n.st=Date.now(),C.useOpen?""===K?dn.push(t):(wx.Queue.push(t),dn.concat()):wx.Queue.push(t)}function v(){var n={};for(var t in en)n[t]=en[t];return n}function _(n){for(var t="",e=0;e<n.length;e++)n[e].length>t.length&&(t=n[e]);return t}function m(){return""+Date.now()+Math.floor(1e7*Math.random())}function y(n){var t={};for(var e in n)"rawData"!=e&&"errMsg"!=e&&(t[e]=n[e]);return t}function S(n){if(n.indexOf("?")==-1)return"";var t={};return n.split("?")[1].split("&").forEach(function(n){var e=n.split("=")[1];t[n.split("=")[0]]=e}),t}function x(n){for(var t in n)if("object"==typeof n[t]&&null!==n[t])return!0;return!1}function D(n,t){var e=v();e.ev=n,e.life=t,e.ec=Z,e.dr=Date.now()-N,"show"==t&&(e.uo=C.useOpen),X&&(e.qr=X,e.sr=X),F&&(e.usr=F),g(e)}function q(n,t){var e=v();e.ev=n,e.life=t,e.pp=rn,e.pc=sn,e.dr=Date.now()-N,(fn||vn)&&(e.so=1),vn=!1,fn=!1,cn&&"{}"!=JSON.stringify(cn)&&(e.ag=cn),X&&(e.qr=X,e.sr=X),F&&(e.usr=F),an&&(e.ps=1),on?e.pdr=wn:(un=rn,on=!0,e.ifp=on,e.fp=rn,e.pdr=0),g(e)}function A(n,t,e){var o=v();o.ev=n,o.tp=t,o.dr=Date.now()-N,e&&(o.ct=e),g(o)}function I(n,t,e){if(n[t]){var o=n[t];n[t]=function(n){e.call(this,n,t),o.call(this,n)}}else n[t]=function(n){e.call(this,n,t)}}function O(n){var t={};for(var e in n)"onLaunch"!==e&&"onShow"!==e&&"onHide"!==e&&"onError"!==e&&(t[e]=n[e]);return t.onLaunch=function(t){a.call(this,t),"function"==typeof n.onLaunch&&n.onLaunch.call(this,t)},t.onShow=function(t){r.call(this,t),n.onShow&&"function"==typeof n.onShow&&n.onShow.call(this,t)},t.onHide=function(){i.call(this),n.onHide&&"function"==typeof n.onHide&&n.onHide.call(this)},t.onError=function(t){s.call(this,t),n.onError&&"function"==typeof n.onError&&n.onError.call(this,t)},t}function M(n){var t={};for(var e in n)"onLoad"!==e&&"onShow"!==e&&"onHide"!==e&&"onUnload"!==e&&"onPullDownRefresh"!==e&&"onReachBottom"!==e&&"onShareAppMessage"!==e&&(t[e]=n[e]);return t.onLoad=function(t){c.call(this,t),"function"==typeof n.onLoad&&n.onLoad.call(this,t)},t.onShow=function(t){u.call(this),"function"==typeof n.onShow&&n.onShow.call(this,t)},t.onHide=function(t){h.call(this),"function"==typeof n.onHide&&n.onHide.call(this,t)},t.onUnload=function(t){f.call(this),"function"==typeof n.onUnload&&n.onUnload.call(this,t)},t.onReachBottom=function(t){d(),n.onReachBottom&&"function"==typeof n.onReachBottom&&n.onReachBottom.call(this,t)},t.onPullDownRefresh=function(t){l(),n.onPullDownRefresh&&"function"==typeof n.onPullDownRefresh&&n.onPullDownRefresh.call(this,t)},n.onShareAppMessage&&"function"==typeof n.onShareAppMessage&&(t.onShareAppMessage=function(t){var e=n.onShareAppMessage.call(this,t);return void 0===e?(e={},e.path=this.route):void 0===e.path&&(e.path=this.route),p.call(this,e)}),t}function P(n){return App(O(n))}function k(n){return Page(M(n))}function L(n){return j=!0,O(n)}function R(n){return M(n)}var C=require("./ald-stat-conf");void 0===wx.Queue&&(wx.Queue=new n,wx.Queue.all()),""===C.app_key&&console.error("请在ald-stat-conf.js文件中填写小程序统计/广告监测平台创建小程序后生成的app_key,请参考接入文档 http://doc.aldwx.com 小程序统计平台-快速接入指南!"),C.useOpen&&console.warn("提示:开启了useOpen配置后,如果不上传用户OpendID则不会上报数据,上传方式:http://doc.aldwx.com 小程序统计/广告监测平台-快速接入指南-上传OpenID!");var H="7.3.8",b="log",U="wx",E=function(){return void 0===wx.getAccountInfoSync?"":wx.getAccountInfoSync().miniProgram.appId.split("").map(function(n){return n.charCodeAt(0)+9}).join("-")}(),j=!1,T=m(),B="",N=Date.now(),Q=0,J="",K=function(){var n="";try{n=wx.getStorageSync("aldstat_op")}catch(n){}return n}(),G="",z=0,V="",W="",$=function(){var n="";try{n=wx.getStorageSync("aldstat_uuid")}catch(t){n="uuid_getstoragesync"}if(n)W=!1;else{n=w();try{wx.setStorageSync("aldstat_uuid",n),W=!0}catch(n){wx.setStorageSync("aldstat_uuid","uuid_getstoragesync")}}return n}(),F="",X="",Y="",Z=0,nn="",tn="",en={},on=!1,an=!1,rn="",sn="",cn="",un="",hn=!0,fn=!1,ln="",dn=new t,pn=0,wn=0,gn=[{name:"scanCode"},{name:"chooseAddress"},{name:"chooseImage"},{name:"previewImage"},{name:"chooseInvoiceTitle"},{name:"chooseInvoice"}],vn=!1;!function(){gn.forEach(function(n){n.fn=wx[n.name];var t=n.name;try{Object.defineProperty(wx,t,{get:function(){return vn=!0,n.fn}})}catch(n){}})}();var _n="";!function(){wx.request({url:"https://"+b+".aldwx.com/config/app.json",header:{AldStat:"MiniApp-Stat"},method:"GET",success:function(n){200===n.statusCode&&(H<n.data.version&&console.warn("您的SDK不是最新版本,部分功能不可用,请尽快前往 http://tj.aldwx.com/downSDK 升级"),n.data.warn&&console.warn(n.data.warn),n.data.error&&console.error(n.data.error))}})}(),wx.aldstat=new o("");try{var mn=wx.getSystemInfoSync();en.br=mn.brand,en.pm=mn.model,en.pr=mn.pixelRatio,en.ww=mn.windowWidth,en.wh=mn.windowHeight,en.lang=mn.language,en.wv=mn.version,en.wvv=mn.platform,en.wsdk=mn.SDKVersion,en.sv=mn.system}catch(n){}wx.getNetworkType({success:function(n){en.nt=n.networkType}}),wx.getSetting({success:function(n){n.authSetting["scope.userLocation"]?wx.getLocation({type:"wgs84",success:function(n){en.lat=n.latitude,en.lng=n.longitude,en.spd=n.speed}}):C.getLocation&&wx.getLocation({type:"wgs84",success:function(n){en.lat=n.latitude,en.lng=n.longitude,en.spd=n.speed}})}}),o.prototype.sendEvent=function(n,t){if(""!==n&&"string"==typeof n&&n.length<=255)if("string"==typeof t&&t.length<=255)A("event",n,t);else if("object"==typeof t){if(JSON.stringify(t).length>=255)return void console.error("自定义事件参数不能超过255个字符,请参考接入文档 http://doc.aldwx.com 小程序统计平台-快速接入指南-自定义事件!");if(x(t))return void console.error("事件参数内部只支持Number、String等类型,请参考接入文档 http://doc.aldwx.com 小程序统计平台-快速接入指南-自定义事件!");for(var e in t)"number"==typeof t[e]&&(t[e]=t[e]+"s##");A("event",n,JSON.stringify(t))}else void 0===t?A("event",n,!1):console.error("事件参数必须为String、Object类型,且参数长度不能超过255个字符,请参考接入文档 http://doc.aldwx.com 小程序统计平台-快速接入指南-自定义事件!");else console.error("事件名称必须为String类型且不能超过255个字符,请参考接入文档 http://doc.aldwx.com 小程序统计平台-快速接入指南-自定义事件!")},o.prototype.sendSession=function(n){if(""===n||!n)return void console.error("请传入从后台获取的session_key");J=n;var t=v();t.tp="session",t.ct="session",t.ev="event",""===tn?wx.getSetting({success:function(n){n.authSetting["scope.userInfo"]?wx.getUserInfo({success:function(n){t.ufo=y(n),G=_(n.userInfo.avatarUrl.split("/")),""!==nn&&(t.gid=nn),g(t)}}):""!==nn&&(t.gid=nn,g(t))}}):(t.ufo=tn,""!==nn&&(t.gid=nn),g(t))},o.prototype.sendOpenid=function(n){if(""===n||!n||28!==n.length)return void console.error("OpenID不符合规则,请参考接入文档 http://doc.aldwx.com 小程序统计/广告监测平台-快速接入指南!");K=n,wx.setStorageSync("aldstat_op",n);var t=v();t.tp="openid",t.ev="event",t.ct="openid",g(t)},o.prototype.setOpenid=function(n){"function"==typeof n&&(_n=n,e())};return C.plugin?{App:P,Page:k,MpvueApp:L,MpvuePage:R}:function(n){!function(){var n=App,t=Page,e=Component;App=function(t){I(t,"onLaunch",a),I(t,"onShow",r),I(t,"onHide",i),I(t,"onError",s),n(t)},Page=function(n){var e=n.onShareAppMessage;I(n,"onLoad",c),I(n,"onUnload",f),I(n,"onShow",u),I(n,"onHide",h),I(n,"onReachBottom",d),I(n,"onPullDownRefresh",l),void 0!==e&&null!==e&&(n.onShareAppMessage=function(n){if(void 0!==e){var t=e.call(this,n);return void 0===t?(t={},t.path=rn):void 0===t.path&&(t.path=rn),p(t)}}),t(n)},Component=function(n){try{var t=n.methods.onShareAppMessage;I(n.methods,"onLoad",c),I(n.methods,"onUnload",f),I(n.methods,"onShow",u),I(n.methods,"onHide",h),I(n.methods,"onReachBottom",d),I(n.methods,"onPullDownRefresh",l),void 0!==t&&null!==t&&(n.methods.onShareAppMessage=function(n){if(void 0!==t){var e=t.call(this,n);return void 0===e?(e={},e.path=rn):void 0===e.path&&(e.path=rn),p(e)}}),e(n)}catch(t){e(n)}}}()}()});
|