Authored by zhangxiaoru

冲突ã

... ... @@ -38,7 +38,7 @@ let _processCateData = (list, channel) => {
secondItem.url = helpers.urlFormat('/', {
sort: _.get(secondItem, 'relationParameter.sort'),
sort_name: secondItem.categoryName,
gender: genderMap[channel] || ''
gender: genderMap[key] || ''
}, 'list');
});
... ... @@ -47,14 +47,14 @@ let _processCateData = (list, channel) => {
url: helpers.urlFormat('/', {
sort: _.get(firstItem, 'relationParameter.sort'),
sort_name: firstItem.categoryName,
gender: genderMap[channel] || ''
gender: genderMap[key] || ''
}, 'list')
});
} else {
firstItem.url = helpers.urlFormat('/', {
sort: _.get(firstItem, 'relationParameter.sort'),
sort_name: firstItem.categoryName,
gender: genderMap[channel] || ''
gender: genderMap[key] || ''
}, 'list');
}
});
... ...
<div class="resources">
<!--banner-->
{{#each result.focus1}}
{{> resources/banner-top}}
<div class="banner-top">
<div class="banner-swiper swiper-container">
<ul class="swiper-wrapper">
{{#each data}}
{{#if @first}}
<li class="swiper-slide">
<a href="{{url}}">
<img src="{{image src 750 364}}">
</a>
</li>
{{^}}
<li class="swiper-slide">
<a href="{{url}}">
<img class="swiper-lazy" data-src="{{image src 750 364}}">
</a>
<div class="swiper-lazy-preloader"></div>
</li>
{{/if}}
{{/each}}
</ul>
</div>
<div class="swiper-pagination">
<div class="pagination-inner">
</div>
</div>
</div>
{{/each}}
{{#each result.title_image}}
... ...
/**
* 热销排行页面
* @author: zxr<xiaoru.zhang@yoho.cn>
* @date: 2016/09/22
*/
'use strict';
const newsaleModel = require('../models/newsale');
const headerModel = require('../../../doraemon/models/header');
let channels = {
boys: '1,3',
girl: '2,3',
kids: '1,2,3',
lifestyle: '1,2,3'
};
const index = (req, res, next) => {
let channel = req.yoho.channel || 'boys';
let codeKey = '';
switch (channel) {
case 'boys': // 男生
codeKey = '3cf2c1be5217fbab6009ce83959e1e12';
break;
case 'girls': // 女生
codeKey = '1cf7f9f10e2a2670e73d05c568793ad9';
break;
case 'kids': // 潮童
codeKey = '57457adececa6c748b29c90cad0ae940';
break;
case 'lifestyle': // 创意生活
codeKey = '04953a61cbf1db426a681e55d496d2fe';
break;
}
newsaleModel.getHotRank(codeKey).then((result) => {
res.render('newsale/hotrank', {
module: 'product',
page: 'hot-rank',
title: '热销排行榜',
pageHeader: headerModel.setNav({
navTitle: '热销排行榜'
}),
pageFooter: true,
headerBanner: result
});
}).catch(next);
};
const selectHotrank = (req, res, next) => {
let sort = req.query.sort;
let tab_id = req.query.tab_id;
let limit = 50;
let page = req.query.page || 1;
let notab = req.query.notab || 0;
let yhChannel = req.query.yh_channel || 1;
let gender = req.query.gender || req.cookies._Channel && channels[req.cookies._Channel] || '1,3';
newsaleModel.selectHotrank(yhChannel, gender, sort, tab_id, limit, page, notab).then((result) => {
res.render('newsale/hotlist', {
layout: false,
tabs: result.tabs,
goods: result.goods
});
}).catch(next);
};
module.exports = {
index,
selectHotrank
};
... ...
... ... @@ -921,6 +921,9 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => {
};
let _getShopsInfo = (brandId) => {
if(!brandId) {
return Promise.resolve([]);
}
return api.get('', {
method: 'app.shop.queryShopsByBrandId',
brand_id: _.toString(brandId)
... ... @@ -1006,7 +1009,7 @@ let getProductData = (data) => {
}
result = result.data;
return Promise.all([
_getShopsInfo(result.brandInfo.brandId),
_getShopsInfo(_.get(result, 'brandInfo.brandId', 0)),
_getPromotionInfo(result.productSkn),
comment.getCommentInfo({
productId: result.productId
... ...
'use strict';
const api = global.yoho.API;
const helpers = global.yoho.helpers;
const _ = require('lodash');
const serviceAPI = global.yoho.ServiceAPI;
const logger = global.yoho.logger;
const getHotRank = (codeKey) => {
return serviceAPI.get('operations/api/v5/resource/get', {
content_code: codeKey
}).then((result) => {
if (result && result.code === 200) {
let formData = {};
if (result.data[0].data.length === 1) {
formData.url = result.data[0].data[0].url;
formData.img = result.data[0].data[0].src;
} else {
let list = [];
_.forEach(result.data[0].data, function(val) {
list.push({
url: val.url,
img: val.src
});
});
formData.list = list;
}
return formData;
} else {
logger.error('getHotRank data return code is not 200');
return {};
}
});
};
const selectHotrank = (yhChannel, gender, sort, tab_id, limit, page, notab) => {
let param = {
method: 'app.search.top',
gender: gender,
yh_channel: yhChannel,
page: page,
limit: limit
};
if (sort) {
param.sort = sort;
}
if (tab_id) {
param.tab_id = tab_id;
}
console.log(param);
return api.get('', param).then((result) => {
if (result && result.code === 200 && result.data.product_list) {
let formData = {};
if (notab && parseInt(notab, 10) === 0 && result.data.tabs) {
let tabs = [];
_.forEach(result.data.tabs, function(val, index) {
let obj = {};
if (index === 0) {
obj = _.assign(obj, {
focus: true
});
}
obj = _.assign(obj, {
title: val,
dataId: index
});
tabs.push(obj);
});
formData.tabs = tabs;
}
if (result.data.product_list && result.data.product_list.length !== 0) {
let goods = [];
_.forEach(result.data.product_list, function(data, index) {
let one = {};
if (data === null || !data.product_skn || !data.goods_list[0]) {
return false;
}
one = _.assign(one, {
url: '/product/pro_' + data.product_id + '_' + data.goods_list[0].goods_id
+ '/' + data.cn_alphabet + '.html',
thumb: data.default_images,
rank: limit * (page - 1) + index + 1,
name: data.product_name,
salePrice: data.sales_price
});
if (data.sales_phrase) {
one = _.assign(one, {
sales_phrase: data.sales_phrase
});
}
goods.push(one);
});
formData.goods = goods;
}
return formData;
}
});
};
module.exports = {
getHotRank,
selectHotrank
};
... ...
... ... @@ -33,6 +33,10 @@ const list = require(`${cRoot}/list`);
// 新品到着 controller
const news = require(`${cRoot}/new`);
//热销排行榜
const newsale = require(`${cRoot}/newsale`);
// routers
// /pro_136349_455445/HEARTSOFARMianMaShuJiaoXiuXianKuPS1684.html
... ... @@ -98,4 +102,7 @@ router.get('/new', news.newGoods);
router.get('/new/selectNewSale', news.selectNewSale);
router.get('/new/filter', news.filter);
router.get('/newsale/hotrank', newsale.index);// 热销排行榜
router.get('/newsale/selectHotrank', newsale.selectHotrank);// 热销排行榜
module.exports = router;
... ...
{{#if tabs}}
<div class="s-goods-nav goods-nav">
<ul class="swiper-wrapper clearfix">
{{# tabs}}
{{# title}}
<li class="swiper-slide nav-item {{#if @first}} active{{/if}}">
<span data-sort="{{ params}}" data-id="{{ id}}" >{{ name}}</span>
</li>
{{/ title}}
{{/ tabs}}
</ul>
</div>
{{/if}}
<div class="rank-main">
<ul>
{{# goods}}
<li>
<a class="clearfix" href="{{url}}">
<div class="item-img">
<img class="lazy" data-original="{{image thumb 75 114}}">
</div>
<div class="item-content">
<i class="rank-icon top">{{rank}}</i>
<h2 {{# sales_phrase}}class="hasActive"{{/ sales_phrase}}>{{name}}</h2>
{{# active}}
<p>{{.}}</p>
{{/ active}}
{{#sales_phrase}}
<p>{{.}}</p>
{{/sales_phrase}}
<p>
{{#salePrice}}¥{{.}}{{/salePrice}}{{#price}}
<b>¥{{.}}</b>{{/price}}
</p>
</div>
</a>
</li>
{{/ goods}}
</ul>
</div>
\ No newline at end of file
... ...
<div class="discount-page yoho-page">
{{# headerBanner}}
{{> newsale/banner-swipe-and-single}}
{{/ headerBanner}}
<div id="hotRank"></div>
{{> common/suspend-cart}}
</div>
... ...
... ... @@ -22,7 +22,7 @@
{{^}}
<div class="banner-top-single">
<a href={{url}}>
<img class="img" src="{{image img 450 600}}">
<img class="img" src="{{image src 450 600}}">
</a>
</div>
{{/if}}
... ...
{{#if list}}
<div class="banner-top">
<div class="banner-swiper swiper-container">
<ul class="swiper-wrapper">
{{# list}}
<li class="swiper-slide">
<a href="{{#if url}}{{url}}{{else}}javascript:;{{/if}}">
<img class="swiper-lazy" data-src="{{image img 640 240}}">
</a>
<div class="swiper-lazy-preloader"></div>
</li>
{{/ list}}
</ul>
</div>
<div class="swiper-pagination">
<div class="pagination-inner">
</div>
</div>
</div>
{{^}}
<div class="banner-top-single">
<a href="{{#if url}}{{url}}{{else}}javascript:;{{/if}}">
<img class="img" src="{{image img 640 240}}">
</a>
</div>
{{/if}}
\ No newline at end of file
... ...
... ... @@ -14,16 +14,17 @@ var $nav = $('.category-nav'),
require('../common');
(function() {
function resetHeight() {
var $header = $('.yoho-header'),
$search = $('#search-input');
var h = $(window).height() - $header.outerHeight() - $search.outerHeight() - $nav.outerHeight();
var h = document.body.scrollHeight - $header.outerHeight() - $search.outerHeight() - $nav.outerHeight();
$categoryContainer.css('min-height', h);
$contents.height(h);
}());
}
resetHeight();
$('#search-input').focus(function() {
$(this).blur();
... ... @@ -39,6 +40,7 @@ $nav.on('touchend touchcancel', function(e) {
var $this = $(e.target).closest('li'),
selector = '.' + $this.data('channel');
resetHeight();
if ($this.hasClass('focus')) {
return;
}
... ...
... ... @@ -125,7 +125,7 @@ $(function() {
if (!(window.queryString.app_version || window.queryString.appVersion)) {
$('.tab-nav').css({
position: 'absolute'
position: 'relative'
});
$footer.css({
... ...
... ... @@ -33,6 +33,7 @@ $('.detail-tab span').on('click', function() {
if ($(this).index() === 1) {
setDetailText();
lazyLoad($('img.lazy'));
}
});
... ...
var $ = require('yoho-jquery'),
// Swiper = require('yoho.iswiper'),
lazyLoad = require('yoho-jquery-lazyload'),
loading = require('../plugin/loading');
var page = 1,
winH,
listTop,
navSwiper,
notab = 0,
sort = '',
id = '',
hotrankNav,
noResult = '<p class="no-result">未找到相关搜索结果</p>';
require('../common/suspend-cart');
require('../common');
var share = require('../common/share');
share({
title: '有货【会员日】开启啦!9月28日潮集狂欢趴等你来HI!限时6大福利,快参与起来喽~',
link: location.href,
desc: 'YOHO!BUY',
imgUrl: 'http://static.yohobuy.com/m/v1/img/touch/apple-touch-icon-144x144-precomposed-new.png'
});
function hotrank(page, sort, tabId, notab) {
loading.showLoadingMask();
$.ajax({
type: 'GET',
url: '/product/newsale/selectHotrank?' + sort,
dataType: 'html',
data: {
page: page,
tab_id: tabId,
notab: notab
},
success: function(data) {
if (data === ' ') {
if ($('.rank-main').length < 1 && $('.goods-nav').length < 1) {
$('#hotRank').html(noResult);
} else {
if (page === 1) {
hotrankNav = $('.goods-nav').prop('outerHTML');
$('#hotRank').html(hotrankNav + noResult);
}
}
} else {
$('.no-result').remove();
if (page === 1) {
$('.rank-main').remove();
}
$('#hotRank').append(data);
}
lazyLoad($('img.lazy'));
$('.rank-main ul li:gt(9)').find('.item-content i').removeClass('top');
winH = $(window).height();
if ($('.rank-main').length !== 0) {
$('#yoho-footer').css('position', 'static');
listTop = $('.rank-main').find('ul').offset().top;
} else {
$('#yoho-footer').css({
position: 'fixed',
width: '100%'
});
}
navSwiper = new Swiper('.s-goods-nav', {
grabCursor: true,
slidesPerView: 'auto',
slideElement: 'li'
});
loading.hideLoadingMask();
}
});
}
function scrollHandler() {
if (page === 2) {
return;
}
if ($(window).scrollTop() + winH < listTop + $('#hotRank').height() - 100) {
return;
}
page = 2;
notab = 1;
hotrank(page, sort, id, notab);
}
$(window).scroll(function() {
window.requestAnimationFrame(scrollHandler);
});
hotrank(page, sort, id, notab);
$('#hotRank').on('touchend touchcancel', function(e) {
var ev = ev || window.event;
var target = ev.target || ev.srcElement;
if (target.nodeName.toLowerCase() === 'span') {
$('.s-goods-nav .nav-item').removeClass('active');
target.parentNode.className = 'active ' + target.parentNode.className;
id = target.getAttribute('data-id') ? target.getAttribute('data-id') : '';
sort = target.getAttribute('data-sort') ? target.getAttribute('data-sort') : '';
page = 1;
notab = 1;
hotrank(page, sort, id, notab);
}
});
$('#hotRank').bind('contextmenu', function(e) {
return false;
});
$('#hotRank').on('touchstart', function(e) {
var ev = ev || window.event;
var target = ev.target || ev.srcElement;
if (target.nodeName.toLowerCase() === 'span') {
target.parentNode.className = 'bgActive ' + target.parentNode.className;
}
}).on('touchend touchcancel', function() {
$('.s-goods-nav .nav-item').removeClass('bgActive');
});
... ...
... ... @@ -62,19 +62,18 @@
background: #f6f6f6;
.title-image {
a {
display: block;
}
.image {
width: 100%;
height: 364px;
height: 310px;
}
img {
width: 100%;
height: 100%;
height: inherit;
}
}
... ... @@ -104,20 +103,17 @@
}
.focus {
.swipe {
height: 100%;
}
.swipe-1 {
.swipe-indicators {
display: none;
}
}
.swipe-item {
a {
display: block;
}
... ... @@ -126,7 +122,6 @@
width: 100%;
height: 100%;
}
}
.swipe-indicators {
... ... @@ -168,8 +163,8 @@
a {
display: inline-block;
margin: 0 15px;
width: 250px;
height: 250px;
width: 213px;
height: 213px;
}
img {
... ...
... ... @@ -4,7 +4,7 @@
}
li {
width: 580px;
width: 100%;
height: 200px;
margin-bottom: 30px;
position: relative;
... ...
... ... @@ -88,7 +88,28 @@
}
#goods-list {
margin: 15px 0 0 15px;
padding: 0 15px;
margin: 15px 0 0;
width: 100%;
box-sizing: border-box;
}
.good-info {
float: left;
padding: 0 15px;
margin: 10px 0 40px;
box-sizing: border-box;
width: 50%;
height: auto;
}
.good-detail-img {
height: auto;
background: #c3c3c3;
img {
height: 100%;
}
}
}
... ...
... ... @@ -82,7 +82,7 @@
.title-box {
margin-left: 22px;
width: 240px;
width: 210px;
.product-name {
overflow: hidden;
... ... @@ -126,7 +126,7 @@
.info-box {
margin-left: 22px;
float: left;
width: 452px;
width: 402px;
}
h3 {
... ... @@ -154,7 +154,7 @@
.installment-box {
text-align: center;
float: left;
width: 213.333px;
width: 33%;
font-size: 22px;
}
... ...
... ... @@ -294,7 +294,7 @@
border-top: 1px solid #e0e0e0;
label {
margin-left: 75px;
margin-left: 60px;
width: 320px;
height: 120px;
float: left;
... ...
... ... @@ -4,3 +4,4 @@
@import "search/index";
@import "shop/index";
@import "new/new-arrival";
@import "newsale/hot-rank";
... ...
.rank-main {
padding: 14px 0 0 30px;
background: #fff;
li {
height: 230px;
overflow: hidden;
.item-img {
float: left;
width: 150px;
height: 200px;
padding: 14px 0;
line-height: 200px;
text-align: center;
img {
max-width: 100%;
max-height: 100%;
vertical-align: middle;
}
}
.item-content {
float: left;
width: 407px;
height: 213px;
margin: 0 0 0 13px;
padding: 14px 0 0 30px;
border-top: 1px solid #e0e0e0;
overflow: hidden;
.rank-icon {
display: block;
height: 45px;
width: 50px;
line-height: 50px;
text-align: center;
font-size: 22px;
color: #fff;
background: resolve("me/employ/rank.png") no-repeat;
background-position: center top;
background-size: auto 100%;
&.top {
background: resolve("me/employ/rank-t.png") no-repeat;
background-position: center top;
background-size: 100%;
line-height: 54px;
}
}
h2 {
margin: 15px 0 0 !important;
padding: 0 !important;
width: 9.5rem;
max-height: 72px;
overflow: hidden;
line-height: 36px;
color: #444;
font-size: 28px;
&.hasActive {
margin: 5px 0 0 !important;
}
}
p {
margin: 0 !important;
padding: 0 !important;
width: 9.5rem;
line-height: 36px;
font-size: 24px;
color: #d0021b;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
b {
text-decoration: line-through;
color: #b0b0b0;
margin-left: 10px;
}
}
}
}
li:first-child {
.item-content {
border: none;
}
}
}
.goods-nav {
border-bottom: 2px solid #e6e6e6;
height: 67px;
overflow: hidden;
li {
float: left;
width: auto;
height: 67px;
line-height: 67px;
width: 145px;
text-align: center;
font-size: 28px;
a {
display: inline-block;
padding: 0 5px;
font-size: 28px;
color: #999;
height: 65px;
}
}
li:first-child {
margin-left: 30px;
}
li.focus {
a {
border-bottom: 4px solid #000;
color: #000;
}
}
}
.s-goods-nav {
box-sizing:border-box;
overflow: hidden;
li {
margin: 0 10px;
padding:0 15px;
width: auto;
height: 100%;
color: #999;
&.active{
color: #000;
}
&.bgActive{
color: #000;
background-color:#e0e0e0;
}
a {
padding: 0;
}
}
li:first-child {
margin: 0 0 0 39px;
}
.swiper-wrapper {
background: #fff;
}
}
... ...