fix android商品详情页 未能上报数据的bug
Showing
1 changed file
with
25 additions
and
8 deletions
@@ -469,8 +469,15 @@ _yas.sendAppLogs = function(json, asyncindx) { | @@ -469,8 +469,15 @@ _yas.sendAppLogs = function(json, asyncindx) { | ||
469 | cross.appSend("_mlogs=" + escape(JSON.stringify(logs))); | 469 | cross.appSend("_mlogs=" + escape(JSON.stringify(logs))); |
470 | window._yasloaded = true; | 470 | window._yasloaded = true; |
471 | 471 | ||
472 | - if (asyncindx) { | ||
473 | - // 将indx同步到app中 | 472 | + if (asyncindx) { // 将indx同步到app中 |
473 | + if (window.isandroidyas) { | ||
474 | + window.prompt(JSON.stringify({ | ||
475 | + method: 'set.analyticEventIndex', | ||
476 | + arguments: { | ||
477 | + indx: window.indx | ||
478 | + } | ||
479 | + })); | ||
480 | + } else { | ||
474 | window.yohoInterface.triggerEvent(nullFun, nullFun, { | 481 | window.yohoInterface.triggerEvent(nullFun, nullFun, { |
475 | method: 'set.analyticEventIndex', | 482 | method: 'set.analyticEventIndex', |
476 | arguments: { | 483 | arguments: { |
@@ -478,6 +485,7 @@ _yas.sendAppLogs = function(json, asyncindx) { | @@ -478,6 +485,7 @@ _yas.sendAppLogs = function(json, asyncindx) { | ||
478 | } | 485 | } |
479 | }); | 486 | }); |
480 | } | 487 | } |
488 | + } | ||
481 | } | 489 | } |
482 | 490 | ||
483 | function appPageOpen(data, actionUrl) { | 491 | function appPageOpen(data, actionUrl) { |
@@ -516,14 +524,23 @@ function appPageOpen(data, actionUrl) { | @@ -516,14 +524,23 @@ function appPageOpen(data, actionUrl) { | ||
516 | } | 524 | } |
517 | } | 525 | } |
518 | 526 | ||
519 | -// 监听app加载的deviceready事件 | ||
520 | -ev.addEventHandler(document, 'deviceready', function(e) { | 527 | +if (navigator.userAgent.indexOf('YohoBuy-android-yas') > -1) { |
528 | + // 针对android商品详情页做特殊处理 | ||
529 | + window.isandroidyas = true; | ||
530 | + var data = window.prompt(JSON.stringify({ | ||
531 | + method: 'get.analyticAppData' | ||
532 | + })); | ||
533 | + | ||
534 | + appPageOpen(JSON.parse(data || '{}')); | ||
535 | +} else { | ||
536 | + // 监听app加载的deviceready事件 | ||
537 | + ev.addEventHandler(document, 'deviceready', function(e) { | ||
521 | window._yasloaded = false; | 538 | window._yasloaded = false; |
522 | 539 | ||
523 | var actionUrl = []; | 540 | var actionUrl = []; |
524 | var aDom = document.getElementsByTagName("a"); //获取页面所有a标签 | 541 | var aDom = document.getElementsByTagName("a"); //获取页面所有a标签 |
525 | 542 | ||
526 | - for(var i = 0; i < aDom.length; i++) { | 543 | + for (var i = 0; i < aDom.length; i++) { |
527 | var href = aDom[i].getAttribute('href'); | 544 | var href = aDom[i].getAttribute('href'); |
528 | if (href && !/^#.*$/.test(href) && !/^javascript.*$/i.test(href)) { | 545 | if (href && !/^#.*$/.test(href) && !/^javascript.*$/i.test(href)) { |
529 | actionUrl.push(href); | 546 | actionUrl.push(href); |
@@ -567,7 +584,7 @@ ev.addEventHandler(document, 'deviceready', function(e) { | @@ -567,7 +584,7 @@ ev.addEventHandler(document, 'deviceready', function(e) { | ||
567 | }); | 584 | }); |
568 | } | 585 | } |
569 | 586 | ||
570 | - window.yohoInterface.triggerEvent(function(data){ | 587 | + window.yohoInterface.triggerEvent(function(data) { |
571 | appPageOpen(data, actionUrl); | 588 | appPageOpen(data, actionUrl); |
572 | }, nullFun, { | 589 | }, nullFun, { |
573 | method: 'get.analyticAppData' | 590 | method: 'get.analyticAppData' |
@@ -585,7 +602,7 @@ ev.addEventHandler(document, 'deviceready', function(e) { | @@ -585,7 +602,7 @@ ev.addEventHandler(document, 'deviceready', function(e) { | ||
585 | }); | 602 | }); |
586 | } | 603 | } |
587 | }, 500); | 604 | }, 500); |
588 | - | ||
589 | -}); | 605 | + }); |
606 | +} | ||
590 | 607 | ||
591 | module.exports = _yas; | 608 | module.exports = _yas; |
-
Please register or login to post a comment