Authored by whb

index css, js

@@ -1080,6 +1080,73 @@ function actionTipPic() { @@ -1080,6 +1080,73 @@ function actionTipPic() {
1080 }); 1080 });
1081 } 1081 }
1082 1082
  1083 +
  1084 +
  1085 +function closeCover(){
  1086 + var $cover = $('#cover');
  1087 +
  1088 + $cover.remove();
  1089 +}
  1090 +/**
  1091 + * 首次进入有弹窗
  1092 + * @return {[type]} [description]
  1093 + */
  1094 +function actionCover() {
  1095 + var gender = cookieMap._Gender;
  1096 +
  1097 + setCookie('_Channel','boys',{path : '/',domain : '.yohobuy.com',expires : 7});
  1098 + if(typeof gender == 'undefined' || gender == '' || gender == null){
  1099 + $.get('http://www.yohobuy.com/index/guide', function(data){
  1100 + var newMask = document.createElement("div");
  1101 + newMask.id = 'cover';
  1102 + newMask.innerHTML=data;
  1103 + document.body.appendChild(newMask);
  1104 + var window_height = $(window).height();
  1105 + var self_height = $('.guide-box').height();
  1106 + var container_top = window_height / 2 - self_height / 2;
  1107 + var length=$('.guide-box .clear').find("li").length;
  1108 + $('.guide-box').css({
  1109 + width: (200 * length) + 'px',
  1110 + top: container_top + 'px'
  1111 + });
  1112 + $('#cover').bind('click', function(event){
  1113 + setCookie('_Gender','1,3',{path : '/',domain : '.yohobuy.com',expires : 90});
  1114 + setCookie('_Channel','boys',{path : '/',domain : '.yohobuy.com',expires : 7});
  1115 + closeCover();
  1116 + });
  1117 + $('#cover .guide-box .close').bind('click', function(event){
  1118 + getSource('弹窗','CLOSE','homepage_man');
  1119 + setCookie('_Gender','1,3',{path : '/',domain : '.yohobuy.com',expires : 90});
  1120 + setCookie('_Channel','boys',{path : '/',domain : '.yohobuy.com',expires : 7});
  1121 + analy('guide_close');
  1122 + closeCover();
  1123 + });
  1124 + $('.boys img , .boys .go').bind('click', function(event){
  1125 + getSource('弹窗','BOYS','homepage_man');
  1126 + setCookie('_Gender','1,3',{path : '/',domain : '.yohobuy.com',expires : 90});
  1127 + setCookie('_Channel','boys',{path : '/',domain : '.yohobuy.com',expires : 7});
  1128 + analy( 'guide_boys');
  1129 + closeCover();
  1130 + });
  1131 + $('.girls img, .girls .go').bind('click', function(event){
  1132 + getSource('弹窗','GIRLS','homepage_woman');
  1133 + setCookie('_Gender','2,3',{path : '/',domain : '.yohobuy.com',expires : 90});
  1134 + setCookie('_Channel','girls',{path : '/',domain : '.yohobuy.com',expires : 7});
  1135 + analy( 'guide_girls');
  1136 + });
  1137 + $('.lifestyle img, .lifestyle .go').bind('click', function(event){
  1138 + setCookie('_Channel','lifestyle',{path : '/',domain : '.yohobuy.com',expires : 7});
  1139 + getSource('弹窗','LIEFSTYLE','homepage_lifestyle');
  1140 + analy( 'guide_lifestyle');
  1141 + });
  1142 + //防止冒泡事件
  1143 + $('#cover .guide-box').bind('click', function(event){
  1144 + event.stopPropagation();
  1145 + });
  1146 +
  1147 + });
  1148 + }
  1149 +}
1083 /** 1150 /**
1084 * 查询跳转后保留关键字 1151 * 查询跳转后保留关键字
1085 * @return {[type]} [description] 1152 * @return {[type]} [description]
@@ -1530,7 +1597,7 @@ function actionExeTemplate() { @@ -1530,7 +1597,7 @@ function actionExeTemplate() {
1530 * @return {[type]} [description] 1597 * @return {[type]} [description]
1531 */ 1598 */
1532 function actionSearch() { 1599 function actionSearch() {
1533 - var searchDomain = 'http://search.yohobuy.com/product/search/suggest'; 1600 + var searchDomain = 'http://search.yohobuy.com/api/suggest';
1534 1601
1535 $('#query_key').search(searchDomain); 1602 $('#query_key').search(searchDomain);
1536 } 1603 }
@@ -1704,11 +1771,13 @@ function init() { @@ -1704,11 +1771,13 @@ function init() {
1704 actionListenDelCarGoods(); //监听购物车删除 1771 actionListenDelCarGoods(); //监听购物车删除
1705 actionListenCartMore(); // 1772 actionListenCartMore(); //
1706 actionLoginInfo(); //获取登录信息 1773 actionLoginInfo(); //获取登录信息
  1774 + actionCover(); //初次登录弹框
1707 } 1775 }
1708 1776
1709 -init(); 1777 +init();
  1778 +
1710 }); 1779 });
1711 -define("js/product/entry", ["jquery","lazyload","handlebars","source-map"], function(require, exports, module){ 1780 +define("js/product/entry", ["jquery","handlebars","source-map","lazyload"], function(require, exports, module){
1712 /** 1781 /**
1713 * 商品页面打包入口文件 1782 * 商品页面打包入口文件
1714 * @auhtor: xuqi<qi.xu@yoho.cn> 1783 * @auhtor: xuqi<qi.xu@yoho.cn>
@@ -1719,7 +1788,7 @@ require("js/product/list"); @@ -1719,7 +1788,7 @@ require("js/product/list");
1719 1788
1720 require("js/product/hotrank"); 1789 require("js/product/hotrank");
1721 }); 1790 });
1722 -define("js/product/list", ["jquery","lazyload"], function(require, exports, module){ 1791 +define("js/product/list", ["jquery","handlebars","source-map","lazyload"], function(require, exports, module){
1723 /** 1792 /**
1724 * 商品列表页 1793 * 商品列表页
1725 * @author: xuqi<qi.xu@yoho.cn> 1794 * @author: xuqi<qi.xu@yoho.cn>
@@ -1732,14 +1801,15 @@ require("js/product/sort-pager"); @@ -1732,14 +1801,15 @@ require("js/product/sort-pager");
1732 1801
1733 require("js/product/product"); 1802 require("js/product/product");
1734 }); 1803 });
1735 -define("js/product/filter", ["jquery"], function(require, exports, module){ 1804 +define("js/product/filter", ["jquery","handlebars","source-map"], function(require, exports, module){
1736 /** 1805 /**
1737 * 商品筛选逻辑 1806 * 商品筛选逻辑
1738 * @author: xuqi<qi.xu@yoho.cn> 1807 * @author: xuqi<qi.xu@yoho.cn>
1739 * @date: 2015/12/4 1808 * @date: 2015/12/4
1740 */ 1809 */
1741 1810
1742 -var $ = require("jquery"); 1811 +var $ = require("jquery"),
  1812 + Handlebars = require("handlebars");
1743 1813
1744 var checkUnicode = { 1814 var checkUnicode = {
1745 unchecked: '&#xe613;', 1815 unchecked: '&#xe613;',
@@ -1773,6 +1843,13 @@ var $seniorSubWrap = $('.senior-sub-wrap'), @@ -1773,6 +1843,13 @@ var $seniorSubWrap = $('.senior-sub-wrap'),
1773 1843
1774 var seniorHoverTime, hoveredIndex; 1844 var seniorHoverTime, hoveredIndex;
1775 1845
  1846 +// 尺寸 handlebars 模板
  1847 +var sizeTmpl = '{{# size}}<a class="attr {{#if checked}}checked{{/if}}" href="{{href}}">{{name}}</a>{{/ size}}',
  1848 + sizeCache = {}, // 缓存一下尺寸信息
  1849 + $sizeWrap = $('.filter-box .size');
  1850 +
  1851 +sizeTmpl = Handlebars.compile(sizeTmpl);
  1852 +
1776 //清除checkbox选中状态 1853 //清除checkbox选中状态
1777 function clearChecked($checkbox) { 1854 function clearChecked($checkbox) {
1778 $checkbox.removeClass('checked').html(checkUnicode.unchecked); 1855 $checkbox.removeClass('checked').html(checkUnicode.unchecked);
@@ -1820,13 +1897,45 @@ $('.filter-box').on('selectstart', '.attr, .brands-index span', function() { @@ -1820,13 +1897,45 @@ $('.filter-box').on('selectstart', '.attr, .brands-index span', function() {
1820 //【分类】 1897 //【分类】
1821 $('.sort-pre').on('click', 'li', function() { 1898 $('.sort-pre').on('click', 'li', function() {
1822 var $this = $(this), 1899 var $this = $(this),
1823 - index = $this.index(); 1900 + index = $this.index(),
  1901 + id = $this.data('id');
  1902 +
  1903 + if ($this.hasClass('active')) {
  1904 +
  1905 + // 选中时,再次点击取消选中
  1906 + $this.removeClass('active');
  1907 + $sortSub.children(':eq(' + index + ')').addClass('hide');
  1908 + $sizeWrap.addClass('hide');
  1909 + return;
  1910 + }
1824 1911
1825 $this.siblings('.active').removeClass('active'); 1912 $this.siblings('.active').removeClass('active');
1826 $this.addClass('active'); 1913 $this.addClass('active');
1827 1914
1828 $sortSub.children(':not(.hide)').addClass('hide'); 1915 $sortSub.children(':not(.hide)').addClass('hide');
1829 $sortSub.children(':eq(' + index + ')').removeClass('hide'); 1916 $sortSub.children(':eq(' + index + ')').removeClass('hide');
  1917 +
  1918 + if (sizeCache[id]) {
  1919 + $sizeWrap.find('.attr-content').html(sizeCache[id]);
  1920 + $sizeWrap.removeClass('hide');
  1921 + } else {
  1922 + $.ajax({
  1923 + url: '/product/search/sortSize',
  1924 + data: {
  1925 + msort: id
  1926 + }
  1927 + }).then(function(res) {
  1928 + if ($.type(res) === 'array' && res.length) {
  1929 + sizeCache[id] = sizeTmpl({
  1930 + size: res
  1931 + });
  1932 + $sizeWrap.find('.attr-content').html(sizeCache[id]);
  1933 + $sizeWrap.removeClass('hide');
  1934 + } else {
  1935 + $sizeWrap.addClass('hide');
  1936 + }
  1937 + });
  1938 + }
1830 }); 1939 });
1831 1940
1832 //【品牌】 1941 //【品牌】
@@ -1867,10 +1976,17 @@ $brandMore.click(function() { @@ -1867,10 +1976,17 @@ $brandMore.click(function() {
1867 }); 1976 });
1868 1977
1869 //【品牌】索引 1978 //【品牌】索引
1870 -$('.brands-index').on('click', 'span', function() { 1979 +$('.brands-index').on('mouseenter', 'span', function() {
1871 var $this = $(this), 1980 var $this = $(this),
1872 index = $this.data('index'); 1981 index = $this.data('index');
1873 1982
  1983 + if ($this.hasClass('hover')) {
  1984 + return;
  1985 + }
  1986 +
  1987 + $this.siblings('span.hover').removeClass('hover');
  1988 + $this.addClass('hover');
  1989 +
1874 if ($this.index() === 0) { 1990 if ($this.index() === 0) {
1875 1991
1876 //全部 1992 //全部
@@ -2397,7 +2513,7 @@ $('.logo-brand').logoBrand({ @@ -2397,7 +2513,7 @@ $('.logo-brand').logoBrand({
2397 '<div class="good-info">' + 2513 '<div class="good-info">' +
2398 '<div class="item-img">' + 2514 '<div class="item-img">' +
2399 '<a class="good-thumb" target="_blank" href="\{{url}}">' + 2515 '<a class="good-thumb" target="_blank" href="\{{url}}">' +
2400 - '<img class="lazy" data-original="\{{img}}">' + 2516 + '<img class="lazy" data-original="\{{thumb}}">' +
2401 '</a>' + 2517 '</a>' +
2402 '</div>' + 2518 '</div>' +
2403 '<div class="good-detail-text">' + 2519 '<div class="good-detail-text">' +
@@ -2479,6 +2595,10 @@ $('.logo-brand').logoBrand({ @@ -2479,6 +2595,10 @@ $('.logo-brand').logoBrand({
2479 var nowIndex = $(this).index(), 2595 var nowIndex = $(this).index(),
2480 sid = $(this).data('sid'); 2596 sid = $(this).data('sid');
2481 2597
  2598 + if ($(this).hasClass('current')) {
  2599 + return;
  2600 + }
  2601 +
2482 //处理current样式 2602 //处理current样式
2483 $(this).addClass('current').siblings().removeClass('current'); 2603 $(this).addClass('current').siblings().removeClass('current');
2484 $('.floatlayer').find('li').removeClass('current').eq(nowIndex).addClass('current'); 2604 $('.floatlayer').find('li').removeClass('current').eq(nowIndex).addClass('current');
@@ -2497,7 +2617,11 @@ $('.logo-brand').logoBrand({ @@ -2497,7 +2617,11 @@ $('.logo-brand').logoBrand({
2497 $('.floatlayer').on('click', 'li', function() { 2617 $('.floatlayer').on('click', 'li', function() {
2498 var nowIndex = $(this).index(); 2618 var nowIndex = $(this).index();
2499 2619
2500 - $('.hot-cate').find('li').trigger('click'); 2620 + if ($(this).hasClass('current')) {
  2621 + return;
  2622 + }
  2623 +
  2624 + $('.hot-cate').find('li').eq(nowIndex).trigger('click');
2501 2625
2502 //处理current样式 2626 //处理current样式
2503 $(this).addClass('current').siblings().removeClass('current'); 2627 $(this).addClass('current').siblings().removeClass('current');
@@ -4510,6 +4634,18 @@ function pwdFn($obj) { @@ -4510,6 +4634,18 @@ function pwdFn($obj) {
4510 // Tips: 不可以在获得焦点的时候验证,获得焦点和失去焦点的间隔太小,如果中间存在ajax校验的话会出现问题 4634 // Tips: 不可以在获得焦点的时候验证,获得焦点和失去焦点的间隔太小,如果中间存在ajax校验的话会出现问题
4511 // ( ▼-▼ )注册页和信息完善页面接口不同 4635 // ( ▼-▼ )注册页和信息完善页面接口不同
4512 exports.init = function(page) { 4636 exports.init = function(page) {
  4637 +
  4638 + $('#agree-terms').click(function() {
  4639 + if ($(this).attr('notchecked')) {
  4640 + console.log(1);
  4641 + $(this).removeAttr('notchecked');
  4642 + } else {
  4643 + console.log(2);
  4644 + $(this).attr('notchecked', 'true');
  4645 + }
  4646 +
  4647 + });
  4648 +
4513 $registerPage.find('.va').keyup(function() { 4649 $registerPage.find('.va').keyup(function() {
4514 4650
4515 var j, 4651 var j,
@@ -4531,7 +4667,7 @@ exports.init = function(page) { @@ -4531,7 +4667,7 @@ exports.init = function(page) {
4531 4667
4532 } 4668 }
4533 4669
4534 - if (statusLen === 4 && $('#agree-terms').is(':checked')) { 4670 + if (statusLen === 4 && !$('#agree-terms').attr('notchecked')) {
4535 $registerBtn.removeClass('disable').removeAttr('disabled'); 4671 $registerBtn.removeClass('disable').removeAttr('disabled');
4536 } else { 4672 } else {
4537 $registerBtn.addClass('disable').attr('disabled', 'true'); 4673 $registerBtn.addClass('disable').attr('disabled', 'true');
@@ -4608,18 +4744,6 @@ exports.init = function(page) { @@ -4608,18 +4744,6 @@ exports.init = function(page) {
4608 }); 4744 });
4609 4745
4610 // 防止粘贴密码 4746 // 防止粘贴密码
4611 - /*$('#pwd, #repwd').keydown(function (event) {  
4612 -  
4613 - console.log(event.ctrlKey);  
4614 - console.log(isPwd);  
4615 - console.log(event.keyCode);  
4616 -  
4617 - if (event.ctrlKey && isPwd && event.keyCode === 86) {  
4618 - $(this).val(pwdVal);  
4619 - }  
4620 -  
4621 - });*/  
4622 -  
4623 $pwd[0].onpaste = function() { 4747 $pwd[0].onpaste = function() {
4624 return false; 4748 return false;
4625 }; 4749 };
@@ -5288,13 +5412,17 @@ $account.on('keyup', function() { @@ -5288,13 +5412,17 @@ $account.on('keyup', function() {
5288 //密码 5412 //密码
5289 $password.on('blur', function() { 5413 $password.on('blur', function() {
5290 validatePassword(); 5414 validatePassword();
  5415 +
  5416 + if ($capsLock.hasClass('hide')) {
  5417 + return;
  5418 + }
  5419 +
  5420 + $capsLock.addClass('hide');
5291 }).on('keypress', function(e) { 5421 }).on('keypress', function(e) {
5292 - var code = e.which,  
5293 - isShift = e.shiftKey || (code === 16) || false; 5422 + var code = e.which;
5294 5423
5295 //CapsLock检测 5424 //CapsLock检测
5296 - if ((!isShift && (code >= 65 && code <= 90)) ||  
5297 - (isShift && (code >= 97 && code <= 122))) { 5425 + if (code >= 65 && code <= 90) {
5298 $capsLock.removeClass('hide'); 5426 $capsLock.removeClass('hide');
5299 return; 5427 return;
5300 } 5428 }
@@ -5353,7 +5481,7 @@ $('#login-btn').on('click', function() { @@ -5353,7 +5481,7 @@ $('#login-btn').on('click', function() {
5353 if (data.data) { 5481 if (data.data) {
5354 5482
5355 //防止data.data为undefined时下行语句执行出错而导致脚本不能走到complete去处理authing 5483 //防止data.data为undefined时下行语句执行出错而导致脚本不能走到complete去处理authing
5356 - location.href = data.data.href; 5484 + location.href = data.data.session;
5357 } 5485 }
5358 } else { 5486 } else {
5359 $passwordTip.removeClass('hide').children('em').text(data.message); 5487 $passwordTip.removeClass('hide').children('em').text(data.message);
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.