Authored by 沈志敏

fix android商品详情页 未能上报数据的bug

Showing 1 changed file with 25 additions and 8 deletions
... ... @@ -469,8 +469,15 @@ _yas.sendAppLogs = function(json, asyncindx) {
cross.appSend("_mlogs=" + escape(JSON.stringify(logs)));
window._yasloaded = true;
if (asyncindx) {
// 将indx同步到app中
if (asyncindx) { // 将indx同步到app中
if (window.isandroidyas) {
window.prompt(JSON.stringify({
method: 'set.analyticEventIndex',
arguments: {
indx: window.indx
}
}));
} else {
window.yohoInterface.triggerEvent(nullFun, nullFun, {
method: 'set.analyticEventIndex',
arguments: {
... ... @@ -478,6 +485,7 @@ _yas.sendAppLogs = function(json, asyncindx) {
}
});
}
}
}
function appPageOpen(data, actionUrl) {
... ... @@ -516,14 +524,23 @@ function appPageOpen(data, actionUrl) {
}
}
// 监听app加载的deviceready事件
ev.addEventHandler(document, 'deviceready', function(e) {
if (navigator.userAgent.indexOf('YohoBuy-android-yas') > -1) {
// 针对android商品详情页做特殊处理
window.isandroidyas = true;
var data = window.prompt(JSON.stringify({
method: 'get.analyticAppData'
}));
appPageOpen(JSON.parse(data || '{}'));
} else {
// 监听app加载的deviceready事件
ev.addEventHandler(document, 'deviceready', function(e) {
window._yasloaded = false;
var actionUrl = [];
var aDom = document.getElementsByTagName("a"); //获取页面所有a标签
for(var i = 0; i < aDom.length; i++) {
for (var i = 0; i < aDom.length; i++) {
var href = aDom[i].getAttribute('href');
if (href && !/^#.*$/.test(href) && !/^javascript.*$/i.test(href)) {
actionUrl.push(href);
... ... @@ -567,7 +584,7 @@ ev.addEventHandler(document, 'deviceready', function(e) {
});
}
window.yohoInterface.triggerEvent(function(data){
window.yohoInterface.triggerEvent(function(data) {
appPageOpen(data, actionUrl);
}, nullFun, {
method: 'get.analyticAppData'
... ... @@ -585,7 +602,7 @@ ev.addEventHandler(document, 'deviceready', function(e) {
});
}
}, 500);
});
});
}
module.exports = _yas;
\ No newline at end of file
... ...