Authored by 周少峰

Merge branch 'feature/mBrandShop' of http://git.dev.yoho.cn/web/yohobuywap into feature/mBrandShop

... ... @@ -4,7 +4,7 @@
var $ = require('jquery'),
IScroll = require('iscroll/iscroll-probe'),
// lazyLoad = require('yoho.lazyload'),
lazyLoad = require('yoho.lazyload'),
Swiper = require('yoho.iswiper'),
activeTab,
myScroll,
... ... @@ -19,6 +19,349 @@ var $ = require('jquery'),
$nav2 = $('#pos-list'),
isIphone = navigator.userAgent.indexOf('iPhone') > 0 ? true : false;//判断浏览器类型
var tip = require('../plugin/tip'),
filter = require('../plugin/filter'),
loading = require('../plugin/loading');
var $goodsContainer = $('#goods-container'),
$goodsChildren = $goodsContainer.children(),
$ngc = $($goodsChildren.get(0)),
$pgc = $($goodsChildren.get(1)),
$dgc = $($goodsChildren.get(2));
var winH = $(window).height(),
noResult = '<p class="no-result">未找到相关搜索结果</p>';
//默认筛选条件
var defaultOpt = require('./query-param');
var $listNav = $('#list-nav'),
//导航数据信息
navInfo = {
newest: {
order: 1,
reload: true,
page: 0,
end: false
},
price: {
order: 1,
reload: true,
page: 0,
end: false
},
discount: {
order: 1,
reload: true,
page: 0,
end: false
}
},
$pre = $listNav.find('.active'), //纪录进入筛选前的active项,初始为选中项
searching;
function search(opt) {
var setting = {},
ext,
att,
nav, navType,
page;
if (searching) {
return;
}
if (opt) {
//筛选项变更则重置reload为true
for (att in navInfo) {
if (navInfo.hasOwnProperty(att)) {
navInfo[att].reload = true;
}
}
//处理active状态
$listNav.children('.active').removeClass('active');
$pre.addClass('active');
switch (opt.type) {
case 'gender':
ext = {
gender: opt.id
};
break;
case 'brand':
ext = {
brand: opt.id
};
break;
case 'sort':
ext = {
sort: opt.id
};
break;
case 'color':
ext = {
color: opt.id
};
break;
case 'size':
ext = {
size: opt.id
};
break;
case 'price':
ext = {
price: opt.id
};
break;
case 'discount':
ext = {
discount: opt.id
};
break;
}
$.extend(defaultOpt, ext); //扩展筛选项
}
//导航类别
if ($pre.hasClass('new')) {
navType = 'newest';
} else if ($pre.hasClass('price')) {
navType = 'price';
} else if ($pre.hasClass('discount')) {
navType = 'discount';
}
nav = navInfo[navType];
page = nav.page + 1;
if (nav.reload) {
page = 1;
} else if (nav.end) {
//不需要重新加载并且数据请求结束
return;
}
$.extend(setting, defaultOpt, {
type: navType,
order: nav.order,
page: page
});
searching = true;
loading.showLoadingMask();
$.ajax({
type: 'GET',
url: '/product/newsale/selectNewSale',
data: setting,
success: function(data) {
var $container,
num;
switch (navType) {
case 'newest':
$container = $ngc;
break;
case 'price':
$container = $pgc;
break;
case 'discount':
$container = $dgc;
break;
}
if (data === ' ') {
nav.end = true;
if (nav.reload) {
$container.html(noResult);
}
} else {
if (nav.reload) {
$container.html(data);
lazyLoad($container.find('.lazy'));
} else {
num = $container.find('.good-info').length;
$container.append(data);
//lazy good-infos who append in
lazyLoad($container.find('.good-info:gt(' + (num - 1) + ') .lazy'));
}
}
nav.reload = false;
nav.page = page;
searching = false;
loading.hideLoadingMask();
window.rePosFooter();
},
error: function() {
tip.show('网络断开连接了~');
searching = false;
loading.hideLoadingMask();
}
});
}
$.ajax({
type: 'GET',
url: '/product/newsale/filter',
data: defaultOpt,
success: function(data) {
$goodsContainer.append(data);
//初始化filter&注册filter回调
filter.initFilter({
fCbFn: search,
hCbFn: function() {
//切换active状态到$pre上
$pre.addClass('active');
$pre.siblings('.filter').removeClass('active');
},
missStatus: true
});
}
});
$listNav.bind('contextmenu', function(e) {
return false;
});
$listNav.on('touchend touchcancel', function(e) {
var $this = $(e.target).closest('li'),
nav,
navType,
$active;
e.preventDefault();
if (typeof $this === 'undefined' || $this.length === 0) {
return;
}
if ($this.hasClass('filter')) {
//筛选面板切换状态
if ($this.hasClass('active')) {
filter.hideFilter();
//点击筛选钱的active项回复active
$pre.addClass('active');
$this.removeClass('active');
} else {
$pre = $this.siblings('.active');
$pre.removeClass('active');
$this.addClass('active');
filter.showFilter();
}
} else {
if ($this.hasClass('new')) {
navType = 'newest';
} else if ($this.hasClass('price')) {
navType = 'price';
} else if ($this.hasClass('discount')) {
navType = 'discount';
}
nav = navInfo[navType];
if ($this.hasClass('active')) {
//最新无排序切换
if ($this.hasClass('new')) {
return;
}
if ($this.hasClass('price') || $this.hasClass('discount')) {
// 价格/折扣切换排序状态
$this.find('.icon > .iconfont').toggleClass('cur');
$pre = $this; //更新pre为当前项
nav.reload = true; //重置reload,HTML会被替换为逆序的HTML
nav.order = nav.order === 0 ? 1 : 0; //切换排序
}
} else {
$active = $this.siblings('.active');
$pre = $this; //$pre为除筛选导航的其他导航项,若当前active的为筛选,则把$pre置为当前点击项
if ($active.hasClass('filter')) {
//若之前active项为筛选,则隐藏筛选面板
filter.hideFilter();
} else {
//切换container显示
$goodsContainer.children('.container:not(.hide)').addClass('hide');
switch (navType) {
case 'newest':
$ngc.removeClass('hide');
break;
case 'price':
$pgc.removeClass('hide');
break;
case 'discount':
$dgc.removeClass('hide');
break;
}
}
$active.removeClass('active');
$this.addClass('active');
}
if (nav.reload) {
search();
}
}
e.stopPropagation();
});
function scrollHandler() {
//当scroll到1/4$goodsContainer高度后继续请求下一页数据
if ($(window).scrollTop() + winH >
$(document).height() - 0.25 * $goodsContainer.height() - 50) {
if ($pre !== undefined) {
search();
}
}
}
//srcoll to load more
$(window).scroll(function() {
window.requestAnimationFrame(scrollHandler);
});
//初始请求最新第一页数据
search();
$listNav.on('touchstart', 'li', function(e) {
$(this).addClass('bytouch');
}).on('touchend touchcancel', function() {
$listNav.find('li').removeClass('bytouch');
});
// lazyLoad($('img.lazy'));
if ($('.banner-swiper').find('li').size() > 1) {
... ... @@ -47,53 +390,53 @@ if ($('.multi-browse').find('li').size() > 1) {
}
function tabChange(dom, index) {
var li = dom.eq(index);
var li = dom.eq(index),
sortSize = li.find('.iconfont').length;
dom.removeClass('active');
dom.removeClass('color');
li.addClass('active');
dom.removeClass('color');
li.addClass('color');
li.addClass('active');
}
$.jqtab = function(nav, nav1, main) {
$(nav + ' li, ' + nav1 + ' li').on('touchstart', function() {
var index = $(this).index();
$.jqtab = function(nav, posNav, main) {
$(nav + ' li, ' + posNav + ' li').on('touchstart', function() {
var index = $(this).index(),
activeTab = $(this).attr('tab');
console.log(activeTab)
tabChange($(nav + ' li'), index);
tabChange($(nav1 + ' li'), index);
tabChange($(posNav + ' li'), index);
$(main).hide();
$('#' + activeTab).fadeIn();
return false;
});
};
$.jqtab('#nav','#pos-nav', '.main');
$.jqtab('#nav','#pos-nav','.main');
$(function(){
// if (!isIphone) {
// return;
// }
$('#wrapper').addClass('scroll-wrapper');
myScroll = new IScroll('#wrapper', {
probeType: 3,
mouseWheel: true,
click: true
});
lazyLoad($('img.lazy'));
setTimeout(function(){
myScroll = new IScroll('#wrapper', {
probeType: 3,
mouseWheel: true,
click: true
});
document.addEventListener('touchmove', function(e) {
e.preventDefault();
}, false);
if (!isIphone) {
return;
}
// lazyLoad($('img.lazy'), {
// container: $("#scroller")
// });
myScroll.on('scroll', function() {
var sTop = -this.y;
myScroll.on('scroll', function() {
var sTop = -this.y;
if (sTop < imgH) {
if (!$nav1.hasClass('hide')) {
... ... @@ -153,7 +496,23 @@ $(function(){
});
}
}
$("#scroller").trigger('scroll');
});
}, 1000)
// console.log(lazyLoad)
// console.log($('#scroller').height())
document.addEventListener('touchmove', function(e) {
e.preventDefault();
}, false);
if (!isIphone) {
return;
}
})
//window onload 后重新refresh iscroll
... ... @@ -168,13 +527,3 @@ window.onload = function() {
scH = $('#scroller').outerHeight();
};
// $(nav + ' li, ' + nav1 + ' li').on('touchstart', function() {
// $.ajax({
// url:,
// data:,
// xxx:,
// success:function(data){
// $('#nav-main').append(data);
// }
// });
// });
\ No newline at end of file
... ...
.shop-index {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
overflow: hidden;
.branner-top {
width: 100%;
height: 200rem / $pxConvertRem;
position: relative;
overflow: hidden;
}
.logo {
position: absolute;
overflow: hidden;
left: 30rem / $pxConvertRem;
bottom: 30rem / $pxConvertRem;
width: 100rem / $pxConvertRem;
height: 100rem / $pxConvertRem;
}
.store-name {
color: #fff;
font-size: 28rem / $pxConvertRem;
position: absolute;
overflow: hidden;
left: 148rem / $pxConvertRem;
bottom: 20rem / $pxConvertRem;
}
.collect {
width: 128rem / $pxConvertRem;
height: 50rem / $pxConvertRem;
position: absolute;
bottom: 30rem / $pxConvertRem;
right: 30rem / $pxConvertRem;
border-radius: 10rem / $pxConvertRem;
text-align: center;
background: image-url('product/collect.png') no-repeat;
background-size: contain;
}
.nav {
width: 100%;
height: 88rem / $pxConvertRem;
margin: 0;
padding: 0;
border: 0;
font: inherit;
vertical-align: baseline;
list-style: none;
font-size: 0.7rem;
background: #fff;
overflow: hidden;
border-sizing: border-box;
border-bottom: 2rem / $pxConvertRem solid #e1e1e1;
li{
color: #b1b1b1;
display: block;
height: 28rem /$pxConvertRem;
float: left;
line-height: 28rem /$pxConvertRem;
width: 24%;
text-align: center;
border-left: 1rem / $pxConvertRem solid #e1e1e1;
margin-top: 30rem / $pxConvertRem;
border-sizing: border-box;
color: #b1b1b1;
&:first-child {
border-left: none;
}
a {
color: #b1b1b1;
}
}
.color {
color: #000;
}
}
.main {
background: #f0f0f0;
padding-bottom: 1rem;
overflow: hidden;
}
.banner-area {
@extend .banner-top;
.banner-swiper ul {
height: 6.5rem;
}
.swiper-pagination {
bottom: 1.5rem;
}
}
.hide {
display: hidden;
}
.coupon {
width: 100%;
padding: 30rem / $pxConvertRem 0;
overflow: hidden;
img {
width: 245rem / $pxConvertRem;
height: 120rem / $pxConvertRem;
vertical-align: top;
margin-left: 30rem / $pxConvertRem;
float: left;
}
}
.multi-brands {
width: 100%;
height: 270rem / $pxConvertRem;
background: #fff;
border: 1px solid #e1e1e1;
border-top: none;
font-size: 20px;
text-align: center;
padding-top: 25rem / $pxConvertRem;
margin-bottom: 30rem / $pxConvertRem;
overflow: hidden;
h2 {
font-size: 28rem / $pxConvertRem;
}
}
.multi-browse {
margin-top: 50rem / $pxConvertRem;
@extend .swiper-container
}
.brand-img {
margin-left: 30rem / $pxConvertRem;
width: 30%;
height: 55%;
overflow: hidden;
padding-bottom: 20rem / $pxConvertRem;
float: left;
p {
font-size: 25rem / $pxConvertRem;
color: #b1b1b1;
padding-top: 10rem / $pxConvertRem;
}
}
.spring {
margin: 0;
overflow: hidden;
li {
width: 50%;
float: left;
text-align: center;
list-style: none;
display: list-item;
img {
width: 90%;
border-radius: 10rem / $pxConvertRem;
vertical-align: top;
}
}
}
.popularity-title {
background: #fff;
border-bottom: 1px solid #e8e8e8;
text-align: center;
line-height: 98rem / $pxConvertRem;
font-size: 0.8rem;
margin-top: 1rem;
position: relative;
}
.more {
position: absolute;
right: .75rem;
top: 0;
bottom: 0;
color: #b0b0b0;
font-size: 1.25rem;
font-family: "iconfont" !important;
font-style: normal;
text-decoration: none;
}
.product-list {
margin: 0;
padding: 0 0 30rem / $pxConvertRem 30rem / $pxConvertRem;
overflow: hidden;
background: #fff;
border-bottom: 30rem / $pxConvertRem solid #f0f0f0;
li {
width: 275rem / $pxConvertRem;
height: 368rem / $pxConvertRem;
margin-top: 50rem / $pxConvertRem;
margin-right: 30rem / $pxConvertRem;
float: left;
text-align: center;
list-style: none;
img {
width: 100%;
vertical-align: top;
}
}
}
.list-price {
height: 60rem / $pxConvertRem;
background: #ABACAC;
color: #FFFFFF;
font-size: 22rem / $pxConvertRem;
margin-top: -60rem / $pxConvertRem;
position: relative;
opacity: 0.7;
padding-left: 15rem / $pxConvertRem;
p {
margin: 0;
line-height: 32rem / $pxConvertRem;
text-align: left;
}
}
.red {
color: red;
}
.icon {
position: relative;
i {
position: absolute;
}
.up {
top: -5rem / $pxConvertRem;
left: 8rem / $pxConvertRem;
}
.down {
top: 8rem / $pxConvertRem;
left: 8rem / $pxConvertRem;
}
}
.iconfont {
color: #b1b1b1;
}
.active .cur {
color: #000;
}
.goods-container {
position: relative;
min-height: 440rem / $pxConvertRem;
padding-left: 0.375rem;
padding-top: 20rem / $pxConvertRem;
border-bottom: 1px solid #e0e0e0;
}
.discount-area {
@extend .discount-page;
.list-nav li {
display: block;
height: 28rem / $pxConvertRem;
float: left;
line-height: 28rem / $pxConvertRem;
width: 24%;
text-align: center;
border-left: 1px solid #e1e1e1;
margin-top: 30rem / $pxConvertRem;
margin-bottom: 30rem / $pxConvertRem;
border-sizing: border-box;
span {
font-size: 0.7rem;
}
&:first-child {
border-left: none;
}
}
.list-nav .icon .up {
top: -6rem / $pxConvertRem;
}
.list-nav .icon .down {
top: 8rem / $pxConvertRem;
}
.goods-container {
padding-top: 30rem / $pxConvertRem;
padding-bottom: 100rem / $pxConvertRem;
}
.active a{
color: #b1b1b1;
}
}
.search-area {
@extend .search-page;
}
.hide {
display: none;
}
.nav-title {
position: absolute;
margin-left: 200rem / $pxConvertRem;
height: 100%;
font-size: 36rem / $pxConvertRem;
color: #fff;
font-weight: bold;
top: 0;
right: 0;
left: 0;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
text-align: center;
}
.shop-foot-wrapper {
position: absolute;
bottom: 0;
display: table;
width: 100%;
height: 2.2rem;
line-height: 2.2rem;
font-size: 0.7rem;
background: #fff;
border-top: 1px solid #eaeaea;
ul {
display: table-row;
}
li {
display: table-cell;
text-align: center;
.wall {
width: 0;
height: 0.8rem;
margin-top: 0.7rem;
float: right;
border-right: 1px solid #eaeaea;
display: inline-block;
}
}
.sub-group {
position: absolute;
background: #fff;
border-right: 1px solid #eaeaea;
border-radius: 5px;
bottom: 2.6rem;
width: 30%;
dl {
width: 80%;
margin: 0 auto;
}
dd {
line-height: 2rem;
text-align: center;
border-top: 1px solid #eaeaea;
}
dd:first-child {
border-top: 0;
}
}
.sharp {
position: absolute;
width: 100%;
height: 8px;
background: image-url("/img/product/sharp.png") no-repeat center center;
}
}
.bytouch{
background:#eee;
}
}
\ No newline at end of file
... ...
... ... @@ -34,8 +34,8 @@
</li>
</ul>
<div id="home-page">
<div id="nav-main" class="main">
<div id="home-page" class="main">
<div id="nav-main" >
{{#unless brands}}
<div class="multi-brands">
<h2>品牌一览</h2>
... ... @@ -87,7 +87,7 @@
<img src="{{listUrl}}">
</a>
<div class="list-price">
<p>VANS AP M BERZE</p>
<p>{{productName}}</p>
<p><span class="red">{{originalPrice}}</span>
<span>{{presentPrice}}</span>
</p>
... ... @@ -96,6 +96,7 @@
{{/each}}
</ul>
</div>
<div class="discount-area">
{{> product/goods-nav-top}}
</div>
... ... @@ -103,7 +104,7 @@
<div id="new-arrival" class=""></div>
<div id="popularity" class=""></div>
</div>
{{> product/shop-footer}}
<ul id="pos-nav" class="nav hide">
<li class="active color">首页</li>
<li>上新</li>
... ...
... ... @@ -394,6 +394,5 @@
{{#if shopPage}}
<script>
seajs.use('js/product/shop');
seajs.use('js/product/newsale/discount');
</script>
{{/if}}
... ...
... ... @@ -741,6 +741,21 @@ class IndexController extends AbstractAction
),
'is_soon_sold_out' => false
)
),
'filter' => array(
'classify' => array(
array(
'default' => true,
'title' => 'aaa',
'name' => 'name',
'dataType' => '1',
'subs' => array(
'chosed' => true,
'dataId' => '1',
'name' => 'bbb',
)
)
)
)
);
... ...