fix android商品详情页 未能上报数据的bug
Showing
1 changed file
with
86 additions
and
69 deletions
@@ -469,14 +469,22 @@ _yas.sendAppLogs = function(json, asyncindx) { | @@ -469,14 +469,22 @@ _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中 | ||
474 | - window.yohoInterface.triggerEvent(nullFun, nullFun, { | ||
475 | - method: 'set.analyticEventIndex', | ||
476 | - arguments: { | ||
477 | - indx: window.indx | ||
478 | - } | ||
479 | - }); | 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 { | ||
481 | + window.yohoInterface.triggerEvent(nullFun, nullFun, { | ||
482 | + method: 'set.analyticEventIndex', | ||
483 | + arguments: { | ||
484 | + indx: window.indx | ||
485 | + } | ||
486 | + }); | ||
487 | + } | ||
480 | } | 488 | } |
481 | } | 489 | } |
482 | 490 | ||
@@ -516,76 +524,85 @@ function appPageOpen(data, actionUrl) { | @@ -516,76 +524,85 @@ function appPageOpen(data, actionUrl) { | ||
516 | } | 524 | } |
517 | } | 525 | } |
518 | 526 | ||
519 | -// 监听app加载的deviceready事件 | ||
520 | -ev.addEventHandler(document, 'deviceready', function(e) { | ||
521 | - window._yasloaded = false; | ||
522 | - | ||
523 | - var actionUrl = []; | ||
524 | - var aDom = document.getElementsByTagName("a"); //获取页面所有a标签 | 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 | + })); | ||
525 | 533 | ||
526 | - for(var i = 0; i < aDom.length; i++) { | ||
527 | - var href = aDom[i].getAttribute('href'); | ||
528 | - if (href && !/^#.*$/.test(href) && !/^javascript.*$/i.test(href)) { | ||
529 | - actionUrl.push(href); | ||
530 | - } | ||
531 | - | ||
532 | - ev.addEventHandler(aDom[i], 'click', function(e) { | ||
533 | - if (!window.originUrl) { | ||
534 | - return; | 534 | + appPageOpen(JSON.parse(data || '{}')); |
535 | +} else { | ||
536 | + // 监听app加载的deviceready事件 | ||
537 | + ev.addEventHandler(document, 'deviceready', function(e) { | ||
538 | + window._yasloaded = false; | ||
539 | + | ||
540 | + var actionUrl = []; | ||
541 | + var aDom = document.getElementsByTagName("a"); //获取页面所有a标签 | ||
542 | + | ||
543 | + for (var i = 0; i < aDom.length; i++) { | ||
544 | + var href = aDom[i].getAttribute('href'); | ||
545 | + if (href && !/^#.*$/.test(href) && !/^javascript.*$/i.test(href)) { | ||
546 | + actionUrl.push(href); | ||
535 | } | 547 | } |
536 | - | ||
537 | - var target = e.currentTarget, | ||
538 | - furl = target.getAttribute('href'); | ||
539 | 548 | ||
540 | - // 上报曝光事件 | ||
541 | - _yas.sendAppLogs({ | ||
542 | - appop: 'YB_H5_PAGE_FLR_C', | ||
543 | - param: JSON.stringify({ | ||
544 | - C_ID: window.qs.yh_channel || util.getChannel() || 1, | ||
545 | - PAGE_URL: window.originUrl, | ||
546 | - PAGE_NAME: decodeURI(window.qs.title || document.title), | ||
547 | - F_URL: furl | ||
548 | - }) | ||
549 | - }, true); | ||
550 | - | ||
551 | - if ('feature.yoho.cn' === document.domain) { // feature.yoho.cn场合 | ||
552 | - var operid = target.getAttribute('operid'); | ||
553 | - if (operid) { | ||
554 | - var param = target.getAttribute('param'); | ||
555 | - | ||
556 | - param = JSON.parse(param); | ||
557 | - param.C_ID = window.qs.yh_channel; | ||
558 | - param.F_URL = furl; | ||
559 | - | ||
560 | - // 上报点击事件 | ||
561 | - _yas.sendAppLogs({ | ||
562 | - appop: operid, | ||
563 | - param: JSON.stringify(param) | ||
564 | - }, true); | 549 | + ev.addEventHandler(aDom[i], 'click', function(e) { |
550 | + if (!window.originUrl) { | ||
551 | + return; | ||
565 | } | 552 | } |
566 | - } | ||
567 | - }); | ||
568 | - } | ||
569 | 553 | ||
570 | - window.yohoInterface.triggerEvent(function(data){ | ||
571 | - appPageOpen(data, actionUrl); | ||
572 | - }, nullFun, { | ||
573 | - method: 'get.analyticAppData' | ||
574 | - }); | 554 | + var target = e.currentTarget, |
555 | + furl = target.getAttribute('href'); | ||
575 | 556 | ||
576 | - // 同步indx(需延迟处理) | ||
577 | - var timer = setInterval(function() { | ||
578 | - if (window._yasloaded) { | ||
579 | - clearInterval(timer); | ||
580 | - window.yohoInterface.triggerEvent(nullFun, nullFun, { | ||
581 | - method: 'set.analyticEventIndex', | ||
582 | - arguments: { | ||
583 | - indx: window.indx | 557 | + // 上报曝光事件 |
558 | + _yas.sendAppLogs({ | ||
559 | + appop: 'YB_H5_PAGE_FLR_C', | ||
560 | + param: JSON.stringify({ | ||
561 | + C_ID: window.qs.yh_channel || util.getChannel() || 1, | ||
562 | + PAGE_URL: window.originUrl, | ||
563 | + PAGE_NAME: decodeURI(window.qs.title || document.title), | ||
564 | + F_URL: furl | ||
565 | + }) | ||
566 | + }, true); | ||
567 | + | ||
568 | + if ('feature.yoho.cn' === document.domain) { // feature.yoho.cn场合 | ||
569 | + var operid = target.getAttribute('operid'); | ||
570 | + if (operid) { | ||
571 | + var param = target.getAttribute('param'); | ||
572 | + | ||
573 | + param = JSON.parse(param); | ||
574 | + param.C_ID = window.qs.yh_channel; | ||
575 | + param.F_URL = furl; | ||
576 | + | ||
577 | + // 上报点击事件 | ||
578 | + _yas.sendAppLogs({ | ||
579 | + appop: operid, | ||
580 | + param: JSON.stringify(param) | ||
581 | + }, true); | ||
582 | + } | ||
584 | } | 583 | } |
585 | }); | 584 | }); |
586 | } | 585 | } |
587 | - }, 500); | ||
588 | 586 | ||
589 | -}); | 587 | + window.yohoInterface.triggerEvent(function(data) { |
588 | + appPageOpen(data, actionUrl); | ||
589 | + }, nullFun, { | ||
590 | + method: 'get.analyticAppData' | ||
591 | + }); | ||
592 | + | ||
593 | + // 同步indx(需延迟处理) | ||
594 | + var timer = setInterval(function() { | ||
595 | + if (window._yasloaded) { | ||
596 | + clearInterval(timer); | ||
597 | + window.yohoInterface.triggerEvent(nullFun, nullFun, { | ||
598 | + method: 'set.analyticEventIndex', | ||
599 | + arguments: { | ||
600 | + indx: window.indx | ||
601 | + } | ||
602 | + }); | ||
603 | + } | ||
604 | + }, 500); | ||
605 | + }); | ||
606 | +} | ||
590 | 607 | ||
591 | module.exports = _yas; | 608 | module.exports = _yas; |
-
Please register or login to post a comment