Authored by htoooth

Merge branch 'master' into feature/perf

... ... @@ -79,11 +79,12 @@
}
.top-downloadbar .download-go-wechat {
right: 3.425rem;
right: 4.7rem;
background: #000;
}
.top-downloadbar .download-wechat {
.top-downloadbar .download-wechat,
.top-downloadbar .mini-app-open {
position: absolute;
top: 50%;
-webkit-transform: translateY(-50%);
... ... @@ -97,4 +98,4 @@
background: red;
color: #fff;
text-decoration: none;
}
\ No newline at end of file
}
... ...
.mini-app-dialog-bg,
.mini-app-dialog {
display: none;
}
.mini-app-dialog-bg {
background-color: #000;
opacity: .3;
position: fixed;
width: 100%;
z-index: 9998;
height: 100%;
}
.mini-app-dialog {
text-align: center;
position: fixed;
z-index: 9999;
left: 50%;
top: 50%;
width: 12.5rem;
border-radius: 0.2rem;
background-color: #fff;
margin-left: -6.25rem;
margin-top: -6.8rem;
}
.mini-app-dialog div {
text-align: center;
}
.mini-app-dialog .mini-app-header {
height: 2rem;
line-height: 2rem;
}
.mini-app-dialog .mini-app-content {
padding: 0.625rem;
}
.mini-app-dialog .mini-app-content img {
width: 6.45rem;
height: 6.45rem;
}
.mini-app-dialog .mini-app-footer {
height: 3.65rem;
line-height: 3.65rem;
font-size: 0.7rem;
}
.mini-app-dialog .mini-app-close {
width: 0.75rem;
height: 0.75rem;
position: absolute;
right: 0.25rem;
top: 0.25rem;
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAmFJREFUeNrMl99OE0EUxrdL9bYYbWoEJajUP5ckXsM2IZJe0IQQqY9AGq0+QY0vUExs+gqQkCblAi0ktPckvUQoQoyihDbE6qWELN9pzjbr6O7MlK7xJB/Tdg/nN+fszOzZkG3bhszK5fIlDI+hKegRdAe6wpe/Q/vQFrQBradSqV+ymCE/MICDGF5AGeiaoWYnUAHKYwJtbTCgaQyLUMzozZpQFvAlJTCAAxjecJb9sCL0DBM48wQzlGY4Z/TXStATN9wUHBYDgJLNchX/zBjZznO2QdpT5553wLx6dy6wkFStBcVptTulzvpAJ3jfNhQCb0Mj0LTH9Sj0snOPke1lyQr+ihkeYExAexKoBd/P9D8+fhlimnwaRX0c38FxCAEpmOUBJ2gCPk34UsarPvGu0ilo8lHoZ2PQpgsuZv6BocfwuYXPVWhUErMDHle4d3GG3wDgkOEfGWq5oDUFKNm4yRkZPcCtHjLtVjGMPxGN7XCP4RbDaSveZOhtjTgRytjW3Iu24m++RuCfGv67XN4jZDoMXcfnL1z2A404P0zJ3hShlgPl8lZd8EkN+B6B67qZMvQudJ/vuS68TuCKxKnB0G8C1LEHDI9plL1icp/U8nFKuqCbAtQNrzKcjswZSWtUcZ5OOXx55eFI5aNM3ivseTo6k9BDaM3D5zUmlwvzF3pIL3g8oWoaq5WAnySPxXy3A+FuMGsEb8+dzrPb+uCHZQxvA4QW3B2n2HNRD70SALQkVvQ3MHeBaW7I+2VFscP8vxr6v7zCZLk1iv6TVxiFl7ZBvtwWXtoqAJ7KYp4LMACryxGMnWAbNgAAAABJRU5ErkJggg==");
background-size: cover;
}
... ...
{
"name": "yas-jssdk",
"version": "2.4.9",
"version": "2.4.15",
"description": "YOHO!采集系统的前端js的开发包",
"keywords": [
"YOHO!",
... ...
... ... @@ -183,6 +183,8 @@ exports.getChannel = function() {
// }
return {
men: 1,
women: 2,
boys: 1,
girls: 2,
kids: 3,
... ... @@ -264,20 +266,37 @@ exports.setFontSize = function() {
}
}
exports.getMiniAppDialog = function() {
var imgpath = '//cdn.yoho.cn/static/wechat/miniapp-yohobuy.jpg?imageView2/1/w/258/h/258&t=' + (new Date().getTime());
var minipath = document.getElementById('main-wrap').getAttribute('data-minipath') || imgpath;
var str = '<div class="mini-app-dialog-bg" id="mini-app-dialog-bg"></div>';
str += '<div class="mini-app-dialog" id="mini-app-dialog">';
str += '<div class="mini-app-header"><span class="mini-app-close" id="mini-app-close"></span></div>';
str += '<div class="mini-app-content"><img id="mini-app-img" src="' + minipath + '" onerror="this.src= \'' + imgpath + '\';this.onerror=null;" /></div>';
str += '<div class="mini-app-footer">长按识别小程序码进入有货精选</div>';
str += '</div>';
return str;
}
exports.getDownloadStr = function(isWechat) {
var str = '<div class="top-downloadbar';
if (isWechat) {
str += ' top-downloadbar-wechat';
}
str += '" id="top-downloadbar"><a href="javascript:void(0);" class="download-close" id="download-close"></a>\
<span class="download-icon"></span><span class="download-text">Yoho!Buy有货</span>';
if (isWechat) {
str += '<a class="download-go-wechat" id="download-go" href="https://union.yoho.cn/union/app-downloads.html">立即打开</a>';
str += '<a class="download-wechat" id="download-wechat" href="https://mp.weixin.qq.com/mp/profile_ext?action=home&__biz=MjM5ODI5MDA4MA==&scene=110#wechat_redirect">加关注</a></div>';
str += '<a class="mini-app-open" id="mini-app-open" href="javascript:;">进入小程序</a>';
// str += '<a class="download-wechat" id="download-wechat" href="https://mp.weixin.qq.com/mp/profile_ext?action=home&__biz=MjM5ODI5MDA4MA==&scene=110#wechat_redirect">加关注</a></div>';
} else {
str += '<p class="download-text-desc">新用户送惊喜礼包</p>';
str += '<a class="download-go" id="download-go" href="https://union.yoho.cn/union/app-downloads.html">立即打开</a></div>';
}
return str;
}
... ...
... ... @@ -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;
... ...