/** * 热销排行页面 * @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 };