Skip to content

Commit f1e94a3

Browse files
author
shengyonggen
committed
修复page里的q的bug
1 parent e398780 commit f1e94a3

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

sensorsdata.js

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ var ArrayProto = Array.prototype,
2323
slice = ArrayProto.slice,
2424
toString = ObjProto.toString,
2525
hasOwnProperty = ObjProto.hasOwnProperty,
26-
LIB_VERSION = '1.2',
26+
LIB_VERSION = '1.3',
2727
LIB_NAME = 'MiniProgram';
2828

2929
var source_channel_standard = 'utm_source utm_medium utm_campaign utm_content utm_term';
@@ -589,14 +589,21 @@ _.getUtm = function(url,prefix1,prefix2){
589589
var utms = _.getSource(url);
590590
var pre1 = {};
591591
var pre2 = {};
592-
if(typeof prefix1 === 'undefined'){
593-
return _.getPrefixUtm(utms,'$').$utms;
594-
}
595-
if(typeof prefix2 !== 'undefined'){
592+
if ((typeof prefix2 === 'undefined') && prefix1) {
596593
return {
597-
pre1: _.getPrefixUtm(utms, '$').$utms || {},
598-
pre2: _.getPrefixUtm(utms, '$latest_').$utms || {}
599-
}
594+
pre1: _.getPrefixUtm(utms, prefix1).$utms || {},
595+
pre2: {}
596+
};
597+
} else if (typeof prefix2 !== 'undefined' && prefix1){
598+
return {
599+
pre1: _.getPrefixUtm(utms, prefix1).$utms || {},
600+
pre2: _.getPrefixUtm(utms, prefix2).$utms || {}
601+
};
602+
} else {
603+
return {
604+
pre1:{},
605+
pre2:{}
606+
};
600607
}
601608
}
602609

@@ -1058,7 +1065,7 @@ sa.initWithOpenid = function (options) {
10581065
};
10591066

10601067
// 对所有提供的方法做代理暂存
1061-
_.each(["setProfile", "setOnceProfile", "track", "register", "clearAllRegister", "autoTrackCustom"],function(method){
1068+
_.each(['setProfile', 'setOnceProfile', 'track', 'register', 'clearAllRegister', 'autoTrackCustom', 'registerApp'],function(method){
10621069
var temp = sa[method];
10631070
sa[method] = function(){
10641071
if (sa.initialState.isComplete){
@@ -1118,9 +1125,10 @@ function appShow(para) {
11181125
if (para && para.path) {
11191126
prop.$url_path = para.path;
11201127
}
1128+
11211129
// 暂时只解析传统网页渠道的query
11221130
if (para && _.isObject(para.query) && para.query.q) {
1123-
var utms = _.getUtm(para.query.q, '$', '$latest');
1131+
var utms = _.getUtm(para.query.q, '$', '$latest_');
11241132
_.extend(prop, utms.pre1);
11251133
sa.registerApp(utms.pre2);
11261134
}

0 commit comments

Comments
 (0)