Authored by zhangxiaoru

全部分类

... ... @@ -59,7 +59,7 @@ const brandList = (req, res, next) => {
res.render('brand/brand-list', {
layout: false,
brandList: result.brandList
})
});
}).catch(next);
};
... ... @@ -67,13 +67,13 @@ const categoryData = (req, res, next) => {
let code;
let gender = req.query.gender || req.cookies._Channel && channels[req.cookies._Channel] || 1;
if (parseInt(gender) === 1) {
if (parseInt(gender, 10) === 1) {
code = '7f885e9cab53231cff34ea236f3f1120';
} else {
code = 'a6f9dc00219eb7d08520a18864929a30';
}
brandModel.categoryData(code, gender).then(result => {
brandModel.categoryData(code).then(result => {
res.render('brand/category', {
layout: false,
categoryData: result.categoryData
... ... @@ -96,8 +96,8 @@ const cateAll = (req, res, next) => {
}
// showFooterTab: footerModel.getUrlData('category')
});
}).catch(next);
}
}).catch(next);
};
module.exports = {
index,
... ...
... ... @@ -277,29 +277,29 @@ const brandListData = (code, gender) => {
list.brandList = brandList;
return list;
})
}
});
};
const categoryData = (code, gender) => {
const categoryData = (code) => {
return _getResourcesData(code).then(result => {
let categoryData = {};
let category = {};
let list = {};
if (result) {
_.forEach(result, function(data) {
if (data.template_name === 'recommend_content_five') {
categoryData.list = data.data.list;
category.list = data.data.list;
} else if (data.template_name === 'focus') {
categoryData.focusData = data;
category.focusData = data;
}
});
}
list.categoryData = categoryData;
list.categoryData = category;
return list;
});
}
};
const getCateData = (channel) => {
return api.get('', {
... ... @@ -321,12 +321,12 @@ const getCateData = (channel) => {
return result.data;
}).then((list) => {
return _processCateData(list, channel);
});
}
});
};
module.exports = {
indexData,
brandListData,
categoryData,
getCateData
};
\ No newline at end of file
};
... ...
/**
* 分类
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2015/10/14
*/
var $ = require('yoho-jquery');
var FastClick = require('yoho-fastclick');
var $nav = $('.category-nav'),
$search = $('#search-input'),
$categoryContainer = $('.category-container'),
$contents = $categoryContainer.children('.content'),
$subLevelItem = $categoryContainer.find('.sub-level li'),
$primaryItem = $categoryContainer.find('.primary-level li');
require('../common');
$(function() {
FastClick.attach(document.body);
});
function resetHeight() {
var h = document.body.scrollHeight - $search.outerHeight() - $nav.outerHeight();
$contents.height(h);
}
resetHeight();
$search.focus(function() {
$(this).blur();
});
$nav.on('contextmenu', function() {
return false;
});
$('.category-container').on('contextmenu', function() {
return false;
});
$nav.on('touchend touchcancel', function(e) {
var $this = $(e.target).closest('li'),
selector = '.' + $this.data('channel');
if ($this.hasClass('focus')) {
return;
}
$nav.find('li.focus').removeClass('focus');
$this.addClass('focus');
$contents.addClass('hide');
$contents.filter(selector).removeClass('hide');
});
$categoryContainer.on('click', function(e) {
var $this = $(e.target),
$subLevel,
$cur, index;
$cur = $this.closest('.p-level-item');
// 第一次单击右则空白处,出现冒泡
if ($(e.target).closest('.sub-level').length <= 0) {
e.preventDefault();
}
if ($this[0] && $this[0].tagName === 'LI' && $this.find('a').attr('href')) {
location.href = $this.find('a').attr('href');
}
if ($this[0] && $this[0].tagName === 'A' && $this.attr('href')) {
location.href = $this.attr('href');
}
if ($cur.length > 0) {
index = $cur.index();
$subLevel = $this.closest('.content').find('.sub-level');
if ($this.hasClass('focus')) {
return;
}
$this.closest('.primary-level').children('.focus').removeClass('focus');
$this.addClass('focus');
$subLevel.not('.hide').addClass('hide');
$subLevel.eq(index).removeClass('hide');
}
});
$categoryContainer.find('.primary-level').on('touchstart touchend touchcancel', 'li', function() {
$primaryItem.removeClass('highlight');
$(this).addClass('highlight');
}).on('touchend touchcancel', 'li', function() {
$(this).removeClass('highlight');
});
$categoryContainer.find('.sub-level').on('touchstart', 'li', function() {
$subLevelItem.removeClass('highlight');
$(this).addClass('highlight');
}).on('touchend touchcancel', 'li', function() {
$(this).removeClass('highlight');
});
$nav.on('touchstart', 'li', function() {
$nav.find('li').removeClass('bytouch');
$(this).addClass('bytouch');
}).on('touchend touchcancel', 'li', function() {
$nav.find('li').removeClass('bytouch');
});
/**
* 分类
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2015/10/14
*/
var $ = require('yoho-jquery');
var FastClick = require('yoho-fastclick');
var $nav = $('.category-nav'),
$search = $('#search-input'),
$categoryContainer = $('.category-container'),
$contents = $categoryContainer.children('.content'),
$subLevelItem = $categoryContainer.find('.sub-level li'),
$primaryItem = $categoryContainer.find('.primary-level li');
require('../common');
$(function() {
FastClick.attach(document.body);
});
function resetHeight() {
var h = document.body.scrollHeight - $search.outerHeight() - $nav.outerHeight();
$contents.height(h);
}
resetHeight();
$search.focus(function() {
$(this).blur();
});
$nav.on('contextmenu', function() {
return false;
});
$('.category-container').on('contextmenu', function() {
return false;
});
$nav.on('touchend touchcancel', function(e) {
var $this = $(e.target).closest('li'),
selector = '.' + $this.data('channel');
if ($this.hasClass('focus')) {
return;
}
$nav.find('li.focus').removeClass('focus');
$this.addClass('focus');
$contents.addClass('hide');
$contents.filter(selector).removeClass('hide');
});
$categoryContainer.on('click', function(e) {
var $this = $(e.target),
$subLevel,
$cur, index;
$cur = $this.closest('.p-level-item');
// 第一次单击右则空白处,出现冒泡
if ($(e.target).closest('.sub-level').length <= 0) {
e.preventDefault();
}
if ($this[0] && $this[0].tagName === 'LI' && $this.find('a').attr('href')) {
location.href = $this.find('a').attr('href');
}
if ($this[0] && $this[0].tagName === 'A' && $this.attr('href')) {
location.href = $this.attr('href');
}
if ($cur.length > 0) {
index = $cur.index();
$subLevel = $this.closest('.content').find('.sub-level');
if ($this.hasClass('focus')) {
return;
}
$this.closest('.primary-level').children('.focus').removeClass('focus');
$this.addClass('focus');
$subLevel.not('.hide').addClass('hide');
$subLevel.eq(index).removeClass('hide');
}
});
$categoryContainer.find('.primary-level').on('touchstart touchend touchcancel', 'li', function() {
$primaryItem.removeClass('highlight');
$(this).addClass('highlight');
}).on('touchend touchcancel', 'li', function() {
$(this).removeClass('highlight');
});
$categoryContainer.find('.sub-level').on('touchstart', 'li', function() {
$subLevelItem.removeClass('highlight');
$(this).addClass('highlight');
}).on('touchend touchcancel', 'li', function() {
$(this).removeClass('highlight');
});
$nav.on('touchstart', 'li', function() {
$nav.find('li').removeClass('bytouch');
$(this).addClass('bytouch');
}).on('touchend touchcancel', 'li', function() {
$nav.find('li').removeClass('bytouch');
});
... ...