Authored by zhangxiaoru

brand

... ... @@ -14,7 +14,6 @@ const brandModel = require(`${mRoot}/brand-list`);
let channels = {
boys: 1,
girl: 2,
kids: 3,
lifestyle: 4
};
... ... @@ -34,31 +33,32 @@ const index = (req, res, next) => {
// }),
// title: '潮流优选',
width750: true,
categoryTab: true,
categoryTab: categoryTab === 'category' ? true : false,
channel: result.channel,
brandList: result.brandList
})
}).catch(next);
};
// const brandList = (req, res, next) => {
// let code = '7317a4701a1d3ddc8d93a5df77a63b75';
const brandList = (req, res, next) => {
let code;
let gender = req.query.gender || req.cookies._Channel && channels[req.cookies._Channel] || 1;
if (parseInt(gender) === 1) {
code = '7317a4701a1d3ddc8d93a5df77a63b75';
} else {
code = '84313c4b293a1c0aea985aa16a42a6b5';
}
// brandModel.getResourcesData(code).then(result => {
// res.render('brand/brand', {
// module: 'guang',
// page: 'brand-list',
// pageHeader: headerModel.setNav({
// navTitle: '潮流优选'
// }),
// title: '潮流优选',
// width750: true,
// categoryTab: true,
// channel: result
// })
// }).catch(next);
// };
brandModel.brandListData(code, gender).then(result => {
res.render('brand/brand-list', {
layout: false,
brandList: result.brandList
})
}).catch(next);
};
module.exports = {
index
index,
brandList
};
... ...
... ... @@ -195,6 +195,32 @@ const indexData = (isbrand, gender, code) => {
}
};
const brandListData = (code, gender) => {
return Promise.all([_getResourcesData(code), _getBrandListOriginData(gender)]).then(result => {
let brandList = {};
let list = {};
if (result[0]) {
_.forEach(result[0], function(data) {
if (data.focus_type === '1') {
brandList.bannerTop = data;
} else if (data.focus_type === '2') {
brandList.focusData = data.data;
}
});
}
if (result[1]) {
brandList.listData = result[1].ListData;
brandList.indexList = result[1].indexList;
}
list.brandList = brandList;
return list;
})
}
module.exports = {
indexData
indexData,
brandListData
};
\ No newline at end of file
... ...
... ... @@ -64,6 +64,6 @@ router.get('/info/listData', index.listDynamicData);
router.get('/info/detailData', index.detailDynamicData);
router.get('/brand', brand.index);
// router.get('/brandList', brand.brand-list);
router.get('/brandList', brand.brandList);
module.exports = router;
... ...
{{> brand/brand-list}}
\ No newline at end of file
... ...
... ... @@ -7,27 +7,45 @@ var bannerSwiper,
var $intercept = $('.no-intercept'),
$list = $('.brand-list-box');
function channels(key) {
return {
'men': 1,
'women': 2,
'lifestyle': 4
}[key];
};
// function loadData() {
// $.ajax({
// method: 'get',
// url: '/guang/brandList',
// success: function(data) {
// }
// });
// }
function loadData(channel) {
$.ajax({
method: 'get',
url: '/guang/brandList',
data: {
gender: channel
},
success: function(data) {
$('.brand-content').html(data);
}
});
}
$('.channel-tab').find('li').click(function() {
var gender = $(this).find('span').text().replace(/[^A-Za-z]+/g, '').toLowerCase();
$(this).addClass('focus').siblings().removeClass('focus');
// console.log(channels(gender))
loadData(channels(gender));
})
// 点击字母,页面滚动到相关区域
$intercept.click(function() {
var name = $(this).attr('href').split('#')[1],
targetTop = $list.find('[name=' + name + ']').offset().top - categoryHeight;
// if (!$gory.hasClass('category-fix')) {
// targetTop -= categoryHeight;
// }
$('html,body').animate({
scrollTop: targetTop
}, 200);
... ...
... ... @@ -190,7 +190,7 @@
right: 0;
background: #fff;
opacity: 0.8;
top: 0;
top: 170px;
overflow-y: auto;
z-index: 10;
... ...