Authored by unknown

Merge branch 'develop' of http://git.dev.yoho.cn/web/yohobuy into develop

... ... @@ -36,7 +36,7 @@
<span id="login-btn" class="login-btn btn">登录</span>
</li>
<li class="other-opts">
<span class="remeber-me">
<span class="remember-me">
<i class="iconfont">&#xe613;</i>
记住登录状态
</span>
... ...
... ... @@ -84,7 +84,7 @@
{{# subnav}}
<li class="sub-nav-item">
<a href="{{link}}">{{name}} {{#is_new}}<span class="newlogo"></span>{{/is_new}}</a>
{{# thirdnav}}
{{#if thirdnav}}
<div class="third-nav-wrapper">
<div class="third-nav">
<div class="categorywrapper" id="category{{../index_main}}{{index_sub}}">
... ... @@ -110,7 +110,7 @@
</div>
</div>
</div>
{{/thirdnav}}
{{/if}}
</li>
{{/ subnav}}
</ul>
... ...
... ... @@ -7,7 +7,7 @@ var $ = require('yoho.jquery');
require('./footer');
require('./simple-header');
require('./header');
function cookie(name) {
var cookies = document.cookie,
... ... @@ -108,7 +108,7 @@ function getShoppingKey() {
a.async = 1;
a.src = j;
m.parentNode.insertBefore(a, m);
})(window, document, 'script', 'http://cdn.yoho.cn/yas-jssdk/1.0.13.6.3/yas.js', '_yas');
})(window, document, 'script', 'http://cdn.yoho.cn/yas-jssdk/1.0.14/yas.js', '_yas');
(function() {
var uid = getUid();
... ... @@ -118,7 +118,7 @@ function getShoppingKey() {
window._ozuid = uid;//暴露ozuid
if (window._yas) {
window._yas(1 * new Date(), '1.0.13.6.3', 'yohobuy_web', uid, '', '');
window._yas(1 * new Date(), '1.0.14', 'yohobuy_web', uid, '', '');
}
}());
... ... @@ -130,4 +130,6 @@ window.getUser = getUser;
window.getUid = getUid;
window.getShoppingKey = getShoppingKey;
\ No newline at end of file
window.getShoppingKey = getShoppingKey;
require('./header');
... ...
... ... @@ -6,11 +6,238 @@
var $ = require('yoho.jquery');
var handlebars = require('yoho.handlebars');
var json2 = require('json2');
var noticeSuccess = false;
var vipInfoCombine = null;
var loginInfoCombine = null;
var apiDomain = 'http://api.open.yohobuy.com';
var cartTpl = '';
var vipInfoCombine = null; //用户信息编译模板
var loginInfoCombine = null; //登录信息编译模板
var apiDomain = 'http://api.open.yohobuy.com'; //获取数据的地址
var cartTpl = ''; //购物车模板
/**
* 搜寻的时候过滤非法字符(+-/:等非法字符单独出现)
* @type {RegExp}
*/
var reg = /^[\^\!\+\-\(\)\:\[\]\\\{\}\~\*\?\|\&\;\/\s]{0,}$/g;
var keyword = '';
var link = '';
var dataLayer = [];
var requestFrame = null;
var logoanimationstart = 0;
var $logotrans = $('.icon-logo');
var isen = true;
var loopdurationtime = 500;
var globaltimeout;
var onetimeoout;
/**
* banner和地址的映射
* @type {Object}
*/
var bannerMap = {
listboys: '4f78b0f418fc42314d8b6e791cfb7fa8',
listgirls: '00c1f025a51b6b597dc37925951ea27d',
listkids: 'b02df11184727701ade1b6de9737d08c',
listlifestyle: 'fd35c52dced0c880976ba858346d1fc5',
searchboys: '9fb8986ea700cc27a8057361c3924394',
searchgirls: 'e3e207a1443ca60c8037fe52a5560c18',
searchkids: '620fc77f479da8feaeb06f2324e5d0bb',
searchlifestyle: 'a3c93301c6ffaf3ed0f36a4a451be36d',
uniquebrandboys: '2ebb0810c0d1a67e5229149c9c3aba7d',
uniquebrandgirls: '99e23385f4ba4b65f406b7e2968ac821',
uniquebrandkids: 'a74ebc9b17840c91b9ea46568111fe6b',
uniquebrandlifestyle: '0e8c81ead53f56302baa4d0ad967f527',
brandsboys: '77b352db07129c76a9d532acad149f9f',
brandsgirls: 'bf047f16e52ebc38be5ce9c7623831e6',
brandskids: 'e3ae1ce9b5e13c6d271ef3eccb831652',
brandslifestyle: 'e4ac8029c30f65d7f1af030980d140fe',
newboys: '869d3c5f3b450fb52101d00a61ce87cb',
newgirls: 'd953b6dfdac02483d1dcce8d96055954',
newkids: '0874cb6d75df8e0e78f2d475e53ecc08',
newlifestyle: '43e8fc8e178115c262bbce2bd0012db7',
saleboys: 'c846e3165c994769b4201d8c32f3ae9b',
salegirls: '52b1d389edcbc62d65de71b80c4d6ad0',
salekids: 'ad8b1703c761ba00973868ab5199cc27',
salelifestyle: '7acc64905c70ac91846f43fb2cec4bbd',
homeboys: 'b0856a771ef1b59ab1234c74688fa42d',
homegirls: '2bd61fa12e4933211518f70fe5ce3c48',
homekids: '895c59e8c64b40399c9533509507320c',
homelifestyle: '2e037d4e25d2767352ca3e0a4627f7bd',
indexboys: '0c911d3000f52e8ca7cffb74f5864c29',
indexgirls: 'b645b8980c423ab30485e0a9d08c2ef7',
indexkids: '17f6d5d5d454d2c507bc5fcbc90f7756',
indexlifestyle: '735cd393e841762af8793c346abbbc36'
};
var cookieMap = {};
function getSource(column, postition, event) {
try {
dataLayer.push({
louceng: column,
weizhi: postition,
event: event
});
} catch (e) {}
}
function submitSearch() {
var $keywordinput = $('#query_key').val();
var column = 'Search';
var postition = 'Head Search';
var event = 'Search';
var $formatkeyword,
$formatkeywordinput;
$formatkeyword = $.trim(keyword.toLowerCase());
$formatkeywordinput = $.trim($keywordinput.toLowerCase());
getSource(column, postition, event);
if (link !== '' && keyword !== '' && $formatkeyword === $formatkeywordinput) {
location.href = link.replace('\'', '');
} else {
if (reg.test($keywordinput)) {
location.href = 'http://search.yohobuy.com/error?query=' + $keywordinput + '&result=error';
} else {
$('#searchForm').submit();
return false;
}
}
}
/**
* 定义购物车扩展
*/
function actionGoodsCart() {
var defaults = {
cookie: '_g',
cartNum: ''
};
var params = '';
var cartInfo = '';
var queryNum = 0;
var listIndex = 0;
var tmpList = 0;
var totalNum = 0;
var text = '';
$.fn.miniCart = function(options) {
params = $.extend(defaults, options);
if (typeof window.cookie(params.cookie) === 'undefined') {
cartInfo = null;
} else {
cartInfo = json2.parse(window.cookie(params.cookie));
}
if (cartInfo != null) {
totalNum = parseInt(cartInfo._nac) + parseInt(cartInfo._ac);
if (totalNum === 0) {
$('#icart-num').attr('class', 'icart-num icart-none');
} else {
$('#icart-num').attr('class', 'icart-num');
}
$(params.cartNum).html(totalNum);
}
};
$.fn.search = function(searchDomain) {
function getKeywords(obj) {
var key = $.trim($(obj).val());
key = key.replace(new RegExp('\'', 'gm'), ''); //去掉特殊字符
if (key === '') {
$('.search-list').hide();
return false;
}
key = encodeURI(key);
$.get(searchDomain + '?callback=?&query=' + key, function(htmlData) {
$('.search-list').html(htmlData.data);
queryNum = $('.search-list').children('li').length;
listIndex = -1;
if (queryNum > 0) {
$('.search-list').show();
} else {
$('.search-list').hide();
}
$('.search-list').find('a').hover(function() {
$(this).css('background-color', '#eee');
}, function() {
$(this).css('background-color', '#fff');
});
}, 'jsonp');
}
function getText(obj) {
$('.search-list li:eq(' + tmpList + ')').children('a').css('background-color', '#fff');
$('.search-list li:eq(' + listIndex + ')').children('a').css('background-color', '#eee');
text = $('.search-list li:eq(' + listIndex + ')').children('a').attr('title');
$('#query_key').val(text);
}
return this.each(function() {
$(this).keyup(function(event) {
if (event.which === 38) {
if (queryNum === 0) {
return false;
}
if (listIndex === -1) {
listIndex = 0;
}
tmpList = listIndex;
listIndex = (listIndex - 1 + queryNum) % queryNum;
getText(this);
} else if (event.which === 40) {
if (queryNum === 0) {
return false;
}
tmpList = listIndex;
listIndex = (listIndex + 1) % queryNum;
getText(this);
} else if (event.which === 13) {
submitSearch();
} else {
getKeywords(this);
}
});
});
};
$.extend({
getData: function(domain, options, onSuccess) {
var defaults = {
page: 1,
method: '',
v: 1,
return_type: 'jsonp',
open_key: '12345',
tmp: Math.random()
};
var params = '';
if (typeof (domain) === undefined || domain === '') {
console.log('请设置请求的api地址');
return false;
}
params = $.extend(defaults, options);
params.page = params.page || 1;
if (params.method === '') {
console.log('请设置请求的URL');
return false;
}
try {
$.getJSON(domain + '/?callback=?', params, function(_data) {
if (onSuccess !== '') {
if (typeof onSuccess(_data.data) !== 'undefined') {
json2.parse(onSuccess(_data.data));
}
return false;
}
});
} catch (e) {
console.log(e.message);
}
},
getShoppingKey: function() {
var shoppingInfo = window.cookie('_g');
var shoppingData = json2.parse(shoppingInfo);
if (typeof shoppingInfo === 'undefined' || shoppingInfo === null) {
return '';
}
return shoppingData._k;
}
});
}
/**
* 判断为1的helper
* @param {[type]} v1 [description]
... ... @@ -56,8 +283,7 @@ handlebars.registerHelper('equalzero', function(v1, options) {
return options.inverse(this);
}
});
require('../plugin/yohocookie');
require('../plugin/yohocart');
/**
* 获取头部banner的回调函数
* @param {[type]} data [description]
... ... @@ -75,42 +301,9 @@ function JsonPCallBack(data) {
}
}
/**
* 获取头部服务器维护的回调
* @param {[type]} data [description]
*/
function NoticeCallBack(data) {
if (+data.code === 200) {
noticeSuccess = true;
}
}
window.JsonPCallBack = JsonPCallBack;
window.NoticeCallBack = NoticeCallBack;
/**
* 检测是否获得公告
* @return {[type]} [description]
*/
function checkNotice() {
var noticeinner;
if (!noticeSuccess) {
noticeinner = '<div class="noticewrapper">' +
'<div class="noticecontainer">' +
'<h1 class="noticetitle">关于系统升级的公告</h1>' +
'<div class="noticecontent">' +
'<p class="tips">尊敬的顾客:</p>' +
'<p class="detail">您好!为了向您提供更优质的服务,目前系统正在升级,请耐心等待。</p>' +
'<p class="detail">' +
'系统升级期间,部分地区用户体验会有暂时中断,如遇紧急事宜,欢迎垂询客服热线:400-889-9646 09:00-22:30(周一至周日)。稍后系统将恢复正常' +
'</p>' +
'<p class="detail">使用,欢迎您继续光顾YOHO!BUY有货!带来不便之处深表歉意,请您谅解!</p>' +
'</div>' +
'</div>' +
'</div>';
$('.header-topwrapper').append(noticeinner);
}
}
/**
* 获得banner数据
* @param {[string]} code [banner对应的编码]
... ... @@ -119,23 +312,11 @@ function checkNotice() {
function getBannerData(code) {
var script = document.createElement('script');
script.src = 'http://new.yohobuy.com/resource/getbanner?content_code=' +
script.src = 'http://www.yohobuy.com/common/getbanner?content_code=' +
code + '&client_type=web&callback=JsonPCallBack';
document.getElementsByTagName('head')[0].appendChild(script);
}
/**
* 获取公告的jsonp请求
* @param {[type]} code [description]
* @return {[type]} [description]
*/
function getNoticeData(code) {
var script = document.createElement('script');
script.src = 'http://new.yohobuy.com/resource/getbanner?content_code=' +
code + '&client_type=web&callback=NoticeCallBack';
document.getElementsByTagName('head')[0].appendChild(script);
window.setTimeout(checkNotice, 5000); //5s后检测是否成功
}
/**
* 显示和隐藏
* @param {[type]} sourceClass [description]
... ... @@ -221,7 +402,7 @@ function isSupportCss3Animation() {
* @param {Array} ) { var thisFunc, prefixList [description]
* @return {[type]} [description]
*/
function requestFrameCloser() {
function requestFrameAct() {
var prefixList = ['webkit', 'moz', 'ms'];
var func1 = prefixList[0] + 'RequestAnimationFrame';
var func2 = prefixList[1] + 'RequestAnimationFrame';
... ... @@ -229,7 +410,7 @@ function requestFrameCloser() {
if (window[func1]) {
return function(callback) {
window[func1](callback);
requestAnimationFrame(callback);
};
}
if (window[func2]) {
... ... @@ -248,69 +429,61 @@ function requestFrameCloser() {
}
window.requestFrame = requestFrameCloser();
window.start = 0;
window.$logotrans = $('.icon-logo');
window.isen = true;
/**
* css3动画
* @return {[type]} [description]
*/
function tsAnimate() {
window.start += 10;
window.$logotrans.css({
transform: 'rotateX(' + window.start + 'deg)',
'-webkit-transform': 'rotateX(' + window.start + 'deg)',
'-moz-transform': 'rotateX(' + window.start + 'deg)'
logoanimationstart += 10;
$logotrans.css({
transform: 'rotateX(' + logoanimationstart + 'deg)',
'-webkit-transform': 'rotateX(' + logoanimationstart + 'deg)',
'-moz-transform': 'rotateX(' + logoanimationstart + 'deg)'
});
if (window.start / 90 % 2 === 1) {
if (window.isen) {
window.$logotrans.css('background-image', 'url(http://static.yohobuy.com/newheader/img/logo1.png)');
window.isen = false;
if (logoanimationstart / 90 % 2 === 1) {
if (isen) {
$logotrans.css('background-image', 'url(http://static.yohobuy.com/newheader/img/logo1.png)');
isen = false;
} else {
window.$logotrans.css('background-image', 'url(http://static.yohobuy.com/newheader/img/logo_e.png)');
window.isen = true;
$logotrans.css('background-image', 'url(http://static.yohobuy.com/newheader/img/logo_e.png)');
isen = true;
}
}
if (window.start / 90 % 2 === 0 && window.start % 360 !== 0) {
if (logoanimationstart / 90 % 2 === 0 && logoanimationstart % 360 !== 0) {
window.setTimeout(tsAnimate, 3000);
} else {
if (window.start % 360 === 0) {
if (logoanimationstart % 360 === 0) {
window.setTimeout(tsAnimate, 1 * 60 * 1000);
} else {
window.requestFrame(function() {
requestFrame(function() {
tsAnimate();
});
}
}
}
window.loopdurationtime = 500;
window.globaltimeout;
window.onetimeoout;
/**
* 淡出
* @return {[type]} [description]
*/
function fadeAnimate() {
if (window.globaltimeout) {
window.clearTimeout(window.globaltimeout);
if (globaltimeout) {
window.clearTimeout(globaltimeout);
}
window.$logotrans.fadeOut(window.loopdurationtime, function() {
window.isen = false;
window.$logotrans.css('background-image', 'url(http://static.yohobuy.com/newheader/img/logo.png)');
window.$logotrans.fadeIn(window.loopdurationtime, function() {
window.onetimeoout = window.setTimeout(function() {
window.$logotrans.fadeOut(window.loopdurationtime, function() {
window.clearTimeout(window.onetimeoout);
window.isen = true;
window.$logotrans.css('background-image',
$logotrans.fadeOut(loopdurationtime, function() {
isen = false;
$logotrans.css('background-image', 'url(http://static.yohobuy.com/newheader/img/logo.png)');
$logotrans.fadeIn(loopdurationtime, function() {
onetimeoout = window.setTimeout(function() {
$logotrans.fadeOut(loopdurationtime, function() {
window.clearTimeout(onetimeoout);
isen = true;
$logotrans.css('background-image',
'url(http://static.yohobuy.com/newheader/img/logo_e.png)');
window.$logotrans.fadeIn(window.loopdurationtime, function() {
window.globaltimeout = window.setTimeout(fadeAnimate, 1 * 60 * 1000);
$logotrans.fadeIn(loopdurationtime, function() {
globaltimeout = window.setTimeout(fadeAnimate, 1 * 60 * 1000);
});
});
}, 3000);
... ... @@ -323,6 +496,7 @@ function fadeAnimate() {
*/
function actionTopLogoAnimate() {
if (isSupportCss3Animation()) {
requestFrame = requestFrameAct();
window.setTimeout(tsAnimate, 3000);
} else {
window.setTimeout(fadeAnimate, 3000);
... ... @@ -355,134 +529,56 @@ function actionAddKeyWords() {
});
}
}
window.dataLayer = [];
function getSource(column, postition, event) {
try {
window.dataLayer.push({
louceng: column,
weizhi: postition,
event: event
});
} catch (e) {}
}
/**
* 搜寻的时候过滤非法字符(+-/:等非法字符单独出现)
* @type {RegExp}
*/
window.reg = /^[\^\!\+\-\(\)\:\[\]\\\{\}\~\*\?\|\&\;\/\s]{0,}$/g;
window.keyword = '';
window.link = '';
window.submitSearch = function() {
var $keywordinput = $('#query_key').val();
var column = 'Search';
var postition = 'Head Search';
var event = 'Search';
var $formatkeyword,
$formatkeywordinput;
$formatkeyword = $.trim(window.keyword.toLowerCase());
$formatkeywordinput = $.trim($keywordinput.toLowerCase());
getSource(column, postition, event);
if (window.link !== '' && window.keyword !== '' && $formatkeyword === $formatkeywordinput) {
location.href = window.link.replace('\'', '');
} else {
if (window.reg.test($keywordinput)) {
location.href = 'http://search.yohobuy.com/error?query=' + $keywordinput + '&result=error';
} else {
$('#searchForm').submit();
return false;
}
}
};
/**
* banner和地址的映射
* @type {Object}
*/
window.bannerMap = {
listboys: '4f78b0f418fc42314d8b6e791cfb7fa8',
listgirls: '00c1f025a51b6b597dc37925951ea27d',
listkids: 'b02df11184727701ade1b6de9737d08c',
listlifestyle: 'fd35c52dced0c880976ba858346d1fc5',
searchboys: '9fb8986ea700cc27a8057361c3924394',
searchgirls: 'e3e207a1443ca60c8037fe52a5560c18',
searchkids: '620fc77f479da8feaeb06f2324e5d0bb',
searchlifestyle: 'a3c93301c6ffaf3ed0f36a4a451be36d',
uniquebrandboys: '2ebb0810c0d1a67e5229149c9c3aba7d',
uniquebrandgirls: '99e23385f4ba4b65f406b7e2968ac821',
uniquebrandkids: 'a74ebc9b17840c91b9ea46568111fe6b',
uniquebrandlifestyle: '0e8c81ead53f56302baa4d0ad967f527',
brandsboys: '77b352db07129c76a9d532acad149f9f',
brandsgirls: 'bf047f16e52ebc38be5ce9c7623831e6',
brandskids: 'e3ae1ce9b5e13c6d271ef3eccb831652',
brandslifestyle: 'e4ac8029c30f65d7f1af030980d140fe',
newboys: '869d3c5f3b450fb52101d00a61ce87cb',
newgirls: 'd953b6dfdac02483d1dcce8d96055954',
newkids: '0874cb6d75df8e0e78f2d475e53ecc08',
newlifestyle: '43e8fc8e178115c262bbce2bd0012db7',
saleboys: 'c846e3165c994769b4201d8c32f3ae9b',
salegirls: '52b1d389edcbc62d65de71b80c4d6ad0',
salekids: 'ad8b1703c761ba00973868ab5199cc27',
salelifestyle: '7acc64905c70ac91846f43fb2cec4bbd',
homeboys: 'b0856a771ef1b59ab1234c74688fa42d',
homegirls: '2bd61fa12e4933211518f70fe5ce3c48',
homekids: '895c59e8c64b40399c9533509507320c',
homelifestyle: '2e037d4e25d2767352ca3e0a4627f7bd',
indexboys: '0c911d3000f52e8ca7cffb74f5864c29',
indexgirls: 'b645b8980c423ab30485e0a9d08c2ef7',
indexkids: '17f6d5d5d454d2c507bc5fcbc90f7756',
indexlifestyle: '735cd393e841762af8793c346abbbc36'
};
/**
* cookie 初始化
* @return {[type]} [description]
*/
function actionInitCookie() {
var $cookieGender = $.cookie('_Gender');
var $cookieGender = window.cookie('_Gender');
var $target = $('.cure');
if (typeof $cookieGender !== 'undefined' && $cookieGender !== '') {
$.setcookie('_Gender', 1, {
window.setCookie('_Gender', 1, {
path: '/',
domain: '.yohobuy.com',
expires: 7
});
}
if ($target.find('.name-cn a').text() === '男生') {
$.setcookie('_Gender', '1,3', {
window.setCookie('_Gender', '1,3', {
path: '/',
domain: '.yohobuy.com',
expires: 7
});
$.setcookie('_Channel', 'boys', {
window.setCookie('_Channel', 'boys', {
path: '/',
domain: '.yohobuy.com',
expires: 7
});
}
if ($target.find('.name-cn a').text() === '女生') {
$.setcookie('_Gender', '2,3', {
window.setCookie('_Gender', '2,3', {
path: '/',
domain: '.yohobuy.com',
expires: 7
});
$.setcookie('_Channel', 'girls', {
window.setCookie('_Channel', 'girls', {
path: '/',
domain: '.yohobuy.com',
expires: 7
});
}
if ($target.find('.name-cn a').text() === '创意生活') {
$.setcookie('_Channel', 'lifestyle', {
window.setCookie('_Channel', 'lifestyle', {
path: '/',
domain: '.yohobuy.com',
expires: 7
});
}
if ($target.find('.name-cn a').text() === '潮童') {
$.setcookie('_Channel', 'kids', {
window.setCookie('_Channel', 'kids', {
path: '/',
domain: '.yohobuy.com',
expires: 7
... ... @@ -494,8 +590,6 @@ function actionInitCookie() {
* cookie集合
* @type {Object}
*/
window.cookieMap = {};
function actionExeCookieMap() {
var cookies = document.cookie;
var cookiearr = cookies.split(';');
... ... @@ -505,8 +599,10 @@ function actionExeCookieMap() {
for (i = 0; i < cookiearr.length; i++) {
temparr = cookiearr[i].split('=');
key = temparr[0].replace(/\s/g, '');
window.cookieMap[key] = temparr[1];
if (typeof temparr[0] !== 'undefined') {
key = temparr[0].replace(/\s/g, '');
cookieMap[key] = temparr[1];
}
}
}
/**
... ... @@ -517,47 +613,47 @@ function actionFirstMenuClick() {
var $cookieGender;
$('.first-nav-item').click(function() {
$cookieGender = $.cookie('_Gender');
$cookieGender = window.cookie('_Gender');
if (typeof $cookieGender !== 'undefined' && $cookieGender !== '') {
$.setcookie('_Gender', 1, {
window.setCookie('_Gender', 1, {
path: '/',
domain: '.yohobuy.com',
expires: 7
});
}
if ($(this).find('.name-cn a').text() === '男生') {
$.setcookie('_Gender', '1,3', {
window.setCookie('_Gender', '1,3', {
path: '/',
domain: '.yohobuy.com',
expires: 7
});
$.setcookie('_Channel', 'boys', {
window.setCookie('_Channel', 'boys', {
path: '/',
domain: '.yohobuy.com',
expires: 7
});
}
if ($(this).find('.name-cn a').text() === '女生') {
$.setcookie('_Gender', '2,3', {
window.setCookie('_Gender', '2,3', {
path: '/',
domain: '.yohobuy.com',
expires: 7
});
$.setcookie('_Channel', 'girls', {
window.setCookie('_Channel', 'girls', {
path: '/',
domain: '.yohobuy.com',
expires: 7
});
}
if ($(this).find('.name-cn a').text() === '创意生活') {
$.setcookie('_Channel', 'lifestyle', {
window.setCookie('_Channel', 'lifestyle', {
path: '/',
domain: '.yohobuy.com',
expires: 7
});
}
if ($(this).find('.name-cn a').text() === '潮童') {
$.setcookie('_Channel', 'kids', {
window.setCookie('_Channel', 'kids', {
path: '/',
domain: '.yohobuy.com',
expires: 7
... ... @@ -566,7 +662,7 @@ function actionFirstMenuClick() {
});
$('#backToOld').click(function() {
$.setcookie('_New', 1, {
window.setCookie('_New', 1, {
path: '/',
domain: '.yohobuy.com'
});
... ... @@ -597,10 +693,10 @@ function loadCartData() {
method: 'open.Shoppingcart.getCartData',
shopping_key: $.getShoppingKey()
}, function(jsonData) {
if (window.cartTpl === '') {
window.cartTpl = handlebars.compile($('#mini-cart-tpl').html());
if (cartTpl === '') {
cartTpl = handlebars.compile($('#mini-cart-tpl').html());
}
$('#miniCartBox').children('.gobuy-wrapper').html(window.cartTpl({
$('#miniCartBox').children('.gobuy-wrapper').html(cartTpl({
carData: jsonData
}));
if (parseInt($('.ic-infomation').html()) === 0) {
... ... @@ -608,11 +704,11 @@ function loadCartData() {
'<h3 class="information">您的购物车暂无商品</h3></div>');
}
if ($('#miniCartBox .goods-list li').length < 1) {
shoppingInfo = $.cookie('_g');
shoppingInfo = window.cookie('_g');
shoppingData = json2.parse(shoppingInfo);
if (shoppingData !== null) {
strK = '{"_k":"' + shoppingData._k + '","_nac":0' + ',"_ac":0,"_r":0}';
$.setcookie('_g', strK, {
window.setCookie('_g', strK, {
path: '/',
domain: '.yohobuy.com'
});
... ... @@ -636,11 +732,11 @@ function delCartGoods(id, isreduce) {
id: id,
isreduce: isreduce
}, function(jsonData) {
var shoppingInfo = $.cookie('_g');
var shoppingInfo = window.cookie('_g');
var shoppingData = json2.parse(shoppingInfo);
var strK = '{"_k":"' + shoppingData._k + '","_nac":' + jsonData.total_goods_num + ',"_ac":0,"_r":0}';
$.setcookie('_g', strK, {
window.setCookie('_g', strK, {
path: '/',
domain: '.yohobuy.com'
});
... ... @@ -752,43 +848,42 @@ function actionGetBannerAndNotice() {
var firstarea;
if (url.indexOf('search') !== -1) {
code = window.bannerMap['search' + window.cookieMap._Channel];
code = bannerMap['search' + cookieMap._Channel];
}
if (url.indexOf('list') !== -1) {
code = window.bannerMap['list' + window.cookieMap._Channel];
code = bannerMap['list' + cookieMap._Channel];
}
if (url.indexOf('brands') !== -1) {
code = window.bannerMap['brands' + window.cookieMap._Channel];
code = bannerMap['brands' + cookieMap._Channel];
}
if (url.indexOf('new') !== -1) {
code = window.bannerMap['new' + window.cookieMap._Channel];
code = bannerMap['new' + cookieMap._Channel];
}
if (url.indexOf('sale') !== -1) {
code = window.bannerMap['sale' + window.cookieMap._Channel];
code = bannerMap['sale' + cookieMap._Channel];
}
if (url.indexOf('home') !== -1) {
code = window.bannerMap['home' + window.cookieMap._Channel];
code = bannerMap['home' + cookieMap._Channel];
}
if (url.indexOf('kids') !== -1) {
code = window.bannerMap[INDEXKIDS];
code = bannerMap[INDEXKIDS];
}
if (url.indexOf('woman') !== -1) {
code = window.bannerMap[INDEXWOMAN];
code = bannerMap[INDEXWOMAN];
}
if (url.indexOf('lifestyle') !== -1) {
code = window.bannerMap[INDEXLIFESTYLE];
code = bannerMap[INDEXLIFESTYLE];
}
if (url.indexOf('www.yohobuy.com') !== -1 && window.location.pathname === '/') {
code = window.bannerMap[INDEXBOYS];
code = bannerMap[INDEXBOYS];
}
firstarea = host.split('.')[0];
if (firstarea !== 'list' && firstarea !== 'search' && firstarea !== 'www' &&
firstarea !== 'new' && firstarea !== 'item' && firstarea !== 'guang') {
code = window.bannerMap[UNIQUEBRAND + window.cookieMap._Channel];
code = bannerMap[UNIQUEBRAND + cookieMap._Channel];
}
getBannerData(code); //获得banner信息
getNoticeData(code); //获得公告信息
}
... ... @@ -879,12 +974,12 @@ function actionLoginState(_data) {
'[<a href="http://www.yohobuy.com/reg.html" onclick="" class="list-a login-out">免费注册</a>]' +
'{{/equalone}}';
var $boxObj = $('#loginBox');
var info = $.cookie('_UID')||'';
var name = _data.data.profile_name||'';
var info = window.cookie('_UID');
var name = _data.data.profile_name;
var _length = 0;
var t = 0;
var char = '';
var user = info.split('::')||'';
var user = info.split('::');
var userName = user[0] || ' ';
var _logout = '';
var islogin = '1';
... ... @@ -999,8 +1094,10 @@ function actionLoginInfo() {
};
$.getData(apiDomain, param, function(_data) {
actionLoginState(_data); // 更改登录状态
actionVipInfo(_data); //获得vip;
if (_data.result !== -1) {
actionLoginState(_data); // 更改登录状态
actionVipInfo(_data); //获得vip;
}
});
}
/**
... ... @@ -1011,6 +1108,7 @@ function init() {
actionExeTemplate(); //处理模板
actionInitCookie(); //初始化cookie
actionExeCookieMap(); //格式化cookie
actionGoodsCart(); //初始化购物车插件
actionYoHoGroup(); // yoho集团鼠标效果
actionTopTagToggle(); // yoho上部分开关
actionTopLogoAnimate(); //yoho logo动画
... ...
... ... @@ -25,6 +25,8 @@ var $emailAutoComplete = $('#email-autocomplete');
var mailPhoneRegx = require('./mail-phone-regx');
var $remember = $('.remember-me');
//checkbox status unicode
var checkbox = {
checked: '&#xe612;',
... ... @@ -232,7 +234,7 @@ $emailAutoComplete.on('click', 'li', function() {
});
//记住登录状态
$('.remeber-me').on('click', function() {
$remember.on('click', function() {
var $this = $(this);
$this.toggleClass('checked');
... ... @@ -266,15 +268,19 @@ $('#login-btn').on('click', function() {
data: {
areaCode: $countryCodeHide.val().replace('+', ''),
account: $.trim($account.val()),
password: $.trim($password.val())
password: $.trim($password.val()),
isRemember: $remember.hasClass('checked') ? true : false
},
success: function(data) {
if (data.code === 400) {
if (data.code === 200) {
if (data.data) {
//防止data.data为undefined时下行语句执行出错而导致脚本不能走到complete去处理authing
location.href = data.data.href;
}
} else {
$passwordTip.removeClass('hide').children('em').text(data.message);
$password.addClass('error');
return;
} else {
location.href = data.data.href;
}
},
complete: function() {
... ...
... ... @@ -60,7 +60,7 @@ $third: sprite-map("passport/third/*.png");
}
}
.remeber-me {
.remember-me {
cursor: pointer;
}
... ...