...
|
...
|
@@ -469,14 +469,22 @@ _yas.sendAppLogs = function(json, asyncindx) { |
|
|
cross.appSend("_mlogs=" + escape(JSON.stringify(logs)));
|
|
|
window._yasloaded = true;
|
|
|
|
|
|
if (asyncindx) {
|
|
|
// 将indx同步到app中
|
|
|
window.yohoInterface.triggerEvent(nullFun, nullFun, {
|
|
|
method: 'set.analyticEventIndex',
|
|
|
arguments: {
|
|
|
indx: window.indx
|
|
|
}
|
|
|
});
|
|
|
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: {
|
|
|
indx: window.indx
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -516,76 +524,85 @@ function appPageOpen(data, actionUrl) { |
|
|
}
|
|
|
}
|
|
|
|
|
|
// 监听app加载的deviceready事件
|
|
|
ev.addEventHandler(document, 'deviceready', function(e) {
|
|
|
window._yasloaded = false;
|
|
|
|
|
|
var actionUrl = [];
|
|
|
var aDom = document.getElementsByTagName("a"); //获取页面所有a标签
|
|
|
if (navigator.userAgent.indexOf('YohoBuy-android-yas') > -1) {
|
|
|
// 针对android商品详情页做特殊处理
|
|
|
window.isandroidyas = true;
|
|
|
var data = window.prompt(JSON.stringify({
|
|
|
method: 'get.analyticAppData'
|
|
|
}));
|
|
|
|
|
|
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);
|
|
|
}
|
|
|
|
|
|
ev.addEventHandler(aDom[i], 'click', function(e) {
|
|
|
if (!window.originUrl) {
|
|
|
return;
|
|
|
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++) {
|
|
|
var href = aDom[i].getAttribute('href');
|
|
|
if (href && !/^#.*$/.test(href) && !/^javascript.*$/i.test(href)) {
|
|
|
actionUrl.push(href);
|
|
|
}
|
|
|
|
|
|
var target = e.currentTarget,
|
|
|
furl = target.getAttribute('href');
|
|
|
|
|
|
// 上报曝光事件
|
|
|
_yas.sendAppLogs({
|
|
|
appop: 'YB_H5_PAGE_FLR_C',
|
|
|
param: JSON.stringify({
|
|
|
C_ID: window.qs.yh_channel || util.getChannel() || 1,
|
|
|
PAGE_URL: window.originUrl,
|
|
|
PAGE_NAME: decodeURI(window.qs.title || document.title),
|
|
|
F_URL: furl
|
|
|
})
|
|
|
}, true);
|
|
|
|
|
|
if ('feature.yoho.cn' === document.domain) { // feature.yoho.cn场合
|
|
|
var operid = target.getAttribute('operid');
|
|
|
if (operid) {
|
|
|
var param = target.getAttribute('param');
|
|
|
|
|
|
param = JSON.parse(param);
|
|
|
param.C_ID = window.qs.yh_channel;
|
|
|
param.F_URL = furl;
|
|
|
|
|
|
// 上报点击事件
|
|
|
_yas.sendAppLogs({
|
|
|
appop: operid,
|
|
|
param: JSON.stringify(param)
|
|
|
}, true);
|
|
|
ev.addEventHandler(aDom[i], 'click', function(e) {
|
|
|
if (!window.originUrl) {
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
window.yohoInterface.triggerEvent(function(data){
|
|
|
appPageOpen(data, actionUrl);
|
|
|
}, nullFun, {
|
|
|
method: 'get.analyticAppData'
|
|
|
});
|
|
|
var target = e.currentTarget,
|
|
|
furl = target.getAttribute('href');
|
|
|
|
|
|
// 同步indx(需延迟处理)
|
|
|
var timer = setInterval(function() {
|
|
|
if (window._yasloaded) {
|
|
|
clearInterval(timer);
|
|
|
window.yohoInterface.triggerEvent(nullFun, nullFun, {
|
|
|
method: 'set.analyticEventIndex',
|
|
|
arguments: {
|
|
|
indx: window.indx
|
|
|
// 上报曝光事件
|
|
|
_yas.sendAppLogs({
|
|
|
appop: 'YB_H5_PAGE_FLR_C',
|
|
|
param: JSON.stringify({
|
|
|
C_ID: window.qs.yh_channel || util.getChannel() || 1,
|
|
|
PAGE_URL: window.originUrl,
|
|
|
PAGE_NAME: decodeURI(window.qs.title || document.title),
|
|
|
F_URL: furl
|
|
|
})
|
|
|
}, true);
|
|
|
|
|
|
if ('feature.yoho.cn' === document.domain) { // feature.yoho.cn场合
|
|
|
var operid = target.getAttribute('operid');
|
|
|
if (operid) {
|
|
|
var param = target.getAttribute('param');
|
|
|
|
|
|
param = JSON.parse(param);
|
|
|
param.C_ID = window.qs.yh_channel;
|
|
|
param.F_URL = furl;
|
|
|
|
|
|
// 上报点击事件
|
|
|
_yas.sendAppLogs({
|
|
|
appop: operid,
|
|
|
param: JSON.stringify(param)
|
|
|
}, true);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
}, 500);
|
|
|
|
|
|
});
|
|
|
window.yohoInterface.triggerEvent(function(data) {
|
|
|
appPageOpen(data, actionUrl);
|
|
|
}, nullFun, {
|
|
|
method: 'get.analyticAppData'
|
|
|
});
|
|
|
|
|
|
// 同步indx(需延迟处理)
|
|
|
var timer = setInterval(function() {
|
|
|
if (window._yasloaded) {
|
|
|
clearInterval(timer);
|
|
|
window.yohoInterface.triggerEvent(nullFun, nullFun, {
|
|
|
method: 'set.analyticEventIndex',
|
|
|
arguments: {
|
|
|
indx: window.indx
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
}, 500);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
module.exports = _yas; |
|
|
\ No newline at end of file |
...
|
...
|
|