...
|
...
|
@@ -49,6 +49,7 @@ var appInfo = { |
|
|
var isApp = /yoho/i.test(navigator.userAgent) || /app_version=/i.test(window.location.search) || !!window.yohoInterface;
|
|
|
var isMobile = /(iPhone|Android|iPad|iPod|iOS)/i.test(navigator.userAgent);
|
|
|
var isWechat = /micromessenger/i.test(navigator.userAgent);
|
|
|
var isMiniProgram = window.__wxjs_environment === 'miniprogram';
|
|
|
var ismyhbuy = /m\.yohobuy\.com/i.test(document.domain);
|
|
|
var isfeature = /feature\.yoho\.cn/i.test(document.domain) || /activity\.yoho\.cn/i.test(document.domain);
|
|
|
var downloadBlackLst = ['m.yohobuy.com/brands', 'm.yohobuy.com/passport'];
|
...
|
...
|
@@ -66,7 +67,7 @@ var custInfo = { |
|
|
ckf: VisitorId.isNew
|
|
|
};
|
|
|
|
|
|
//TODO:用户操作信息
|
|
|
//TODO:用户操作信息
|
|
|
var custOpInfo = {
|
|
|
mp: '', //mouse postion
|
|
|
ev: '', //event
|
...
|
...
|
@@ -90,7 +91,11 @@ var browserInfo = { |
|
|
// 空方法
|
|
|
var nullFun = function() {};
|
|
|
|
|
|
//入口方法
|
|
|
// 创建空的div,以后所有yas内容都注入该dom下
|
|
|
var yasDombar = document.createElement('div');
|
|
|
document.body.insertBefore(yasDombar, document.body.firstChild);
|
|
|
|
|
|
//入口方法
|
|
|
var _yas = function(initTime, version, tid, uid, geo, selector) {
|
|
|
window.qs = util.queryString();
|
|
|
|
...
|
...
|
@@ -152,6 +157,9 @@ var _yas = function(initTime, version, tid, uid, geo, selector) { |
|
|
});
|
|
|
}
|
|
|
|
|
|
// 进入小程序弹框
|
|
|
setMiniAppDialog();
|
|
|
|
|
|
// 设定页面下载条
|
|
|
setDownloadBar();
|
|
|
|
...
|
...
|
@@ -198,7 +206,7 @@ var _yas = function(initTime, version, tid, uid, geo, selector) { |
|
|
|
|
|
// onerror = handleErr;
|
|
|
// var txt = "";
|
|
|
//
|
|
|
//
|
|
|
// function handleErr(msg, url, l) {
|
|
|
// txt = "This page contains error! \n\n";
|
|
|
// txt += "Error message is:" + msg + "\n";
|
...
|
...
|
@@ -402,10 +410,10 @@ function setUnionType() { |
|
|
href += params.join('&');
|
|
|
} else {
|
|
|
var hrefArray = href.split('?');
|
|
|
href = href[0] + '?' + params.join('&') + href[1];
|
|
|
href = hrefArray[0] + '?' + params.join('&') + '&' + hrefArray[1];
|
|
|
}
|
|
|
|
|
|
aDom[i].setAttribute('href', href);
|
|
|
aDom[i].setAttribute('href', href);
|
|
|
}
|
|
|
|
|
|
ev.addEventHandler(aDom[i], 'click', function(e) {
|
...
|
...
|
@@ -421,6 +429,62 @@ function setUnionType() { |
|
|
}
|
|
|
}
|
|
|
|
|
|
// 进入小程序弹框
|
|
|
var miniAppToggle = function() {
|
|
|
var miniAppDialogBg = document.getElementById('mini-app-dialog-bg');
|
|
|
var miniAppDialog = document.getElementById('mini-app-dialog');
|
|
|
|
|
|
if (miniAppDialogBg && miniAppDialog) {
|
|
|
miniAppDialog.style.display = (miniAppDialog.style.display === 'block' ? 'none' : 'block');
|
|
|
miniAppDialogBg.style.display = miniAppDialog.style.display;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function setMiniAppDialog() {
|
|
|
if (!isWechat) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
// 设定fontsize
|
|
|
util.setFontSize();
|
|
|
|
|
|
var css = require('../css/wechat-mini-app.css');
|
|
|
|
|
|
var miniDom = document.createElement('div');
|
|
|
miniDom.innerHTML = util.getMiniAppDialog();
|
|
|
yasDombar.appendChild(miniDom);
|
|
|
|
|
|
var miniAppClose = document.getElementById('mini-app-close');
|
|
|
var miniAppImg = document.getElementById('mini-app-img');
|
|
|
var miniAppCodeTimer;
|
|
|
|
|
|
ev.addEventHandler(miniAppImg, 'touchstart', function(){
|
|
|
miniAppCodeTimer = setTimeout(function() {
|
|
|
if (_hmt && _hmt.push) {
|
|
|
_hmt.push(['_trackEvent', '小程序码', '长按超过1秒']);
|
|
|
}
|
|
|
}, 1000);
|
|
|
});
|
|
|
|
|
|
ev.addEventHandler(miniAppImg, 'touchend', function(){
|
|
|
clearTimeout(miniAppCodeTimer);
|
|
|
});
|
|
|
|
|
|
ev.addEventHandler(miniAppClose, 'click', function(){
|
|
|
if (_hmt && _hmt.push) {
|
|
|
_hmt.push(['_trackEvent', '打开小程序按钮', '关闭']);
|
|
|
}
|
|
|
miniAppToggle();
|
|
|
});
|
|
|
|
|
|
if ((document.getElementById('main-wrap').getAttribute('data-minipath') || '').indexOf('isOpen=true') > -1) {
|
|
|
if (_hmt && _hmt.push) {
|
|
|
_hmt.push(['_trackEvent', '打开小程序按钮', '自动打开']);
|
|
|
}
|
|
|
miniAppToggle();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function setDownloadBar() {
|
|
|
var nodownload = document.getElementById('no-download'); // 页面不需要下载条
|
|
|
var downBar = document.getElementById('top-downloadbar');
|
...
|
...
|
@@ -432,7 +496,7 @@ function setDownloadBar() { |
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (!isApp && (isMobile || isWechat) && (ismyhbuy || isfeature)) {
|
|
|
if (!isApp && !isMiniProgram && (isMobile || isWechat) && (ismyhbuy || isfeature)) {
|
|
|
downBar = document.getElementById('float-layer-app');
|
|
|
if (downBar) {
|
|
|
// 存在下载条时,删除
|
...
|
...
|
@@ -446,13 +510,15 @@ function setDownloadBar() { |
|
|
// 设定fontsize
|
|
|
util.setFontSize();
|
|
|
|
|
|
var css = require('../css/download.css')
|
|
|
var downloadDom = document.createElement("div");
|
|
|
var css = require('../css/download.css');
|
|
|
|
|
|
var downloadDom = document.createElement('div');
|
|
|
downloadDom.innerHTML = util.getDownloadStr(isWechat);
|
|
|
document.body.insertBefore(downloadDom, document.body.firstChild);
|
|
|
yasDombar.appendChild(downloadDom);
|
|
|
|
|
|
// bindevent
|
|
|
var closeDom = document.getElementById('download-close');
|
|
|
|
|
|
ev.addEventHandler(closeDom, 'click', function(){
|
|
|
cookies('_downloadBar', 'close', {
|
|
|
path: "/",
|
...
|
...
|
@@ -484,6 +550,14 @@ function setDownloadBar() { |
|
|
_hmt.push(['_trackEvent', '顶部下载条目', '微信里面关注']);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
var miniAppOpen = document.getElementById('mini-app-open');
|
|
|
ev.addEventHandler(miniAppOpen, 'click', function(){
|
|
|
if (_hmt && _hmt.push) {
|
|
|
_hmt.push(['_trackEvent', '打开小程序按钮', '打开']);
|
|
|
}
|
|
|
miniAppToggle();
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -613,11 +687,11 @@ _yas.sendAppLogs = function(json, asyncindx) { |
|
|
if (param.F_URL) {
|
|
|
param.F_URL = decodeURIComponent(param.F_URL);
|
|
|
}
|
|
|
|
|
|
|
|
|
// abtype
|
|
|
var ev = window.appBaseLogs.events[0];
|
|
|
if(ev.abtype) {
|
|
|
param.AB_TYPE = ev.abtype;
|
|
|
param.AB_TYPE = ev.abtype;
|
|
|
}
|
|
|
var event = util.merge(ev, {
|
|
|
ts: (new Date()).getTime().toString(),
|
...
|
...
|
@@ -685,7 +759,7 @@ function appPageOpen(data, actionUrl) { |
|
|
PAGE_NAME: decodeURI(window.qs.title || document.title),
|
|
|
ACTION_URL: actionUrl
|
|
|
})
|
|
|
}, false);
|
|
|
}, false);
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -695,7 +769,7 @@ if (navigator.userAgent.indexOf('YohoBuy-android-yas') > -1) { |
|
|
var data = window.prompt(JSON.stringify({
|
|
|
method: 'get.analyticAppData'
|
|
|
}));
|
|
|
|
|
|
|
|
|
appPageOpen(JSON.parse(data || '{}'));
|
|
|
} else {
|
|
|
// 监听app加载的deviceready事件
|
...
|
...
|
@@ -766,4 +840,4 @@ if (navigator.userAgent.indexOf('YohoBuy-android-yas') > -1) { |
|
|
});
|
|
|
}
|
|
|
|
|
|
module.exports = _yas; |
|
|
\ No newline at end of file |
|
|
module.exports = _yas; |
...
|
...
|
|