Authored by Rock Zhang

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

Showing 37 changed files with 1217 additions and 1051 deletions
... ... @@ -829,7 +829,6 @@
},
...
],**/
colors: [
{
color:[//说明:第一行,其colorNum的值为其下所有尺码数量之和,不需要sizeNumStr的值.
... ... @@ -864,7 +863,6 @@
]
}
],
sizes: [
{
size:[//说明:第一行,显示所有的尺寸,即为下面的defaultSizes,不需要numStr的值
... ...
... ... @@ -209,7 +209,7 @@ function reMarginFooter(fixedElement) {
a.async = 1;
a.src = j;
m.parentNode.insertBefore(a, m);
})(window, document, 'script', 'http://cdn.yoho.cn/yas-jssdk/1.0.14/yas-debug.js', '_yas');
})(window, document, 'script', 'http://cdn.yoho.cn/yas-jssdk/1.0.14/yas.js', '_yas');
(function() {
var uid = getUid();
... ...
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
... ... @@ -191,7 +191,7 @@ function reMarginFooter(fixedElement) {
a.async = 1;
a.src = j;
m.parentNode.insertBefore(a, m);
})(window, document, 'script', 'http://cdn.yoho.cn/yas-jssdk/1.0.14/yas-debug.js', '_yas');
})(window, document, 'script', 'http://cdn.yoho.cn/yas-jssdk/1.0.14/yas.js', '_yas');
(function() {
var uid = getUid();
... ...
... ... @@ -28,12 +28,12 @@
.banner-swiper {
position: relative;
height: 309rem / $pxConvertRem;
height: 310.303rem / $pxConvertRem;
overflow: hidden;
ul {
position: relative;
height: 309rem / $pxConvertRem;
height: 310.303rem / $pxConvertRem;
li {
float: left;
... ...
... ... @@ -206,7 +206,16 @@
padding: 0 pxToRem(30px);
font-size: 16px;
line-height: pxToRem(88px);
.opinion{
width: 1.3rem;
height: 1.3rem;
overflow: hidden;
display: inline-block;
background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyhpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMDY3IDc5LjE1Nzc0NywgMjAxNS8wMy8zMC0yMzo0MDo0MiAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6NTkyQTQ3NkNCOEQ4MTFFNUIzNTY5MTI2NjU5ODYzQkQiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6NTkyQTQ3NkJCOEQ4MTFFNUIzNTY5MTI2NjU5ODYzQkQiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIDIwMTUgKE1hY2ludG9zaCkiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDpDMkMzNzRFRkFFMEYxMUU1OEM0Q0U0Q0M3NkZCNzIyMCIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDpDMkMzNzRGMEFFMEYxMUU1OEM0Q0U0Q0M3NkZCNzIyMCIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PhkYSdAAAAS0SURBVHja7FpZSFRhFL6TrUZJC0K2WFlmL0Y7thcjkWZlQfVQ0QJWD+09tEMb9BAkPlVQCYVESJtlhhbRJkVqiCHtqylRD5Ut0GLfyTPxe/zvvePM3JlJPPD537n33HPOd8+//7rq6uqM5iCtjGYizYZIa/rjcrn8MuJ2u/ugGAuMBgYD/YBoIEpR+wi8A54DlcAd4FZRUdErf3x7moaLLnwhguBjUSwGZgOJfsRSDpwGskHqZdCIgMBwFDuA6QGumr+BC8AuECpxjAgI9EaRyRlwWihDa0HodUCJgEQGiv1AJwu1x8B1oISvqe5/Ar4D7YHOALWlgQBldQJfm8lnYCPIHPabCAhEojgILDSxQ8EeAU7C4SMf2lk8ivnAMiapk+PACtj/6hMROIniOjtO8/4zYDdwAg5++luP4It6zwXAdqC/RuUmtUn4+tgkIjDcEcVVYJR4j4LeC+yD0e+BbhjwS1VwE7DVMzQocheYAr9fvCICYxEozgMpwtAbYC4MFTvd0hFDEopTQC/xKB+YgRh+SSK67nOzhsQDICkYJEjYTxL7VSWF42skDTKCLzGMUxih6DwFxsD4u2BPOxAPzQ5uA3HKbcrGKMRTapWRTEGC6mNqKEhwZshvKsfhkQiOUz9pBHtK23jxfA2MPQzlZJD9rxG3x3O82tnvaqFMk7qjYTK5PcrxGGbx/m0jycnJPXD9VjYsfI1L4TJNRwamca+lSkxhYWG1mpE0zYBXEGZLjgKOS5U0WbVk2ziHbITVGpjjOSfbiiQi1xM3wnQhKONKbLBChMRqBkC7FeFhnsLQuJMhV3qB0rGJK1ZmJEoovLf5MjnAVKALlzkO6ljFFWW3+fDbxuBYm9+B1PEqLg+RWnG/q43BRza/A6ljFVetJFItFOJtDC4Bavi6hn87pWMVV7UkUi4URtt0hbd5ik3bPr34tyM6NnGVy16Lps1zFIWZwE4bMjQLfREMHRGXKsUyI3lCYSi6xhHhNIBwPEPF7bwGRHjjoFQobQmzwVDGU6pueKjdb5ZQTMdXcIdJNiiOdHE7y2wan6Pp/rJho3uISZD/bE03naMlgjT9QLFevNATyIWxdiEiQX5zOQ5V1nO82owQmYsa9hOZTGSQSUQyiYmylnCchikRllVAhbhHG9aFMB4TJBKDuPpMF48qOD7DlgjY1vK2S5V4NAa4DyezHCZB9ss01amKV621tttBwuAAFFcM/Z4sLTm3wWhZAAnQGLFHs6dGQpvhw+HviXzg7SY2TR/OAGaDYz6vJ/Jl4/My+DYceIYJAY+Q7SHwUekTEaXnOACstHBEX+yyoRwrwOl7k65UPVagNUhnL3mT7UlyCe7LQc8kFIe8mBl75JvR+Hykg581cCmIHPOLCJOhSeYio377v28IhpYPQIKabatNbKuZ6k+ANsvieCvmLH9xf4TepyMMb7Zluxn1J2fe91pNHLjcRsPj6WiLVyjgf8fT9d+n6CvstMX1PGADNWwbt5PxzjWfq1YTyXnO2ck4eft7zm52hCben8LTpVQTlXuwM9JxIgH8IAko1nG7bK8ucUEk5r8hIrpt6v6Xc++3GkSyGxFpDtLy30EtRBySPwIMACKUEyE6TctsAAAAAElFTkSuQmCC");
background-size:100% 100%;
position: relative;
top: .36rem;
}
&.highlight {
background: #eee;
}
... ...
... ... @@ -7,7 +7,7 @@
font-size: pxToRem(66px);
font-weight: bold;
line-height: pxToRem(106px);
letter-spacing: pxToRem(8px);
// letter-spacing: pxToRem(8px);
}
.info {
... ... @@ -17,12 +17,12 @@
.dollar {
display: inline-block;
margin-right: pxToRem(6px);
// margin-right: pxToRem(6px);
vertical-align: middle;
width: pxToRem(24px);
height: pxToRem(24px);
background: image-url("me/yoho-coin/dollar.png") center center;
background-size: 100%;
background-size: 100% 100%;
}
}
... ...
... ... @@ -206,10 +206,6 @@
border-bottom: none;
}
}
// .gap-block {
// min-height: 30rem/$pxConvertRem;
// background-color: #f0f0f0;
// }
}
.consult-form-page {
... ... @@ -264,9 +260,6 @@
&.focus {
color: #000;
}
.comments-num {
display: none;
}
}
.comment-nav {
border-right: 1px solid #ccc;
... ... @@ -289,8 +282,6 @@
line-height: pxToRem(62px);
}
.detail-content {
// font-size: pxToRem(28px);
// line-height: pxToRem(36px);
font-size: pxToRem(24px);
line-height: pxToRem(62px);
color: $mainFontC;
... ...
... ... @@ -7,7 +7,7 @@
</p>
<p class="info">
<span class="dollar"></span>
YOHO
YOHO
</p>
<a href="/home/currencyDetail" class="more">查看明细</a>
{{#if notice}}
... ... @@ -21,7 +21,6 @@
<div class="banner">
{{#banner}}
<a href="{{url}}">
{{!-- 演示图片 --}}
<img src="{{img}}" alt="img">
</a>
{{/banner}}
... ...
... ... @@ -101,7 +101,7 @@
<span class="iconfont num">&#xe604;</span>
</a>
<a class="list-item" href="/home/suggest">
<span class="iconfont icon">&#xe63d;</span>
<span class="opinion"></span>
意见反馈
<span class="iconfont num">&#xe604;</span>
</a>
... ...
{{> layout/header_passport}}
{{> layout/header}}
<div class="reg-code-page passport-page yoho-page">
{{> passport/code}}
</div>
{{> layout/footer_passport}}
\ No newline at end of file
{{> layout/footer}}
\ No newline at end of file
... ...
{{> layout/header_passport}}
{{> layout/header}}
<div class="reg-page passport-page yoho-page">
{{> passport/header}}
<div class="content">
... ... @@ -11,4 +11,4 @@
<p class="register-tip">YOHO!Family账号可登录Yoho!Buy有货、YOHO!Boys、YOHO!Girls及SHOW</p>
</div>
</div>
{{> layout/footer_passport}}
\ No newline at end of file
{{> layout/footer}}
\ No newline at end of file
... ...
{{> layout/header_passport}}
{{> layout/header}}
<div class="reg-password-page passport-page yoho-page">
{{> passport/header}}
<div class="content">
... ... @@ -20,4 +20,4 @@ var r=b.getElementsByTagName('script')[0];r.parentNode.insertBefore(s,r);
_agtjs('init','AG_052186_PHCW','yohobuy.com');
_agtjs('loadEvent',{atsev:101,'atsrmv':""});
</script>
{{> layout/footer_passport}}
\ No newline at end of file
{{> layout/footer}}
\ No newline at end of file
... ...
... ... @@ -30,7 +30,7 @@
</span>
</li>
<li class="input-container-li clearfix">
<input type="hidden" name="code" value="159bI6arxsuaPBxG2iV9OE9BrgDnAPiTecUqYh2iUC3ntt6S0eOtxXpVu+jWIlveXx9NRuwS9zdrXzcUyOd+d3ikzYBAo0k">
<input type="hidden" name="code" value="{{code}}">
<input id="reset-pwd-btn" class="btn reset-pwd-btn" type="submit" value="提交" disabled="">
</li>
</ul>
... ...
{{> layout/simple-header}}
<div class="verification-page back-page passport-page yoho-page clearfix">
{{# verification}}
{{> passport/cover}}
<div class="content">
<form id="verification-form" class="verification-form" method="POST" action="/passport/back/backmobile">
<ul>
<li class="head-title">验证身份</li>
<li class="po-re">
<label class="pn-label">手机号码</label>
<span class="country-code">+{{area}}</span>
<span class="phone-num">{{phoneNum}}</span>
</li>
<li class="po-re">
<input id="captcha" class="input va captcha" type="text" name="captcha">
<input id="send-captcha" class="btn send-captcha" type="button" value="发送验证码" disabled="">
<div id="captcha-tip" class="captcha-tips"><i class="iconfont">&#xe61f;</i>验证码已发送至您的手机,请查收</div>
<span id="err-tip" class="err-tip hide">
<i></i>
<em>请输入验证码</em>
</span>
</li>
<li>
<input name="area" id="area" type="hidden" value="{{area}}">
<input name="mobile" id="mobile" type="hidden" value="{{phoneNum}}">
<input name="captchaPic" id="captchaPic" type="hidden" value="g7ce">
<input name="refer" id="refer" type="hidden" value="">
<input id="next-step" class="btn next-step disable" type="submit" value="下一步" disabled="">
</li>
</ul>
</form>
</div>
{{/ verification}}
</div>
{{> layout/simple-header}}
<div class="verification-page back-page passport-page yoho-page clearfix">
{{# verification}}
{{> passport/cover}}
<div class="content">
<form id="verification-form" class="verification-form" method="POST" action="/passport/back/backmobile">
<ul>
<li class="head-title">验证身份</li>
<li class="po-re">
<label class="pn-label">手机号码</label>
<span class="country-code">+{{area}}</span>
<span class="phone-num">{{phoneNum}}</span>
</li>
<li class="po-re">
<input id="captcha" class="input va captcha" type="text" name="captcha">
<input id="send-captcha" class="btn send-captcha" type="button" value="发送验证码" disabled="">
<div id="captcha-tip" class="captcha-tips"><i class="iconfont">&#xe61f;</i>验证码已发送至您的手机,请查收</div>
<span id="err-tip" class="err-tip hide">
<i></i>
<em>请输入验证码</em>
</span>
</li>
<li>
<input name="area" id="area" type="hidden" value="{{area}}">
<input name="mobile" id="mobile" type="hidden" value="{{phoneNum}}">
<input name="captchaPic" id="captchaPic" type="hidden" value="{{captcha}}">
<input name="refer" id="refer" type="hidden" value="">
<input id="next-step" class="btn next-step disable" type="submit" value="下一步" disabled="">
</li>
</ul>
</form>
</div>
{{/ verification}}
</div>
{{> layout/footer}}
\ No newline at end of file
... ...
... ... @@ -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>
... ...
... ... @@ -30,7 +30,7 @@
{{! 热门品牌}}
{{# hotBrands}}
{{> index/floor-header}}
<div class="hot-brands logo-brand clearfix"></div>
<div class="hot-brands logo-brand clearfix" data-url="{{brandUrl}}"></div>
{{/ hotBrands}}
{{! 一周热卖}}
... ...
... ... @@ -30,7 +30,7 @@
{{! 热门品牌}}
{{# hotBrands}}
{{> index/floor-header}}
<div class="hot-brands logo-brand clearfix"></div>
<div class="hot-brands logo-brand clearfix" data-url="{{brandUrl}}"></div>
{{/ hotBrands}}
{{! 一周热卖}}
... ...
... ... @@ -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>
... ...
... ... @@ -4,7 +4,7 @@
<li class="clearfix">
<select id="region" class="region" name="region">
{{#each region}}
<option {{#if selected}}selected="selected"{{/if}} value="{{id}}">{{name}}</option>
<option {{#if selected}}selected="selected"{{/if}} value="{{areaCode}}">{{name}}</option>
{{/each}}
</select>
</li>
... ...
... ... @@ -20,7 +20,7 @@ var $ = require("jquery");
require("js/footer");
require("js/simple-header");
require("js/header");
function cookie(name) {
var cookies = document.cookie,
... ... @@ -121,7 +121,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();
... ... @@ -131,7 +131,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, '', '');
}
}());
... ... @@ -143,7 +143,10 @@ window.getUser = getUser;
window.getUid = getUid;
window.getShoppingKey = getShoppingKey;
window.getShoppingKey = getShoppingKey;
require("js/header");
});
define("js/footer", ["jquery"], function(require, exports, module){
/**
... ... @@ -333,11 +336,238 @@ define("js/header", ["jquery","handlebars","source-map","index"], function(requi
var $ = require("jquery");
var handlebars = require("handlebars");
var json2 = require("index");
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]
... ... @@ -383,8 +613,7 @@ handlebars.registerHelper('equalzero', function(v1, options) {
return options.inverse(this);
}
});
require("plugin/yohocookie");
require("plugin/yohocart");
/**
* 获取头部banner的回调函数
* @param {[type]} data [description]
... ... @@ -402,42 +631,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对应的编码]
... ... @@ -446,23 +642,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]
... ... @@ -548,7 +732,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';
... ... @@ -556,7 +740,7 @@ function requestFrameCloser() {
if (window[func1]) {
return function(callback) {
window[func1](callback);
requestAnimationFrame(callback);
};
}
if (window[func2]) {
... ... @@ -575,69 +759,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);
}
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',
if (globaltimeout) {
window.clearTimeout(globaltimeout);
}
$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);
... ... @@ -650,6 +826,7 @@ function fadeAnimate() {
*/
function actionTopLogoAnimate() {
if (isSupportCss3Animation()) {
requestFrame = requestFrameAct();
window.setTimeout(tsAnimate, 3000);
} else {
window.setTimeout(fadeAnimate, 3000);
... ... @@ -682,134 +859,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
... ... @@ -821,8 +920,6 @@ function actionInitCookie() {
* cookie集合
* @type {Object}
*/
window.cookieMap = {};
function actionExeCookieMap() {
var cookies = document.cookie;
var cookiearr = cookies.split(';');
... ... @@ -832,8 +929,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];
}
}
}
/**
... ... @@ -844,47 +943,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
... ... @@ -893,7 +992,7 @@ function actionFirstMenuClick() {
});
$('#backToOld').click(function() {
$.setcookie('_New', 1, {
window.setCookie('_New', 1, {
path: '/',
domain: '.yohobuy.com'
});
... ... @@ -924,10 +1023,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) {
... ... @@ -935,11 +1034,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'
});
... ... @@ -963,11 +1062,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'
});
... ... @@ -1079,43 +1178,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); //获得公告信息
}
... ... @@ -1206,12 +1304,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';
... ... @@ -1326,8 +1424,10 @@ function actionLoginInfo() {
};
$.getData(apiDomain, param, function(_data) {
actionLoginState(_data); // 更改登录状态
actionVipInfo(_data); //获得vip;
if (_data.result !== -1) {
actionLoginState(_data); // 更改登录状态
actionVipInfo(_data); //获得vip;
}
});
}
/**
... ... @@ -1337,207 +1437,26 @@ function actionLoginInfo() {
function init() {
actionExeTemplate(); //处理模板
actionInitCookie(); //初始化cookie
actionExeCookieMap(); //格式化cookie
actionYoHoGroup(); // yoho集团鼠标效果
actionTopTagToggle(); // yoho上部分开关
actionTopLogoAnimate(); //yoho logo动画
actionGetBannerAndNotice(); // 获取banner和服务器维护提示
actionBrandChange(); //切换品牌
actionAddKeyWords(); //跳转后增加关键字
actionFirstMenuClick(); //一级菜单点击(会设置cookie)
actionGoodsCarMouseEffect(); //鼠标滑入滑出效果
actionUpdateCartNum(); //更新购物车数量
actionLoopUpdCartNum(); //循环检测购物车数量
actionSearch(); //搜索执行
actionClickMiniCartBox(); //点击购物车跳转
actionListenDelCarGoods(); //监听购物车删除
actionListenCartMore(); //
actionLoginInfo(); //获取登录信息
}
init();
});
define("plugin/yohocookie", ["jquery"], function(require, exports, module){
var jQuery = require("jquery");
(function($) {
$.extend({
cookie: function(name) {
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
if (cookie.substring(0, name.length + 1) == (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
},
setcookie: function(name, value, options) {
var expires = '';
if (typeof value != 'undefined') {
options = options || {};
if (value === null) {
value = '';
options.expires = -1;
}
if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
var date;
if (typeof options.expires == 'number') {
date = new Date();
date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
} else {
date = options.expires;
}
expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
}
var path = options.path ? '; path=' + options.path : '';
var domain = options.domain ? '; domain=' + options.domain : '';
var secure = options.secure ? '; secure' : '';
document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
}
}
})
})(jQuery);
});
define("plugin/yohocart", ["jquery"], function(require, exports, module){
var jQuery = require("jquery");
var $yohocookie = require("plugin/yohocookie");
(function($) {
$.fn.miniCart = function(options) {
var defaults = {
'cookie': '_g',
'cartNum': ''
};
var params = $.extend(defaults, options);
var cartInfo = eval('(' + $.cookie(params.cookie) + ')');
if (cartInfo != null) {
var 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) {
var query_num = 0;
var list_index = 0;
var tmp_list = 0;
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']);
query_num = $('.search-list').children('li').length;
list_index = -1;
if (query_num > 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(' + tmp_list + ')').children('a').css("background-color", "#fff");
$('.search-list li:eq(' + list_index + ')').children('a').css("background-color", "#eee");
var text = $('.search-list li:eq(' + list_index + ')').children('a').attr("title");
$('#query_key').val(text);
}
return this.each(function() {
$(this).keyup(function(event) {
if (event.which == 38) {
if (query_num == 0) {
return false;
}
if (list_index == -1) {
list_index = 0;
}
tmp_list = list_index;
list_index = (list_index - 1 + query_num) % query_num;
getText(this);
} else if (event.which == 40) {
if (query_num == 0) {
return false;
}
tmp_list = list_index;
list_index = (list_index + 1) % query_num;
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()
};
if (typeof(domain) == undefined || domain == '') {
console.log('请设置请求的api地址');
return false;
}
var 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 != '') {
eval(onSuccess(_data.data));
return false;
}
});
} catch (e) {
console.log(e.message);
}
},
getShoppingKey: function() {
var shoppingInfo = $.cookie('_g');
if (typeof shoppingInfo == 'undefined' || shoppingInfo == null) {
return '';
}
var shoppingData = eval('(' + shoppingInfo + ')');
return shoppingData._k;
},
})
})(jQuery);
exports.init = function() {
actionExeCookieMap(); //格式化cookie
actionGoodsCart(); //初始化购物车插件
actionYoHoGroup(); // yoho集团鼠标效果
actionTopTagToggle(); // yoho上部分开关
actionTopLogoAnimate(); //yoho logo动画
actionGetBannerAndNotice(); // 获取banner和服务器维护提示
actionBrandChange(); //切换品牌
actionAddKeyWords(); //跳转后增加关键字
actionFirstMenuClick(); //一级菜单点击(会设置cookie)
actionGoodsCarMouseEffect(); //鼠标滑入滑出效果
actionUpdateCartNum(); //更新购物车数量
actionLoopUpdCartNum(); //循环检测购物车数量
actionSearch(); //搜索执行
actionClickMiniCartBox(); //点击购物车跳转
actionListenDelCarGoods(); //监听购物车删除
actionListenCartMore(); //
actionLoginInfo(); //获取登录信息
}
}
init();
});
define("js/product/entry", ["jquery","lazyload","handlebars","source-map"], function(require, exports, module){
/**
... ... @@ -4043,9 +3962,10 @@ function picCaptchaAjaxFn(page, callback) {
type: 'POST',
url: url,
data: {
code: $ca.val(),
mobile: $pn.val(),
area: $region.text().split('+')[1]
code: $ca.val()
//mobile: $pn.val(),
//area: $region.text().split('+')[1]
}
}).then(function(data) {
switch (data.code) {
... ... @@ -4437,7 +4357,7 @@ exports.init = function(page) {
data: {
area: $region.text().split('+')[1],
mobile: $pn.val(),
captcha: $ca.val(),
verifyCode: $ca.val(),
code: $mc.val(),
password: $pwd.val()
}
... ... @@ -4445,29 +4365,35 @@ exports.init = function(page) {
var time = 0,
t,
refer = data.href;
refer;
t = setTimeout(function() {
time++;
}, 1000);
if (data.code === 200) {
$.ajax({
type: 'POST',
url: '/passport/register/mobileregister',
data: {
session: data.session
}
}).then(function(data) {
refer = data.data.href;
t = setTimeout(function() {
time++;
}, 1000);
$.ajax({
type: 'GET',
url: data.data.session
}).then(function(data) {
if (data.code === 200 && t < 3) {
clearInterval(t);
location.href = refer;
}
});
if (data.code === 200 && t < 3) {
if (t >= 3) {
clearInterval(t);
location.href = refer;
}
});
} else {
if (t >= 3) {
clearInterval(t);
location.href = refer;
//todo
console.log('网络超时~');
}
});
... ... @@ -4854,290 +4780,296 @@ $('#find-btn').click(function(e) {
});
});
define("js/passport/login", ["jquery","jquery.placeholder"], function(require, exports, module){
/**
* 登录
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2015/12/11
*/
var $ = require("jquery");
var mailPostfix = {
num: ['qq.com', '163.com', '126.com', 'sina.com', 'gmail.com', 'sohu.com', 'hotmail.com', '139.com', '189.com'],
other: ['gmail.com', 'qq.com', '163.com', '126.com', 'sina.com', 'sohu.com', 'hotmail.com', '139.com', '189.com']
};
var $account = $('#account'),
$password = $('#password');
var $accountTip = $account.siblings('.err-tip'),
$passwordTip = $password.siblings('.err-tip'),
$capsLock = $('#caps-lock');
var $countryCodeHide = $('#country-code-hide'),
$countryCodeEm = $('#country-code > em'),
$countryList = $('#country-list');
var $emailAutoComplete = $('#email-autocomplete');
var mailPhoneRegx = require("js/passport/mail-phone-regx");
//checkbox status unicode
var checkbox = {
checked: '&#xe612;',
unchecked: '&#xe613;'
};
var authing = false;
var emailAcTime;
require("jquery.placeholder");
//验证账户名
function validateAccount() {
var pass = false,
account = $.trim($account.val()),
err;
if (account !== '') {
if (/^[0-9]+$/.test(account)) {
//如果是纯数字,则作为手机号码处理
if (mailPhoneRegx.phoneRegx[$countryCodeHide.val()].test(account)) {
pass = true;
} else {
pass = false;
err = '手机号码不正确,请重新输入';
}
} else {
if (mailPhoneRegx.emailRegx.test(account)) {
pass = true;
} else {
pass = false;
err = '邮箱格式不正确,请重新输入';
}
}
} else {
err = '请输入账户名';
}
if (pass) {
$accountTip.addClass('hide');
$account.removeClass('error');
} else {
$accountTip.removeClass('hide').children('em').text(err);
$account.addClass('error');
}
return pass;
}
//验证密码
function validatePassword() {
var pass = false,
password = $.trim($password.val()),
err;
if (password !== '') {
if (password.length < 6) {
err = '请输入长度为6-20字符的密码';
} else {
pass = true;
}
} else {
err = '请输入密码';
}
if (pass) {
$passwordTip.addClass('hide');
$password.removeClass('error');
} else {
$passwordTip.removeClass('hide').children('em').text(err);
$password.addClass('error');
}
return pass;
}
//验证
function validate() {
var pass = true,
account = $.trim($account.val()),
password = $.trim($password.val());
if (account !== '') {
pass = validateAccount() && validatePassword();
} else {
pass = false;
$account.addClass('error');
if (password === '') {
//账户名和密码都为空的情况下点击登陆,只在账户输入框后显示错误提示
$accountTip.addClass('both-error').removeClass('hide').children('em').text('请输入账户名和密码');
$passwordTip.addClass('hide');
$password.addClass('error');
} else {
$accountTip.removeClass('hide').children('em').text('请输入账户名');
}
}
return pass;
}
$('[placeholder]').placeholder();
//展开地区列表
$('#country-code').on('click', function() {
if ($countryList.css('display') === 'none') {
$countryList.slideDown();
}
});
//选中地区列表项
$countryList.on('click', 'li', function() {
var $this = $(this),
cc = $this.data('cc');
$countryCodeEm.html($this.html());
$countryCodeHide.val(cc);
$countryList.slideUp();
});
//点击其他区域,收起区域列表
$(document).on('click', function(e) {
if ($(e.target).closest('#country-code').length > 0) {
return;
}
if ($countryList.css('display') === 'block') {
$countryList.slideUp();
}
});
//邮箱
$account.on('keyup', function() {
var account = $.trim($(this).val()),
html = '',
accountMatch,
matchStr,
postfix,
i;
//输入@时自动补全邮箱后缀
//此处>0非错误,用于避免输入的第一个字符为@被识别为邮箱
if (account.indexOf('@') > 0) {
accountMatch = account.match(/^[0-9]+@(.*)/);
if (accountMatch) {
//数字邮箱补全
postfix = mailPostfix.num;
} else {
postfix = mailPostfix.other;
}
matchStr = accountMatch[1];
for (i = 0; i < postfix.length; i++) {
if (postfix[i].indexOf(matchStr) > -1) {
html += '<li>' + account.slice(0, account.indexOf('@')) + '@' + postfix[i] + '</li>';
}
}
if (html !== '') {
$emailAutoComplete.html(html).removeClass('hide');
} else {
//隐藏autocomplete
$emailAutoComplete.html('').addClass('hide');
}
}
}).on('blur', function() {
emailAcTime = setTimeout(function() {
$emailAutoComplete.addClass('hide');
//验证
validateAccount();
}, 200);
});
//密码
$password.on('blur', function() {
validatePassword();
}).on('keypress', function(e) {
var code = e.which,
isShift = e.shiftKey || (code === 16) || false;
//CapsLock检测
if ((!isShift && (code >= 65 && code <= 90)) ||
(isShift && (code >= 97 && code <= 122))) {
$capsLock.removeClass('hide');
return;
}
$capsLock.addClass('hide');
});
//邮箱自动完成列表项点击
$emailAutoComplete.on('click', 'li', function() {
clearTimeout(emailAcTime); //清空默认关闭
$account.val($(this).text()).focus();
$emailAutoComplete.addClass('hide');
});
//记住登录状态
$('.remeber-me').on('click', function() {
var $this = $(this);
$this.toggleClass('checked');
if ($this.hasClass('checked')) {
$this.children('i').html(checkbox.checked);
} else {
$this.children('i').html(checkbox.unchecked);
}
});
//focus到输入框则隐藏错误提示和样式
$('.va').on('focus', function() {
var $this = $(this);
$this.removeClass('error');
$this.siblings('.err-tip').addClass('hide');
});
//登录
$('#login-btn').on('click', function() {
var pass = validate();
if (pass && authing === false) {
authing = true;
$.ajax({
url: '/passport/login/auth',
type: 'POST',
data: {
areaCode: $countryCodeHide.val().replace('+', ''),
account: $.trim($account.val()),
password: $.trim($password.val())
},
success: function(data) {
if (data.code === 400) {
$passwordTip.removeClass('hide').children('em').text(data.message);
$password.addClass('error');
return;
} else {
location.href = data.data.href;
}
},
complete: function() {
authing = false;
}
});
}
/**
* 登录
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2015/12/11
*/
var $ = require("jquery");
var mailPostfix = {
num: ['qq.com', '163.com', '126.com', 'sina.com', 'gmail.com', 'sohu.com', 'hotmail.com', '139.com', '189.com'],
other: ['gmail.com', 'qq.com', '163.com', '126.com', 'sina.com', 'sohu.com', 'hotmail.com', '139.com', '189.com']
};
var $account = $('#account'),
$password = $('#password');
var $accountTip = $account.siblings('.err-tip'),
$passwordTip = $password.siblings('.err-tip'),
$capsLock = $('#caps-lock');
var $countryCodeHide = $('#country-code-hide'),
$countryCodeEm = $('#country-code > em'),
$countryList = $('#country-list');
var $emailAutoComplete = $('#email-autocomplete');
var mailPhoneRegx = require("js/passport/mail-phone-regx");
var $remember = $('.remember-me');
//checkbox status unicode
var checkbox = {
checked: '&#xe612;',
unchecked: '&#xe613;'
};
var authing = false;
var emailAcTime;
require("jquery.placeholder");
//验证账户名
function validateAccount() {
var pass = false,
account = $.trim($account.val()),
err;
if (account !== '') {
if (/^[0-9]+$/.test(account)) {
//如果是纯数字,则作为手机号码处理
if (mailPhoneRegx.phoneRegx[$countryCodeHide.val()].test(account)) {
pass = true;
} else {
pass = false;
err = '手机号码不正确,请重新输入';
}
} else {
if (mailPhoneRegx.emailRegx.test(account)) {
pass = true;
} else {
pass = false;
err = '邮箱格式不正确,请重新输入';
}
}
} else {
err = '请输入账户名';
}
if (pass) {
$accountTip.addClass('hide');
$account.removeClass('error');
} else {
$accountTip.removeClass('hide').children('em').text(err);
$account.addClass('error');
}
return pass;
}
//验证密码
function validatePassword() {
var pass = false,
password = $.trim($password.val()),
err;
if (password !== '') {
if (password.length < 6) {
err = '请输入长度为6-20字符的密码';
} else {
pass = true;
}
} else {
err = '请输入密码';
}
if (pass) {
$passwordTip.addClass('hide');
$password.removeClass('error');
} else {
$passwordTip.removeClass('hide').children('em').text(err);
$password.addClass('error');
}
return pass;
}
//验证
function validate() {
var pass = true,
account = $.trim($account.val()),
password = $.trim($password.val());
if (account !== '') {
pass = validateAccount() && validatePassword();
} else {
pass = false;
$account.addClass('error');
if (password === '') {
//账户名和密码都为空的情况下点击登陆,只在账户输入框后显示错误提示
$accountTip.addClass('both-error').removeClass('hide').children('em').text('请输入账户名和密码');
$passwordTip.addClass('hide');
$password.addClass('error');
} else {
$accountTip.removeClass('hide').children('em').text('请输入账户名');
}
}
return pass;
}
$('[placeholder]').placeholder();
//展开地区列表
$('#country-code').on('click', function() {
if ($countryList.css('display') === 'none') {
$countryList.slideDown();
}
});
//选中地区列表项
$countryList.on('click', 'li', function() {
var $this = $(this),
cc = $this.data('cc');
$countryCodeEm.html($this.html());
$countryCodeHide.val(cc);
$countryList.slideUp();
});
//点击其他区域,收起区域列表
$(document).on('click', function(e) {
if ($(e.target).closest('#country-code').length > 0) {
return;
}
if ($countryList.css('display') === 'block') {
$countryList.slideUp();
}
});
//邮箱
$account.on('keyup', function() {
var account = $.trim($(this).val()),
html = '',
accountMatch,
matchStr,
postfix,
i;
//输入@时自动补全邮箱后缀
//此处>0非错误,用于避免输入的第一个字符为@被识别为邮箱
if (account.indexOf('@') > 0) {
accountMatch = account.match(/^[0-9]+@(.*)/);
if (accountMatch) {
//数字邮箱补全
postfix = mailPostfix.num;
} else {
postfix = mailPostfix.other;
}
matchStr = accountMatch[1];
for (i = 0; i < postfix.length; i++) {
if (postfix[i].indexOf(matchStr) > -1) {
html += '<li>' + account.slice(0, account.indexOf('@')) + '@' + postfix[i] + '</li>';
}
}
if (html !== '') {
$emailAutoComplete.html(html).removeClass('hide');
} else {
//隐藏autocomplete
$emailAutoComplete.html('').addClass('hide');
}
}
}).on('blur', function() {
emailAcTime = setTimeout(function() {
$emailAutoComplete.addClass('hide');
//验证
validateAccount();
}, 200);
});
//密码
$password.on('blur', function() {
validatePassword();
}).on('keypress', function(e) {
var code = e.which,
isShift = e.shiftKey || (code === 16) || false;
//CapsLock检测
if ((!isShift && (code >= 65 && code <= 90)) ||
(isShift && (code >= 97 && code <= 122))) {
$capsLock.removeClass('hide');
return;
}
$capsLock.addClass('hide');
});
//邮箱自动完成列表项点击
$emailAutoComplete.on('click', 'li', function() {
clearTimeout(emailAcTime); //清空默认关闭
$account.val($(this).text()).focus();
$emailAutoComplete.addClass('hide');
});
//记住登录状态
$remember.on('click', function() {
var $this = $(this);
$this.toggleClass('checked');
if ($this.hasClass('checked')) {
$this.children('i').html(checkbox.checked);
} else {
$this.children('i').html(checkbox.unchecked);
}
});
//focus到输入框则隐藏错误提示和样式
$('.va').on('focus', function() {
var $this = $(this);
$this.removeClass('error');
$this.siblings('.err-tip').addClass('hide');
});
//登录
$('#login-btn').on('click', function() {
var pass = validate();
if (pass && authing === false) {
authing = true;
$.ajax({
url: '/passport/login/auth',
type: 'POST',
data: {
areaCode: $countryCodeHide.val().replace('+', ''),
account: $.trim($account.val()),
password: $.trim($password.val()),
isRemember: $remember.hasClass('checked') ? true : false
},
success: function(data) {
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');
}
},
complete: function() {
authing = false;
}
});
}
});
});
define("js/passport/reset", ["jquery","jquery.placeholder"], function(require, exports, module){
... ...
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
... ... @@ -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() {
... ...
... ... @@ -183,7 +183,7 @@
margin-right:-10px;
.good-info{
width: 240px;
height: 400px;
height: 412px;
margin-bottom:0px;
.good-detail-img{
height: 320px;
... ... @@ -439,7 +439,7 @@
.goods-container{
.good-info{
width: 280px;
height: 465px;
height: 485px;
.good-detail-img{
height: 374px;
}
... ...
... ... @@ -60,7 +60,7 @@ $third: sprite-map("passport/third/*.png");
}
}
.remeber-me {
.remember-me {
cursor: pointer;
}
... ...
@import "search", "list", "new-sale", "filter-box", "sort-pager", "good", "latest-walk", "left-content", "no-result";
@import "search", "list", "new-sale", "filter-box", "sort-pager", "good", "latest-walk", "left-content", "no-result", "hot-rank";
.product-page {
... ...
<?php
<?php
/**
* 启动运行
... ... @@ -73,7 +73,7 @@ class Bootstrap extends Bootstrap_Abstract
$action = 'Index';
// 二级域名
if (3 === $level) {
if (2 === $level) {
$subDomain = strval($hostParts[0]);
switch (strtolower($subDomain)) {
case 'www': // 主站
... ... @@ -90,6 +90,10 @@ class Bootstrap extends Bootstrap_Abstract
case 'list': // 商品列表
$module = 'Product';
break;
case 'sale'://促销
$module = 'Product';
$controller = 'sale';
default: // 其它(识别为品牌)
$module = 'Product';
$action = 'Brand';
... ...
<?php
use Action\WebAction;
use Index\HomeModel;
use LibModels\Web\Home\IndexData;
use Plugin\Cache;
use Configs\CacheConfig;
use Api\Yohobuy;
... ... @@ -87,8 +88,8 @@ class CommonController extends WebAction
'content_code' => $content_code,
'client_type' => $client_type
);
$data = Yohobuy::get($url.http_build_query($params));
if(empty($data))
$data = IndexData::getResourceData($content_code);//Yohobuy::get($url.http_build_query($params));
if(empty($data['data']))
{
return $this->helpJsonCallbackResult($callback, 200, '没有数据', '');
}
... ...
... ... @@ -24,6 +24,7 @@ class PassportModel
const BACK_LFFT_BANNER_CODE = '3bbaf502c447a2ddad60879042e286d8';//找回密码左边的banner
const SIGNIN_LEFT_BANNER_CODE ='db350894e01e90eac55cd3a13ad77331';//登录页左边的banner
const AUTOUSERINFO_LEFT_BANNER_CODE ='c62d5da06d843b6ed78d8d27e87fa143';//完善信息页左边的banner
const BACK_FIND_SECRET_KEY = '_+@#$%^';
//简单头部
public static function getSimpleHeader($isLogin, $username = '')
... ... @@ -75,6 +76,11 @@ class PassportModel
$ret['img'] = Images::getImageUrl($val['src'], 252, 190);
$ret['url'] = $val['url'];
}
else
{
$ret['img'] = 'http://img12.static.yhbimg.com/yhb-img01/2015/12/01/07/020a0b6e7ff908d0c2bc4045b4fef42b9f.png?imageView/2/w/252/h/190';
$ret['url'] = '';
}
return $ret;
}
... ...
... ... @@ -56,6 +56,7 @@ class BackController extends WebAction
$data = BackData::sendCodeToMobile($mobile);
$this->setSession('phoneNum', $phoneNum);
$this->setSession('area', $area);
$this->setSession('captcha', $captcha);
if($data['code'] == 200) {
$this->redirect('verification');
}
... ... @@ -66,7 +67,7 @@ class BackController extends WebAction
}
/**
* 发送邮件
* 发送邮件页面
*/
public function sendemailAction() {
$phoneNum = $this->getSession('phoneNum');
... ... @@ -96,14 +97,14 @@ class BackController extends WebAction
'sendEmail' => array(
'coverHref' => $banner['url'],
'coverImg' => $banner['img'],
'countrys' => array()
'countrys' => array(),
)
);
$this->_view->display('send-email', $data);
}
/**
* 重置密码
* 重置密码页面
*/
public function backcodeAction() {
$code = $this->get('code');
... ... @@ -118,14 +119,15 @@ class BackController extends WebAction
'resetPwd' => array(
'coverHref' => $banner['url'],
'coverImg' => $banner['img'],
'countrys' => array()
'countrys' => array(),
'code' => $code,
)
);
$this->_view->display('reset-pwd', $data);
}
/**
* 更新密码
* 更新密码接口
*
*/
public function updateAction()
... ... @@ -134,10 +136,22 @@ class BackController extends WebAction
$password = $this->post('pwd');
$info = $this->checkCode($code);
if(Helpers::verifyPassword($password) && !empty($info)) {
$uid = $info['uid'];
//修改密码
if(isset($info['mobile'])) {//手机号修改密码
$mobile = $info['mobile'];
$token = $info['token'];
$area = $info['area'];
$data = BackData::modifyPasswordByMobile($mobile, $token, $password, $area);
if($data['code']) {
$this->redirect('resetSuccess');
}
} else if(isset($info['uid'])) {//其他方式修改密码
$uid = $info['uid'];
$this->redirect('resetSuccess');
}
}
//跳转错误页面
$this->redirect('/error/index');
}
/**
... ... @@ -157,14 +171,15 @@ class BackController extends WebAction
}
/**
* 手机验证
* 手机验证页面
*/
public function verificationAction() {
$phoneNum = $this->getSession('phoneNum');
$area = $this->getSession('area');
// if(empty($phoneNum)) {
// $this->redirect('index');
// }
$captcha = $this->getSession('captcha');
if(empty($phoneNum)) {
$this->redirect('index');
}
$banner = PassportModel::getLeftBanner(PassportModel::BACK_LFFT_BANNER_CODE);
$data = array(
'simpleHeader' => PassportModel::getSimpleHeader(false),
... ... @@ -174,6 +189,7 @@ class BackController extends WebAction
'coverImg' => $banner['img'],
'phoneNum' => $phoneNum,
'area' => $area,
'captcha'=> $captcha,
'countrys' => array()
)
);
... ... @@ -181,6 +197,32 @@ class BackController extends WebAction
}
/**
* 手机找回密码验证
*/
public function backmobileAction()
{
$mobile = $this->post('mobile');//phoneNum
$area = $this->post('area');
//$captcha = $this->post('captcha');
$code = $this->post('captcha');//code
if($this->getSession('phoneNum') == $mobile && $this->getSession('area') == $area)
{
$result = BackData::validateMobileCode($mobile, $code, $area);
if($result['code'] == 200) {
$str = json_encode(array(
'mobile'=> $mobile,
'area' => $area,
'token'=> $result['data']['token'],
'create_time' => time()
));
$code = AuthCode::encode($str, PassportModel::BACK_FIND_SECRET_KEY);
$url = '/passport/back/backcode?code='.base64_encode($code);
$this->redirect(SITE_MAIN.$url);
}
}
}
/**
* 检查code
*
* @param string $code
... ... @@ -188,9 +230,8 @@ class BackController extends WebAction
*/
private function checkCode($code)
{
$key = '_+@#$%^';
$code = base64_decode($code);
$info = json_decode(AuthCode::decode($code, $key), true);
$info = json_decode(AuthCode::decode($code, PassportModel::BACK_FIND_SECRET_KEY), true);
if ($info['create_time'] < 1 || (time() - $info['create_time']) > 86400) {
return array();
}
... ...
<?php
use Action\AbstractAction;
use Action\WebAction;
use LibModels\Web\Passport\RegData;
use LibModels\Web\Passport\LoginData;
use Passport\PassportModel as PassportModel;
use Plugin\Helpers;
class LoginController extends AbstractAction
class LoginController extends WebAction
{
/**
... ... @@ -23,7 +22,7 @@ class LoginController extends AbstractAction
$this->setCookie('_TOKEN', '');
//登录后跳转页面
$refer = empty($_SERVER["HTTP_REFERER"])?'':$_SERVER["HTTP_REFERER"];
$refer = empty($_SERVER["HTTP_REFERER"]) ? '' : $_SERVER["HTTP_REFERER"];
if (!empty($refer)) {
$this->setCookie('refer', $refer);
}
... ... @@ -40,13 +39,21 @@ class LoginController extends AbstractAction
$simpleHeader = PassportModel::getSimpleHeader($isLogin, $username);
//获取登陆页左侧资源
$cover = PassportModel::getLeftBanner(PassportModel::SIGNIN_LEFT_BANNER_CODE);
//是否记住密码
$isRemember = $this->getCookie('isRemember', FALSE);
$account = '';
$password = '';
if ($isRemember) {
$account = $this->decrypt($this->getCookie('account', ''));
$password = $this->decrypt($this->getCookie('userInfo', ''));
}
//整合
$data = array(
'loginPage' => true,
'simpleHeader' => $simpleHeader,
'passport' => array(
'coverHref' => $cover['url'],
'coverImg' => !empty($cover['img'])?$cover['img']:'http://img12.static.yhbimg.com/yhb-img01/2015/12/01/07/020a0b6e7ff908d0c2bc4045b4fef42b9f.png?imageView/2/w/252/h/190',
'coverImg' => !empty($cover['img']) ? $cover['img'] : 'http://img12.static.yhbimg.com/yhb-img01/2015/12/01/07/020a0b6e7ff908d0c2bc4045b4fef42b9f.png?imageView/2/w/252/h/190',
'countryCode' => '+86',
'countryName' => '中国',
'countryList' => RegData::getAreasData(),
... ... @@ -58,6 +65,9 @@ class LoginController extends AbstractAction
'alipayLogin' => Helpers::url('/passport/autosign/alipay'),
'doubanLogin' => Helpers::url('/passport/autosign/douban'),
'renrenLogin' => Helpers::url('/passport/autosign/renren'),
'isRemember' => $isRemember,
'password' => $password,
'account' => $account
),
);
... ... @@ -84,15 +94,17 @@ class LoginController extends AbstractAction
/* 判断参数是否传递 */
$area = trim($this->post('areaCode', '86'));
$profile = trim($this->post('account'));
$account = trim($this->post('account'));
$password = trim($this->post('password'));
if (!is_numeric($area) || empty($profile) || empty($password)) {
$isRemember = trim($this->post('isRemember'));
$isRemember = false;
if (!is_numeric($area) || empty($account) || empty($password)) {
break;
}
/* 判断参数是否有效 */
$verifyEmail = Helpers::verifyEmail($profile);
$verifyMobile = ($area === '86') ? Helpers::verifyMobile($profile) : Helpers::verifyAreaMobile($profile, $area);
$verifyEmail = Helpers::verifyEmail($account);
$verifyMobile = ($area === '86') ? Helpers::verifyMobile($account) : Helpers::verifyAreaMobile($account, $area);
if (!$verifyEmail && !$verifyMobile) {
break;
}
... ... @@ -106,10 +118,21 @@ class LoginController extends AbstractAction
/* 调用登录接口进行登录 */
// 获取未登录时的唯一识别码
$shoppingKey = Helpers::getShoppingKeyByCookie();
$data = LoginData::signin($area, $profile, $password, $shoppingKey);
$data = LoginData::signin($area, $account, $password, $shoppingKey);
if (!isset($data['code']) || $data['code'] != 200 || !isset($data['data']['uid'])) {
break;
}
//登录成功记录账户信息
if ($isRemember) {
$this->setCookie('account', $this->encrypt($account), time() + 3600 * 24 * 7, '/');
$this->setCookie('userInfo', $this->encrypt($password), time() + 3600 * 24 * 7, '/');
$this->setCookie('isRemember', $isRemember, time() + 3600 * 24 * 7);
}
else {
$this->setCookie('account', '', -1, '/');
$this->setCookie('userInfo', '', -1, '/');
$this->setCookie('isRemember', '', -1, '/');
}
$refer = $this->getCookie('refer');
if (empty($refer)) {
... ... @@ -152,4 +175,60 @@ class LoginController extends AbstractAction
$this->go($refer);
}
/*
* 加密算法
*/
private function encrypt($data, $key='yohobuy')
{
$key = md5($key);
$x = 0;
$str='';
$char='';
$len = strlen($data);
$l = strlen($key);
for ($i = 0; $i < $len; $i++) {
if ($x == $l) {
$x = 0;
}
$char .= $key{$x};
$x++;
}
for ($i = 0; $i < $len; $i++) {
$str .= chr(ord($data{$i}) + (ord($char{$i})) % 256);
}
return base64_encode($str);
}
/*
* 解密算法
*/
private function decrypt($data, $key='yohobuy')
{
$key = md5($key);
$x = 0;
$str='';
$char='';
$data = base64_decode($data);
$len = strlen($data);
$l = strlen($key);
for ($i = 0; $i < $len; $i++) {
if ($x == $l) {
$x = 0;
}
$char .= substr($key, $x, 1);
$x++;
}
for ($i = 0; $i < $len; $i++) {
if (ord(substr($data, $i, 1)) < ord(substr($char, $i, 1))) {
$str .= chr((ord(substr($data, $i, 1)) + 256) - ord(substr($char, $i, 1)));
}
else {
$str .= chr(ord(substr($data, $i, 1)) - ord(substr($char, $i, 1)));
}
}
return $str;
}
}
... ...
<?php
<?php
use Yaf\Application;
define('SITE_MAIN', 'http://dev.yohobuy.com'); // 网站主域名
define('SITE_MAIN', 'http://web.dev.yohobuy.com'); // 网站主域名
define('OLD_MAIN', 'http://www.yohobuy.com'); // 网站旧域名
define('COOKIE_DOMAIN', '.yohobuy.com'); // COOKIE作用域
define('SUB_DOMAIN', '.yohobuy.com'); // 子域名后缀
... ...