Authored by liangxs

Merge branch 'feature/outlet' of http://git.yoho.cn/fe/yohobuywap-node into feature/outlet

... ... @@ -14,10 +14,11 @@ const renderData = {
};
exports.index = (req, res) => {
let channel = req.query.channel || req.cookies._Channel || 'boys';
let channel = req.query.yh_channel || req.cookies._Channel || 'boys';
let headerData = headerModel.setNavHeader('OUTLET', channel, true, '', null);
let categoryId = req.query.category_id;
outletModel.getContent(channel).then(result => {
outletModel.getContent(categoryId, channel).then(result => {
res.render('outlet', Object.assign({
pageHeader: headerData,
pageFooter: true
... ...
/**
* 频道页面 model
* @author: Bi Kai<kai.bi@yoho.cn>
G* @author: Bi Kai<kai.bi@yoho.cn>
* @date: 2016/05/09
*/
'use strict';
... ... @@ -22,10 +22,11 @@ const serviceApi = new ServiceAPI();
const api = new API();
const getOutletResource = () => {
const getOutletResource = (channel) => {
const params = {
content_code: 'c19ffa03f053f4cac3690b22c8da26b7',
limit: 25,
yh_channel: channel || '',
debug: 'XYZ'
};
... ... @@ -54,18 +55,18 @@ const convertNavData = (list) => {
return {data: formatData};
};
const getNavData = () => {
const getNavData = (categoryId) => {
const params = {
// client_type: 'iphone',
// os_version: 8.4,
// screen_size: '320x568',
v: 7,
// parent_id: 1107,
parent_id: categoryId,
debug: 'XYZ'
};
return api.get('operations/api/v6/category/getCategory', sign.apiSign(params)).then(result => {
return serviceApi.get('operations/api/v6/category/getCategory', sign.apiSign(params)).then(result => {
if (result && result.code === 200) {
return convertNavData(result.data);
} else {
... ... @@ -147,7 +148,7 @@ const getHomeActivity = (data) => {
});
};
exports.getContent = (channel) => {
exports.getContent = (categoryId, channel) => {
let floorsData = {},
params = {
type: 0,
... ... @@ -157,8 +158,9 @@ exports.getContent = (channel) => {
if (channel === 'boys') {
params.yh_channel = 1;
}
const promises = [getNavData(categoryId), getOutletResource(channel), getHomeActivity(params), getGoodsList()];
return Promise.all([getNavData(), getOutletResource(), getHomeActivity(params), getGoodsList()]).then(data => {
return Promise.all(promises).then(data => {
floorsData.nav = data[0] || [];
floorsData.content = data[1] || [];
floorsData.activity = {data: data[2]};
... ...
... ... @@ -135,6 +135,7 @@ const processBreakingSort = (list) => {
* @return {[array]}
*/
const searchSales = (params) => {
let method = 'app.search.sales';
// 排除基本筛选项默认值为0的对象
for (let str in params) {
... ... @@ -143,6 +144,10 @@ const searchSales = (params) => {
}
}
if (params.outlets) {
method = 'app.search.li';
}
params = Object.assign({
limit: '50'
}, params);
... ... @@ -152,7 +157,7 @@ const searchSales = (params) => {
}
return api.get('', sign.apiSign(Object.assign({
method: 'app.search.sales'
method: method
}, params)), true);
};
... ...
<div class="outlet-page goods-page yoho-page">
{{> product/sale/banner}}
{{> product/outlet/banner}}
{{> common/filter-nav}}
{{> product/sale/common}}
</div>
... ...
<div class="banner">
{{# outletActivity}}
<img src="{{image webUrl 640 250}}"/>
<p class="outlet-activity-time" data-time-ms="{{endLeftTime}}"><i class="iconfont time-ico">&#xe603;</i><span></span></p>
<p class="outlet-discount">{{promotionName}}</p>
{{/ outletActivity}}
</div>
... ...
<nav id="list-nav" class="outlet-nav outlet-category-nav">
<nav class="outlet-nav outlet-category-nav">
<ul>
<li><a href="?gender=1,3">全部</a></li>
{{!
<li class='cartegory'><a href="?gender=1,3">全部</a></li>
}}
{{#data}}
<li><a href="{{url}}">{{categoryName}}</a></li>
<li class='cartegory'><a href="{{url}}">{{categoryName}}</a></li>
{{/data}}
</ul>
</nav>
... ...
{{# nav}}
<nav class="outlet-nav">
<nav class="outlet-nav" id="index_nav">
<ul>
{{#each data}}
<li><a href="{{url}}">{{name}}</a></li>
{{/each}}
<li><a href="outlet/willBeEnd">即将结束</a></li>
<li><a href="outlet/willBeCome">上线预告</a></li>
<li><a href="outlet/willStart">即将结束</a></li>
<li><a href="outlet/willEnd">即将开始</a></li>
</ul>
</nav>
{{/nav}}
... ...
... ... @@ -12,10 +12,4 @@
<p class="activity-time" data-time-ms="{{leftTime}}"><i class="iconfont time-ico">&#xe603;</i><span>{{time}}</span></p>
{{/ activity}}
{{# outletActivity}}
<img src="{{image webUrl 640 250}}"/>
<p class="outlet-activity-time" data-time-ms="{{endLeftTime}}"><i class="iconfont time-ico">&#xe603;</i><span></span></p>
<p class="outlet-discount">{{promotionName}}</p>
{{/ outletActivity}}
</div>
... ...
... ... @@ -8,6 +8,7 @@
<div class="discount-goods container hide clearfix"></div>
<div class="all-goods container hide clearfix"></div>
<div class="sale-goods container hide clearfix"></div>
<div class="categroy-goods container hide clearfix"></div>
{{> common/filter}}
</div>
... ...
... ... @@ -81,4 +81,4 @@ if (isProduction) {
timeout: 3000
}
});
}
\ No newline at end of file
}
... ...
... ... @@ -6,9 +6,10 @@
var $ = require('yoho-jquery'),
lazyLoad = require('yoho-jquery-lazyload');
var countDown = require('../plugin/countdown');
var countDown = require('../plugin/countdown'),
search = require('./sale/search');
require('./sale/search');
search.start();
lazyLoad($('img.lazy'));
... ...
... ... @@ -4,7 +4,9 @@ var $ = require('yoho-jquery'),
var $time = $('.outlet-activity-time'),
endTime = $time.data('time-ms');
require('./sale/search');
var search = require('./sale/search');
search.start();
countDown({
timeDom: $time,
... ...
var $ = require('yoho-jquery'),
var $ = require('yoho-jquery'),
Swiper = require('yoho-swiper'),
lazyLoad = require('yoho-jquery-lazyload'),
Countdown = require('./outlet/countdown');
var el = $('.cd-lite');
// var nav = require('./outlet/nav');
var search = require('./sale/search');
var iscroll = require('./outlet/nav');
require('./sale/search');
... ... @@ -32,7 +34,7 @@ if ($('.swiper-container .swiper-slide').length > 1) {
}
$('.outlet-category-nav').on('click', 'a', function(e) {
$('.outlet-category-nav a').on('click', function(e) {
var href = $(this).attr('href'), // eslint-disable-line
querys = href.split('?')[1].split('&');
... ... @@ -48,9 +50,14 @@ $('.outlet-category-nav').on('click', 'a', function(e) {
query[key] = val;
});
// search(null, query);
search.start({
type: 'category'
}, query);
});
// 触发第一个search
$('.outlet-category-nav a').eq(0).trigger('click');
if (('.outlet-page').length > 0) {
$('.more-activity').on('click', function() {
$('.more-activity').addClass('hidden');
... ... @@ -69,3 +76,12 @@ if (('.outlet-page').length > 0) {
}
// 导航滚动
iscroll({
el: '#index_nav'
}).goto($('#index_nav').find('.active').index());
iscroll({
el: '#list-nav'
}).goto(0);
... ...
var $ = require('yoho-jquery'),
IScroll = require('yoho-iscroll');
var defaultOpt = {
navClass: '.outlet-nav'
};
// nav 滚动
function initNavScroll(opt) {
var $navBox,
iScroll,
_default = {
el: '.outlet-nav'
},
options;
// $lis,
iScroll;
options = $.extend({}, _default, opt);
$navBox = $(options.el);
$.extend(opt || {}, defaultOpt);
function scroll(index) {
var $ele;
$navBox = $(opt.navClass);
$ele = $navBox.find('li').eq(index);
if ($ele.length > 0) {
setTimeout(function() {
iScroll.scrollToElement($ele[0], 400);
}, 1);
}
}
// $lis = $navBox.find('li');
iScroll = new IScroll($navBox[0], {
scrollX: true,
scrollY: false
});
function scroll(ele) {
var offset;
return {
goto: scroll
};
}
ele = ele || $navBox.find('li').eq(0)[0];
offset = -($navBox.find('ul').width() - 20) / 2;
// 获取url中的参数
function getUrlParam(name) {
var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)'); // 构造一个含有目标参数的正则表达式对象
var r = window.location.search.substr(1).match(reg); // 匹配目标参数
setTimeout(function() {
iScroll.scrollToElement(ele, 400, offset);
}, 1);
// 返回参数值
if (r !== null) {
return decodeURIComponent(r[2]);
} else {
return null;
}
}
$.each($navBox, function(index) {
iScroll = new IScroll($navBox[index], {
scrollX: true,
scrollY: false
});
});
// 选中顶部导航
function activeNav() {
var $nav = $('#index_nav');
var index = getUrlParam('yh_channel');
// $navBox.on('click', 'li', function() {
// var $this = $(this); // eslint-disable-line
// var i = $this.index();
if (index === null) {
index = 0;
}
$nav.find('li').eq(index).addClass('active').siblings().removeClass('active');
}
// $lis.eq(i).addClass('active').siblings().removeClass('active');
// scroll($this[0]);
// });
scroll($navBox.find('.active')[0]);
}
activeNav();
module.exports = initNavScroll;
... ...
... ... @@ -7,8 +7,11 @@
var $ = require('yoho-jquery'),
Swiper = require('yoho-swiper');
var search = require('./sale/search');
require('../common/common');
require('./sale/search');
search.start();
if ($('.swiper-container .swiper-slide').length > 1) {
new Swiper('.swiper-container', {
... ...
... ... @@ -15,6 +15,7 @@ var $goodsContainer = $('#goods-container'),
$dgc = $goodsContainer.find('.discount-goods'),
$pgc = $goodsContainer.find('.price-goods'),
$agc = $goodsContainer.find('.all-goods'),
$cgc = $goodsContainer.find('.category-goods'),
$sgc = $goodsContainer.find('.sale-goods');
var winH = $(window).height(),
... ... @@ -56,6 +57,13 @@ var $listNav = $('#list-nav'),
reload: true,
page: 0,
end: false
},
category: {
order: 0,
reload: true,
fuck: true,
page: 0,
end: false
}
},
$pre = $listNav.find('.active'), // 纪录进入筛选前的active项,初始为选中项
... ... @@ -90,7 +98,7 @@ $.extend(defaultOpt, {
// 判断导航类型
function judgeType(dom) {
var navType;
var navType = 'category';
if (dom.hasClass('new')) {
navType = 'newest';
... ... @@ -102,6 +110,8 @@ function judgeType(dom) {
navType = 'sale';
} else if (dom.hasClass('all')) {
navType = 'all';
} else if (dom.hasClass('category')) {
navType = 'category';
}
return navType;
... ... @@ -184,9 +194,7 @@ function search(opt, params) {
$.extend(defaultOpt, ext); // 扩展筛选项
}
if (params) {
$.extend(defaultOpt, params);
}
$.extend(defaultOpt, params || {}); // 扩展筛选项
// 导航类别
navType = judgeType($pre);
... ... @@ -240,6 +248,9 @@ function search(opt, params) {
case 'all':
$container = $agc;
break;
case 'categroy':
$container = $cgc;
break;
default:
$container = $agc;
break;
... ... @@ -257,7 +268,11 @@ function search(opt, params) {
$container.html(noResult);
}
} else {
if (nav.reload) {
if (navType === 'category') {
nav.page = 1;
}
if (nav.reload || navType === 'category') {
$container.html(data);
lazyLoad($container.find('.lazy'));
} else {
... ... @@ -359,7 +374,7 @@ $listNav.on('touchend touchcancel', function(e) {
// 导航类别
navType = judgeType($this);
nav = navInfo[navType || 'all'];
nav = navInfo[navType];
if ($this.hasClass('active')) {
... ... @@ -419,7 +434,7 @@ $listNav.on('touchend touchcancel', function(e) {
$this.addClass('active');
}
if (nav && nav.reload) {
if (nav.reload) {
search();
}
}
... ... @@ -442,8 +457,6 @@ $(window).scroll(function() {
window.requestAnimationFrame(scrollHandler);
});
// 初始请求最新第一页数据
search();
$listNav.on('touchstart', 'li', function() {
$(this).addClass('bytouch');
... ... @@ -451,5 +464,6 @@ $listNav.on('touchstart', 'li', function() {
$listNav.find('li').removeClass('bytouch');
});
module.exports = search;
module.exports = {
start: search
};
... ...
require('./sale/search');
var search = require('./sale/search');
search.start();
... ...