Authored by xuqi

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

... ... @@ -29,6 +29,7 @@ var $chosePanel = $('#chose-panel'),
cbFn,
$allChoseItems,
queryString,
$soonSoldOut = $('.soonSoldOut-tag'),
$yohoPage = $('.yoho-page');
//初始化购物车面板显示
... ... @@ -210,7 +211,12 @@ $yohoPage.on('touchstart', '.color-list .block', function() {
//如果当前有尺码被选中,且数量等于0,则颜色块添加数量为0的样式
if (curGoodNum > 0) {
if ($soonSoldOut.length > 0) {
$allChoseItems.find('.num .left-num').html('即将售罄');
} else {
$allChoseItems.find('.num .left-num').html('剩余' + curGoodNum + '件');
}
$leftNum.val(curGoodNum);
} else {
$allChoseItems.find('.num .left-num').html('');
... ... @@ -263,7 +269,11 @@ $yohoPage.on('touchstart', '.color-list .block', function() {
// 如果当前有尺码被选中,且数量等于0, 否则显示剩余件数
if (curGoodNum > 0 && hasChooseColor) {
if ($soonSoldOut.length > 0) {
$allChoseItems.find('.num .left-num').html('即将售罄');
} else {
$allChoseItems.find('.num .left-num').html('剩余' + curGoodNum + '件');
}
$('#left-num').val(curGoodNum);
} else {
$allChoseItems.find('.num .left-num').html('');
... ...
... ... @@ -15,8 +15,8 @@
{{# list}}
{{#unless @last}}
<li>
<a href="{{href}}">
<img class="lazy" data-original="{{img}}" alt="">
<a href="{{href}}" target= "_blank">
<img class="lazy" data-original="{{img}}" alt="" >
</a>
</li>
{{/unless}}
... ... @@ -26,7 +26,7 @@
{{# list}}
{{#if @last}}
<div class="last-item">
<a href="{{href}}">
<a href="{{href}}" target= "_blank">
<img class="lazy" data-original="{{img}}" alt="">
</a>
</div>
... ... @@ -43,7 +43,7 @@
<ul class="img-list clearfix">
{{# imgBrand}}
<li class="img-item">
<a href="{{href}}">
<a href="{{href}}" target= "_blank">
<img src="{{img}}" alt="">
</a>
</li>
... ... @@ -70,7 +70,7 @@
{{! 广告}}
{{# adbanner}}
<div class="floor-ad">
<a href="{{url}}"><img class="lazy" data-original="{{img}}"/></a>
<a href="{{url}}" target= "_blank"><img class="lazy" data-original="{{img}}"/></a>
</div>
{{/ adbanner}}
... ...
... ... @@ -15,7 +15,7 @@
<ul class="g-list">
{{# list}}
<li>
<a href="{{url}}">
<a href="{{url}}" target= "_blank">
<img class="lazy" data-original="{{src}}" alt="">
</a>
... ... @@ -32,7 +32,7 @@
<ul class="g-list">
{{# list}}
<li>
<a href="{{url}}">
<a href="{{url}}" target= "_blank">
<img class="lazy" data-original="{{src}}" alt="">
<div class="singlegoods-title">
<div class="g-mask"></div>
... ... @@ -52,7 +52,7 @@
<ul class="g-list">
{{# list}}
<li>
<a href="{{url}}">
<a href="{{url}}" target= "_blank">
<img class="lazy" data-original="{{src}}" alt="" /><i class="video-play"></i>
<div class="video-title">
<div class="g-mask"></div>
... ... @@ -94,7 +94,7 @@
<ul class="g-list">
{{# list}}
<li>
<a href="{{url}}">
<a href="{{url}}" target= "_blank">
<img class="lazy" data-original="{{src}}" alt="">
<span class="name g-title">{{name}}</span>
<span class="des g-title">{{des}}</span>
... ...
... ... @@ -8,7 +8,7 @@
<div class="debris-slider clearfix">
<div class="left-col col">
{{# left}}
<a href="{{href}}">
<a href="{{href}}" target= "_blank">
<img class="lazy" data-original="{{img}}">
</a>
{{/ left}}
... ... @@ -17,7 +17,7 @@
<ul class="slide-wrapper">
{{# center}}
<li>
<a href="{{href}}">
<a href="{{href}}" target= "_blank">
<img class="lazy" data-original="{{img}}">
</a>
</li>
... ... @@ -34,7 +34,7 @@
</div>
<div class="right-col col">
{{# right}}
<a href="{{href}}">
<a href="{{href}}" target= "_blank">
<img class="lazy" data-original="{{img}}">
</a>
{{/ right}}
... ...
... ... @@ -70,7 +70,7 @@
{{! 广告}}
{{# adbanner}}
<div class="floor-ad">
<a href="{{url}}"><img class="lazy" data-original="{{img}}"/></a>
<a href="{{url}}" target= "_blank"><img class="lazy" data-original="{{img}}"/></a>
</div>
{{/ adbanner}}
... ...
... ... @@ -5,26 +5,26 @@
<div class="tpl-nav">
<div class="tpl-keywords">
{{#each keyword}}
<a class="keywords{{@index}}" title="{{name}}" href="{{href}}"><img class="lazy" data-original="{{img}}"/></a>
<a class="keywords{{@index}}" title="{{name}}" href="{{href}}" target= "_blank"><img class="lazy" data-original="{{img}}"/></a>
{{/ keyword}}
</div>
<div class="tpl-category clearfix">
{{#each category}}
<a href="{{href}}">{{name}}</a>
<a href="{{href}}" target= "_blank">{{name}}</a>
{{/ category}}
</div>
</div>
<div class="tpl-brands clearfix">
<ul>
{{#each brands}}
<li><a title="{{name}}" href="{{href}}"><img class="lazy" data-original="{{img}}"/></a></li>
<li><a title="{{name}}" href="{{href}}" target= "_blank"><img class="lazy" data-original="{{img}}"/></a></li>
{{/each}}
</ul>
</div>
<div class="tpl-types clearfix">
<ul>
{{#each types}}
<li><a title="{{name}}" href="{{href}}"><img class="lazy" data-original="{{img}}"/></a></li>
<li><a title="{{name}}" href="{{href}}" target= "_blank"><img class="lazy" data-original="{{img}}"/></a></li>
{{/each}}
</ul>
</div>
... ... @@ -32,7 +32,7 @@
<div class="tpl-products clearfix">
<ul>
{{#each products}}
<li><a href="{{href}}" title="{{name}}"><img class="lazy" data-original="{{img}}"/></a></li>
<li><a href="{{href}}" title="{{name}}" target= "_blank"><img class="lazy" data-original="{{img}}"/></a></li>
{{/each}}
</ul>
</div>
... ...
... ... @@ -2,7 +2,7 @@
{{> index/floor-header}}
<ul class="g-list">
{{#each imgHot}}
<li><a class="impo{{@index}}" href="{{href}}"><img class="lazy" data-original="{{img}}"/></a></li>
<li><a class="impo{{@index}}" href="{{href}}" target= "_blank"><img class="lazy" data-original="{{img}}"/></a></li>
{{/each}}
</ul>
</div>
... ...
... ... @@ -3,7 +3,7 @@
<ul class="clearfix">
{{# list}}
<li class="cate-item{{@index}}">
<a href="{{href}}">
<a href="{{href}}" target= "_blank">
<img class="lazy" data-original="{{img}}" alt="">
</a>
</li>
... ...
... ... @@ -4,6 +4,6 @@
<div class="goods-container clearfix">
</div>
<div class="loading">
<a href="{{href}}">Loading...</a>
<a href="{{href}}" target= "_blank">Loading...</a>
</div>
</div>
\ No newline at end of file
... ...
... ... @@ -5,24 +5,24 @@
<div class="tpl-nav">
<div class="tpl-keywords">
{{#each keyword}}
<a class="keywords{{@index}}" title="{{name}}" href="{{href}}"><img class="lazy" data-original="{{img}}"/></a>
<a class="keywords{{@index}}" title="{{name}}" href="{{href}}" target= "_blank"><img class="lazy" data-original="{{img}}"/></a>
{{/ keyword}}
</div>
<div class="tpl-category clearfix">
{{#each category}}
<a href="{{href}}">{{name}}</a>
<a href="{{href}}" target= "_blank">{{name}}</a>
{{/ category}}
</div>
</div>
<div class="tpl-brands clearfix">
{{#each brands}}
<a title="{{name}}" href="{{href}}"><img class="lazy" data-original="{{img}}"/></a>
<a title="{{name}}" href="{{href}}" target= "_blank"><img class="lazy" data-original="{{img}}"/></a>
{{/each}}
</div>
<div class="tpl-types clearfix">
<ul>
{{#each types}}
<li><a title="{{name}}" href="{{href}}"><img class="lazy" data-original="{{img}}"/></a></li>
<li><a title="{{name}}" href="{{href}}" target= "_blank"><img class="lazy" data-original="{{img}}"/></a></li>
{{/each}}
</ul>
</div>
... ...
... ... @@ -4,7 +4,7 @@
<ul class="g-list clearfix">
{{#each imgHot}}
<li>
<a href="{{href}}"><div class="commodity-img">
<a href="{{href}}" target= "_blank"><div class="commodity-img">
{{# tip}}
<i class="top">{{.}}</i>
{{/ tip}}
... ... @@ -18,7 +18,7 @@
</div>
<div class="commodity-brands clearfix">
{{#each brands}}
<a href="{{href}}" title="{{name}}"><img class="lazy" data-original="{{img}}"/></a>
<a href="{{href}}" title="{{name}}" target= "_blank"><img class="lazy" data-original="{{img}}"/></a>
{{/each}}
</div>
</div>
... ...
... ... @@ -9,7 +9,7 @@
<ul class="img-list">
{{# imgBrand}}
<li class="img-item">
<a href="{{href}}"> <img src="{{img}}" alt="{{alt}}"></a>
<a href="{{href}}" target= "_blank"> <img src="{{img}}" alt="{{alt}}"></a>
</li>
{{/ imgBrand}}
</ul>
... ...
... ... @@ -2,7 +2,7 @@
<div class="slide-accordion clearfix">
<ul>
{{#each slide}}
<li><a title="{{name}}" href="{{href}}"><div class="g-mask"></div><img class="lazy" data-original="{{img}}"/></a></li>
<li><a title="{{name}}" href="{{href}}" target= "_blank"><div class="g-mask"></div><img class="lazy" data-original="{{img}}"/></a></li>
{{/each}}
</ul>
</div>
... ...
<div class="slide-container">
<div class="slide-container {{#if pagination}}slide-thumb-container{{/if}}">
<div class="slide-wrapper">
<ul>
{{# list}}
<li>
<a href="{{href}}">
<li style="backgroundColor:{{bgColor}}">
<a href="{{href}}" target= "_blank">
<img class="lazy" data-original="{{img}}" alt="">
</a>
{{# tips}}
... ... @@ -38,3 +38,4 @@
</div>
{{/if}}
</div>
<div class="slide-container-placeholder {{#if pagination}}slide-thumb-container-placeholder{{/if}}"></div>
\ No newline at end of file
... ...
... ... @@ -81,7 +81,7 @@ var $ = require('yoho.jquery'),
that._createHelper();
brandHtml = '\{{#brandList logoBrand}}' +
'<a href="\{{href}}"><img class="lazy" data-original="\{{img}}" alt=""></a>' +
'<a href="\{{href}}" target= "_blank"><img class="lazy" data-original="\{{img}}" alt=""></a>' +
'\{{/brandList}}';
brandTpl = Handlebars.compile(brandHtml);
that.$element.html(brandTpl(data));
... ...
... ... @@ -94,6 +94,7 @@ module.exports = function(data) {
var $load = $('.loading a');
var load = new InfiniteLoad({
index: 1,
isload: false,
offset: {
height: function() {
return parseFloat($container.offset().top) + parseFloat($container.height()) - 200;
... ... @@ -101,28 +102,35 @@ module.exports = function(data) {
}
});
var loadAjax;
var url = data.url;
var url = data.url,
count = data.count,
rows = data.rows;
data.pageIndex = 0;
delete data.url;
delete data.count;
delete data.rows;
loadAjax = function(url, data, count) {
var options = {
type: 'POST',
url: url,
data: data,
success: function(data) {
var code = data.code;
success: function(result) {
var code = result.code;
var myTemplate,len,pos;
if (code === 200) {
len = data.goods.length % count;
pos = data.goods.length - len - 1;
len = result.goods.length % count;
pos = result.goods.length - len - 1;
data.goods.splice(pos, len);
result.goods.splice(pos, len);
myTemplate = Handlebars.compile(load.tpl);
$container.append(myTemplate(data.goods));
$container.append(myTemplate(result.goods));
data.pageIndex = data.pageIndex + result.goods.length;
//懒加载插件貌似有点问题,图片先直接展示
lazyload($container.find('img.lazy'));
... ... @@ -141,17 +149,14 @@ module.exports = function(data) {
}
};
options.data = data;
$.ajax(options);
};
load.on('after', function(p) {
data = $.extend({}, data, {
pageIndex: p.index
});
data.pageCount = data.count * data.rows[1];
data.pageCount = count * rows[1];
loadAjax(url, data);
});
... ... @@ -187,7 +192,7 @@ module.exports = function(data) {
load.tpl += ' {{/ tags}}';
load.tpl += ' </div>';
load.tpl += ' <div class="good-detail-img">';
load.tpl += ' <a class="good-thumb" href="{{url}}">';
load.tpl += ' <a class="good-thumb" href="{{url}}" target= "_blank">';
load.tpl += ' <img class="lazy" data-original="{{thumb}}">';
load.tpl += ' </a>';
load.tpl += ' {{# isFew}}';
... ... @@ -199,7 +204,7 @@ module.exports = function(data) {
load.tpl += ' {{/if}}';
load.tpl += ' </div>';
load.tpl += ' <div class="good-detail-text">';
load.tpl += ' <a href="{{url}}">{{name}}</a>';
load.tpl += ' <a href="{{url}}" target= "_blank">{{name}}</a>';
load.tpl += ' <p class="price">';
load.tpl += ' <span class="sale-price{{#unless marketPrice}}prime-cost{{/unless}}">';
load.tpl += ' ¥{{salePrice}}';
... ... @@ -212,16 +217,12 @@ module.exports = function(data) {
load.tpl += '</div>';
load.tpl += '{{/each}}';
data = $.extend({}, data, {
pageIndex: p.index
});
data.pageCount = data.count * data.rows[0];
data.pageCount = count * rows[0];
loadAjax(url, data, data.count);
load.emit();
//load.emit();
});
load.init();
... ...
... ... @@ -6,12 +6,29 @@
// overflow: hidden;
/*大banner*/
.slide-container {
position: relative;
position: absolute;
left: 0;
right: 0;
height: 387px;
&.slide-thumb-container {
height: 440px;
}
img {
display: block;
}
}
.slide-container-placeholder {
height: 387px;
width: 100%;
&.slide-thumb-container-placeholder {
height: 440px;
}
}
/*大banner大图*/
.slide-wrapper {
position: relative;
... ... @@ -37,6 +54,13 @@
width: 100%;
height: 100%;
a {
display: block;
height: 100%;
width: 990px;
margin: 0 auto;
}
&:first-child {
display: block;
}
... ... @@ -50,7 +74,7 @@
/*大图上的左右切换按钮*/
.slide-switch {
display: none;
display: block;
/* @include opacity(0);
@include transition-property(opacity);
@include transition-duration(.2s);
... ... @@ -68,11 +92,13 @@
@include opacity(0.55);
&.prev {
left: 0;
left: 50%;
margin-left: -495px;
}
&.next {
right: 0;
right: 50%;
margin-right: -495px;
}
&:hover{
... ... @@ -88,7 +114,8 @@
/*大banner缩略图*/
.thumb-pagination {
margin: 7px 0 0;
width: 990px;
margin: 7px auto 0;
li {
position: relative;
... ... @@ -223,6 +250,17 @@
height: 100%;
}
.slide-switch {
a.prev {
left: 0;
margin-left: 0;
}
a.next {
right: 0;
margin-right: 0;
}
}
img {
max-width: 100%;
max-height: 100%;
... ...
... ... @@ -3,12 +3,50 @@
.home-page {
width: 1150px;
.slide-container{
height: 450px;
&.slide-thumb-container {
height: 510px;
}
}
.slide-wrapper {
height: 450px;
li {
a {
width: 1150px;
}
}
}
.slide-container-placeholder {
height: 450px;
&.slide-thumb-container-placeholder {
height: 510px;
}
}
.slide-switch {
a {
&.prev {
margin-left: -575px;
}
&.next {
margin-right: -575px;
}
}
}
.thumb-pagination {
margin: 6px 0 0;
width: 1148px;
margin: 6px auto 0;
padding: 0 0 0 2px;
li {
... ...
... ... @@ -46,14 +46,20 @@ class CommonController extends WebAction
HomeModel::COOKIE_NAME_LIFESTYLE
);
$channel = $this->post('type', '');
$pageIndex = $this->post('pageIndex', 1);
$pageCount = $this->post('pageCount', 8);
$pageIndex = intval($this->post('pageIndex', 0));
$pageCount = intval($this->post('pageCount', 8));
if (! in_array($channel, $channels)) {
break;
} else {
$data = HomeModel::getNewArrival($channel);
}
$result = array_slice($data, ($pageIndex - 1) * $pageCount, $pageCount);
if($pageIndex < 0) {
$pageIndex = 0;
}
if($pageCount < 0 || $pageCount > 50) {
$pageCount = 20;
}
$result = array_slice($data, $pageIndex, $pageCount);
if (empty($result)) {
break;
}
... ...