Authored by 郝肖肖

微信商城 埋点

@@ -141,6 +141,25 @@ function reMarginFooter(fixedElement) { @@ -141,6 +141,25 @@ function reMarginFooter(fixedElement) {
141 } 141 }
142 } 142 }
143 143
  144 +function queryString() {
  145 + var vars = [],
  146 + hash,
  147 + i;
  148 + var hashes = window.location.search.slice(1).split('&');
  149 +
  150 + for (i = 0; i < hashes.length; i++) {
  151 + hash = hashes[i].split('=');
  152 + vars.push(hash[0]);
  153 + vars[hash[0]] = hash[1];
  154 + }
  155 + return vars;
  156 +}
  157 +
  158 +// 给jQuery 扩展 queryString函数
  159 +$.extend({
  160 + queryString: queryString
  161 +});
  162 +
144 // 页面通用底部位置及status设置 163 // 页面通用底部位置及status设置
145 (function() { 164 (function() {
146 var $op = $footer.children('.op-row'), 165 var $op = $footer.children('.op-row'),
@@ -180,6 +199,12 @@ function reMarginFooter(fixedElement) { @@ -180,6 +199,12 @@ function reMarginFooter(fixedElement) {
180 } 199 }
181 200
182 $footer.removeClass('hide'); 201 $footer.removeClass('hide');
  202 +
  203 + // 接受微信商城或者第三方来源的数据埋点信息
  204 + if (queryString().union_type) {
  205 + setCookie('union_type', queryString().union_type);
  206 + }
  207 +
183 }()); 208 }());
184 209
185 (function(w, d, s, j, f) { 210 (function(w, d, s, j, f) {
@@ -195,7 +220,7 @@ function reMarginFooter(fixedElement) { @@ -195,7 +220,7 @@ function reMarginFooter(fixedElement) {
195 a.async = 1; 220 a.async = 1;
196 a.src = j; 221 a.src = j;
197 m.parentNode.insertBefore(a, m); 222 m.parentNode.insertBefore(a, m);
198 -})(window, document, 'script', (document.location.protocol === 'https:' ? 'https' : 'http') + '://cdn.yoho.cn/yas-jssdk/1.0.17/yas.js', '_yas'); 223 +}(window, document, 'script', (document.location.protocol === 'https:' ? 'https' : 'http') + '://cdn.yoho.cn/yas-jssdk/1.0.17/yas.js', '_yas'));
199 224
200 (function() { 225 (function() {
201 var uid = getUid(); 226 var uid = getUid();
@@ -270,24 +295,6 @@ $('.nav-home').on('touchstart', function() { @@ -270,24 +295,6 @@ $('.nav-home').on('touchstart', function() {
270 window.cancelAnimationFrame = cancelAnimationFrame; 295 window.cancelAnimationFrame = cancelAnimationFrame;
271 }()); 296 }());
272 297
273 -function queryString() {  
274 - var vars = [],  
275 - hash,  
276 - i;  
277 - var hashes = window.location.search.slice(1).split('&');  
278 -  
279 - for (i = 0; i < hashes.length; i++) {  
280 - hash = hashes[i].split('=');  
281 - vars.push(hash[0]);  
282 - vars[hash[0]] = hash[1];  
283 - }  
284 - return vars;  
285 -}  
286 -  
287 -// 给jQuery 扩展 queryString函数  
288 -$.extend({  
289 - queryString: queryString  
290 -});  
291 298
292 // 临时修改 footer 299 // 临时修改 footer
293 function phoneHidden(phone) { 300 function phoneHidden(phone) {
@@ -11,30 +11,25 @@ var floatLayerBtnHammer; @@ -11,30 +11,25 @@ var floatLayerBtnHammer;
11 11
12 require('../common'); 12 require('../common');
13 13
14 -/**  
15 - * 获取url参数  
16 - */  
17 -function getQueryString(name) {  
18 - var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');  
19 - var r = window.location.search.substr(1).match(reg);  
20 -  
21 - if (r !== null) {  
22 - return window.unescape(r[2]);  
23 - }  
24 - return null;  
25 -}  
26 -  
27 function downLoadApp() { 14 function downLoadApp() {
28 - var appUrl = 'http://www.yohoshow.com/about/index/yohobuyqr/'; 15 + var appUrl = 'http://union.yoho.cn/union/downapp.html';
29 var clickedAt = new Date(); 16 var clickedAt = new Date();
30 17
31 setTimeout(function() { 18 setTimeout(function() {
32 - var mkt = getQueryString('mkt_code'); 19 + var mkt = window.queryString().union_type || window.cookie('union_type') || false;
33 20
34 if ((new Date()) - clickedAt < 2000) { 21 if ((new Date()) - clickedAt < 2000) {
35 if (mkt) { 22 if (mkt) {
36 appUrl += '?union_type=' + mkt; 23 appUrl += '?union_type=' + mkt;
37 } 24 }
  25 +
  26 + if (window._yas.sendCustomInfo && window._yas.sendCustomInfo) {
  27 + window._yas.sendCustomInfo({
  28 + op: 'YB_CHOOSE_FOR_YOU_Y',
  29 + param: JSON.stringify([])
  30 + }, true);
  31 + }
  32 +
38 window.location = appUrl; 33 window.location = appUrl;
39 } 34 }
40 }, 500); 35 }, 500);