Showing
3 changed files
with
17 additions
and
20 deletions
| @@ -21,12 +21,6 @@ App({ | @@ -21,12 +21,6 @@ App({ | ||
| 21 | shareTicket:"", | 21 | shareTicket:"", |
| 22 | onLaunch: async function (opt) { | 22 | onLaunch: async function (opt) { |
| 23 | console.log('onLaunch',opt); | 23 | console.log('onLaunch',opt); |
| 24 | - if(opt.shareTicket){ | ||
| 25 | - this.shareTicket=opt.shareTicket; | ||
| 26 | - } | ||
| 27 | - this.getSystemInfo(); | ||
| 28 | - this.openid=await this.getOpenid(); | ||
| 29 | - console.log('this.openid',this.openid); | ||
| 30 | mta.App.init({ | 24 | mta.App.init({ |
| 31 | "appID":"500667280", | 25 | "appID":"500667280", |
| 32 | "eventID":"500667287", | 26 | "eventID":"500667287", |
| @@ -35,6 +29,13 @@ App({ | @@ -35,6 +29,13 @@ App({ | ||
| 35 | "statReachBottom":true, | 29 | "statReachBottom":true, |
| 36 | "lauchOpts":opt, //渠道分析 | 30 | "lauchOpts":opt, //渠道分析 |
| 37 | }); | 31 | }); |
| 32 | + if(opt.shareTicket){ | ||
| 33 | + this.shareTicket=opt.shareTicket; | ||
| 34 | + } | ||
| 35 | + this.getSystemInfo(); | ||
| 36 | + this.openid=await this.getOpenid(); | ||
| 37 | + console.log('this.openid',this.openid,mta); | ||
| 38 | + | ||
| 38 | }, | 39 | }, |
| 39 | onShow:async function(){ | 40 | onShow:async function(){ |
| 40 | if (wx.canIUse('getUpdateManager')) { | 41 | if (wx.canIUse('getUpdateManager')) { |
| 1 | // pages/customer/index.js | 1 | // pages/customer/index.js |
| 2 | +var mta=require('mta-wechat-analysis') | ||
| 2 | import App from '../../utils/api'; | 3 | import App from '../../utils/api'; |
| 3 | import util from '../../utils/util' | 4 | import util from '../../utils/util' |
| 4 | const {regeneratorRuntime} = global | 5 | const {regeneratorRuntime} = global |
| @@ -17,7 +18,7 @@ Page({ | @@ -17,7 +18,7 @@ Page({ | ||
| 17 | islove:'',//用户在哪端 | 18 | islove:'',//用户在哪端 |
| 18 | enter_params:'',//商户入口参数 | 19 | enter_params:'',//商户入口参数 |
| 19 | async onLoad(opt) { | 20 | async onLoad(opt) { |
| 20 | - console.log('onLoad', opt); | 21 | + console.log('onLoad', opt,mta); |
| 21 | //转化场景值到opt | 22 | //转化场景值到opt |
| 22 | this.selectComponent("#network").debug(opt, 'opt'); | 23 | this.selectComponent("#network").debug(opt, 'opt'); |
| 23 | if (opt.scene) {//扫码进入 | 24 | if (opt.scene) {//扫码进入 |
| @@ -28,6 +29,14 @@ Page({ | @@ -28,6 +29,14 @@ Page({ | ||
| 28 | }) | 29 | }) |
| 29 | this.selectComponent("#network").debug(opt, 'scene'); | 30 | this.selectComponent("#network").debug(opt, 'scene'); |
| 30 | } | 31 | } |
| 32 | + mta.Page.init({ | ||
| 33 | + "appID":"500667280", | ||
| 34 | + "eventID":"500667287", | ||
| 35 | + "statPullDownFresh":true, | ||
| 36 | + "statShareApp":true, | ||
| 37 | + "statReachBottom":true, | ||
| 38 | + "lauchOpts":opt, //渠道分析 | ||
| 39 | + }); | ||
| 31 | opt.openid = await this.getOpenid(); | 40 | opt.openid = await this.getOpenid(); |
| 32 | if (!opt.openid) { | 41 | if (!opt.openid) { |
| 33 | console.log('App.Orders.CheckOrder no openid'); | 42 | console.log('App.Orders.CheckOrder no openid'); |
utils/mta_analysis.js
deleted
100644 → 0
| 1 | -//application id got from MTAMTA analysis | ||
| 2 | -var MTA_APP_ID = ''; //常规统计id | ||
| 3 | -var MTA_EVENT_ID = ''; //自定义事件id | ||
| 4 | -//data report remote address | ||
| 5 | -var MTA_API_BASE = 'https://pingtas.qq.com/pingd'; | ||
| 6 | -//MTA wechat apps analysis storage key prefix | ||
| 7 | -var MTA_VAR_PREFIX = '_mta_'; | ||
| 8 | - | ||
| 9 | -function getNetworkType(a){wx.getNetworkType({success:function(b){a(b.networkType)}})}function getSystemInfo(){var a=wx.getSystemInfoSync();return{adt:a.model,scl:a.pixelRatio,scr:a.windowWidth+"x"+a.windowHeight,lg:a.language,fl:a.version}}function getUID(){try{return wx.getStorageSync(MTA_VAR_PREFIX+"auid")}catch(a){}}function setUID(){try{var a=getRandom();wx.setStorageSync(MTA_VAR_PREFIX+"auid",a);return a}catch(b){}} | ||
| 10 | -function getSID(){try{return wx.getStorageSync(MTA_VAR_PREFIX+"ssid")}catch(a){}}function setSID(){try{var a="s"+getRandom();wx.setStorageSync(MTA_VAR_PREFIX+"ssid",a);return a}catch(b){}}function getRandom(a){return(a||"")+Math.round(2147483647*(Math.random()||.5))*+new Date%1E10}function getPagePath(){try{var a=getCurrentPages(),b="/";0<a.length&&(b=a.pop().__route__);return b}catch(e){console.log("get current page path error:"+e)}} | ||
| 11 | -function getMainInfo(){var a={dm:"wechat.apps.xx",url:getPagePath(),pvi:"",si:"",ty:2};a.pvi=function(){var b=getUID();b||(a.ty=1,b=setUID());return b}();a.si=function(){var a=getSID();a||(a=setSID());return a}();return a}function getBasicInfo(){var a=getSystemInfo();getNetworkType(function(a){wx.setStorageSync(MTA_VAR_PREFIX+"ntdata",a)});a.ct=wx.getStorageSync(MTA_VAR_PREFIX+"ntdata")||"4g";return a}function getExtentInfo(){return{r2:MTA_APP_ID,r4:"wx"}} | ||
| 12 | -module.exports={initLaunch:function(){setSID()},rptMain:function(){if(""!=MTA_APP_ID){for(var a=[],b=0,e=[getMainInfo(),getBasicInfo(),getExtentInfo(),{random:+new Date}],d=e.length;b<d;b++)for(var f in e[b])e[b].hasOwnProperty(f)&&a.push(f+"="+(e[b][f]||""));wx.request({url:MTA_API_BASE+"?"+a.join("&").toLowerCase()})}},eventStat:function(a,b){if(""!=MTA_EVENT_ID){var e=[],d=getMainInfo(),f=getExtentInfo();d.dm="wxapps.click";d.url=a;f.r2=MTA_EVENT_ID;var c;c="undefined"===typeof b?{}:b;var k=[], | ||
| 13 | -g;for(g in c)c.hasOwnProperty(g)&&k.push(g+"="+c[g]);c=k.join(";");f.r5=c;c=0;d=[d,getBasicInfo(),f,{random:+new Date}];for(f=d.length;c<f;c++)for(var h in d[c])d[c].hasOwnProperty(h)&&e.push(h+"="+(d[c][h]||""));wx.request({url:MTA_API_BASE+"?"+e.join("&").toLowerCase()})}}}; |
-
Please register or login to post a comment