@@ -23,7 +23,7 @@ var ArrayProto = Array.prototype,
2323 slice = ArrayProto . slice ,
2424 toString = ObjProto . toString ,
2525 hasOwnProperty = ObjProto . hasOwnProperty ,
26- LIB_VERSION = '1.4 ' ,
26+ LIB_VERSION = '1.5 ' ,
2727 LIB_NAME = 'MiniProgram' ;
2828
2929var source_channel_standard = 'utm_source utm_medium utm_campaign utm_content utm_term' ;
@@ -504,6 +504,18 @@ _.base64Encode = function (data) {
504504 return enc ;
505505} ;
506506
507+ _ . getCurrentPath = function ( ) {
508+ var url = '未取到' ;
509+ try {
510+ var pages = getCurrentPages ( ) ;
511+ var currentPage = pages [ pages . length - 1 ] ;
512+ url = currentPage . route ;
513+ } catch ( e ) {
514+ logger . info ( e ) ;
515+ } ;
516+ return url ;
517+ } ;
518+
507519_ . getQueryParam = function ( url , param ) {
508520 var regexS = "[\\?&]" + param + "=([^&#]*)" ,
509521 regex = new RegExp ( regexS ) ,
@@ -655,6 +667,15 @@ _.setUtm = function(para,prop){
655667 var query = { } ;
656668 if ( para && _ . isObject ( para . query ) ) {
657669 query = _ . extend ( { } , para . query ) ;
670+ var scene = query . scene ;
671+ if ( scene ) {
672+ if ( scene . indexOf ( "?" ) !== - 1 ) {
673+ scene = '?' + scene . replace ( / \? / g, '' ) ;
674+ } else {
675+ scene = '?' + scene ;
676+ }
677+ _ . extend ( query , _ . getObjFromQuery ( scene ) ) ;
678+ }
658679 if ( para . query . q ) {
659680 _ . extend ( query , _ . getObjFromQuery ( para . query . q ) ) ;
660681 }
@@ -1009,6 +1030,15 @@ sa.init = function(){
10091030 sa . initialState . checkIsComplete ( ) ;
10101031} ;
10111032
1033+ sa . getPresetProperties = function ( ) {
1034+ if ( _ . info && _ . info . properties && _ . info . properties . $lib && _ . info . properties . $user_agent ) {
1035+ delete _ . info . properties . $lib ;
1036+ delete _ . info . properties . $user_agent ;
1037+ return _ . extend ( { $url_path : _ . getCurrentPath ( ) } , _ . info . properties , sa . store . getProps ( ) ) ;
1038+ } else {
1039+ return { } ;
1040+ }
1041+ }
10121042
10131043// 发送队列
10141044_ . autoExeQueue = function ( ) {
@@ -1204,6 +1234,7 @@ function appHide() {
12041234
12051235 var current_time = ( new Date ( ) ) . getTime ( ) ;
12061236 var prop = { } ;
1237+ prop . $url_path = _ . getCurrentPath ( ) ;
12071238 if ( mpshow_time && ( current_time - mpshow_time > 0 ) && ( ( current_time - mpshow_time ) / 3600000 < 24 ) ) {
12081239 prop . event_duration = ( current_time - mpshow_time ) / 1000 ;
12091240 }
@@ -1302,7 +1333,7 @@ Page = function (t) {
13021333 sa_referrer = router ;
13031334 } ) ;
13041335
1305- // e(t, "onHide", pageOnHide);
1336+ // e(t, "onHide", pageOnHide);
13061337
13071338 // e(t, "onReady", pageOnReady);
13081339 // e(t, "onPullDownRefresh", pageOnPullDownRefresh);
0 commit comments