Authored by 陈峰

product/sale product/new brands

... ... @@ -9,6 +9,7 @@
const headerModel = require('../../../doraemon/models/header'); // 头部model
const footerModel = require('../../../doraemon/models/footer_tab'); // 底部tab
const indexModel = require('../models/brand');
const typeLib = require('../../../config/type-lib');
/**
* 品牌一览
... ... @@ -17,7 +18,6 @@ const indexModel = require('../models/brand');
* @param int channel 1表示男生频道, 2表示女生频道, 3表示潮童频道, 4表示创意生活频道
*/
let index = (req, res, next) => {
let responseData = {
module: 'channel',
page: 'brand',
... ... @@ -26,14 +26,36 @@ let index = (req, res, next) => {
// title: '品牌一览 | Yoho!Buy有货 | 潮流购物逛不停',
showFooterTab: footerModel.getUrlData('category')
};
let channel,
gender;
if (!req.query.channel) {
channel = '1';
} else if (!typeLib.channels[req.query.channel]) {
channel = req.query.channel;
} else {
channel = typeLib.channels[req.query.channel] + '';
}
if (!req.query.gender) {
gender = '1,3';
} else if (!typeLib.gender[gender]) {
gender = req.query.gender;
} else {
gender = typeLib.gender[gender];
}
let param = {
channel: req.query.channel || '1',
gender: req.query.gender || '1,3'
channel,
gender
};
indexModel.getBrandByChannel(param.channel).then(result => {
res.render('brand/index', Object.assign(responseData, result));
console.log(result.channel.channels)
res.render('brand/index', Object.assign(responseData, result, {
params: {
yhChannel: channel
}
}));
}).catch(next);
};
... ...
... ... @@ -84,13 +84,17 @@ const getBrandByChannel = (channel) => {
let resu = {
channel: {
channels: [{
name: 'Boy'
name: 'Boy',
channelName: 'boys'
}, {
name: 'Girl'
name: 'Girl',
channelName: 'girls'
}, {
name: 'Kid'
name: 'Kid',
channelName: 'kids'
}, {
name: 'Lifestyle'
name: 'Lifestyle',
channelName: 'lifestyle'
}],
topData: {
bannerTop: {},
... ...
... ... @@ -12,6 +12,7 @@ const channel = require(cRoot);
const cate = require(cRoot + '/cate');
const brandController = require(`${cRoot}/brand`);
const custom = require(`${cRoot}/custom`);
const rewrite = require('../../doraemon/middleware/rewrite');
const router = express.Router(); // eslint-disable-line
... ... @@ -26,6 +27,7 @@ router.get('/(:channel)/bottomBanner', channel.bottomBanner);
router.get('/cate', cate.index);
router.get('/brands', brandController.index); // 品牌首页
router.get(/^\/([a-zA-Z]+)-brands/, rewrite.channel, brandController.index); // 品牌首页 SEO优化
router.get('/brands/search', brandController.search); // 品牌搜索页
router.get('/brands/getBrandList', brandController.brandList); // 获取品牌列表
router.post('/brands/searchAsync', brandController.searchAsync); // 品牌搜索异步数据
... ...
... ... @@ -4,7 +4,7 @@
<div class="genderNav">
<ul>
{{# channels}}
<li {{#if active}}class="active"{{/if}} data-id="{{@index}}">
<li {{#if active}}class="active"{{/if}} data-id="{{@index}}" data-name="{{channelName}}">
<span>{{name}}</span>
<span class="split-border"></span>
</li>
... ... @@ -57,3 +57,6 @@
{{/channel}}
</div>
{{> footer-tab}}
{{# params}}
{{> common/query-param}}
{{/params}}
\ No newline at end of file
... ...
... ... @@ -11,6 +11,7 @@ const cRoot = './controllers';
const star = require(cRoot + '/star');
const homeController = require(`${cRoot}/index`);
const plusstar = require(cRoot + '/plusstar');
const rewrite = require('../../doraemon/middleware/rewrite');
const index = require(cRoot + '/index');
const opt = require(cRoot + '/opt');
... ... @@ -32,6 +33,7 @@ router.post('/star/setFavorite', star.setFavorite); // 收藏文章
router.get('/', homeController.index); // 逛首页
router.get('/plusstar', plusstar.index); // 潮流优选
router.get(/^\/([a-zA-Z]+)-plusstar/, rewrite.gender, plusstar.index); // 潮流优选 SEO优化
router.post('/plusstar/userSkn', plusstar.userSkn); // 用户推荐skn
router.get('/plusstar/resources-template', plusstar.resourcesTemplate); // 潮流优选首页-资源位
router.post('/plusstar/resources-goodsList', plusstar.resourcesGoodsList); // 潮流优选首页-资源位-商品列表
... ...
... ... @@ -10,6 +10,8 @@ const router = require('express').Router(); // eslint-disable-line
const auth = require('../../doraemon/middleware/auth');
const rewrite = require('../../doraemon/middleware/rewrite');
const cRoot = './controllers';
// 商品详情controller
... ... @@ -86,6 +88,8 @@ router.post('/detail/consultupvote', detail.consultUpvoteOrUseful); // 商品咨
router.post('/detail/consultuseful', detail.consultUpvoteOrUseful); // 商品咨询提交接口
router.get('/sale', sale.index);
router.get(/^\/([a-zA-Z]+)-sale/, rewrite.channel, sale.index); // 折扣专区 SEO优化
router.get('/sale/discount', sale.discount);
router.get('/sale/discount/detail', sale.discountDetail);
router.get('/sale/breakingYards', sale.breakingYards);
... ... @@ -157,6 +161,10 @@ router.get('/opt/favoriteBrand', list.favoriteBrand);
// 新品到着
router.get('/new', news.newGoods);
// 新品到着 SEO优化
router.get(/^\/([a-zA-Z]+)-new/, rewrite.channel, news.newGoods);
router.get('/list/new', news.newGoods); // 兼容 PC 的链接
router.get('/new/selectNewSale', news.selectNewSale);
router.get('/new/filter', news.filter);
... ...
/**
* 类型映射配置
* @author: chenfeng<feng.chen@yoho.cn>
* @date: 2017/02/20
*/
'use strict';
const channels = {
boys: 1,
girl: 2,
girls: 2,
kids: 3,
lifestyle: 4
};
let gender = {
boys: '1,3',
girl: '2,3',
girls: '2,3',
kids: '3,3',
lifestyle: '4'
};
module.exports = {
channels,
gender
};
... ...
/**
* 路由重写
* @author: chenfeng<feng.chen@yoho.cn>
* @date: 2017/2/20
*/
'use strict';
const typeLib = require('../../config/type-lib');
const gender = (req, res, next) => {
let genderName = req.params[0];
if (!genderName || !typeLib.gender[genderName]) {
return next();
}
req.query.gender = typeLib.gender[genderName];
return next();
};
const channel = (req, res, next) => {
let channelName = req.params[0];
if (!channelName) {
return next();
}
req.query.channel = channelName;
req.yoho.channel = channelName;
res.locals.channel = channelName;
req.yoho.pageChannel = {[channelName]: true};
if (typeLib.channels[channelName] <= 2) {
req.query.gender = typeLib.gender[channelName];
}
return next();
};
module.exports = {
gender,
channel
};
... ...
... ... @@ -45,7 +45,7 @@ function getBrandList() {
$.ajax({
url: '/brands/getBrandList',
data: {
channel: window.queryString.channel
channel: window.queryString.channel || $('.query-param[data-attr="yhChannel"]').val()
},
success: function(data) {
$('#placeholder-brandlist').replaceWith(listHbs(data));
... ... @@ -284,8 +284,15 @@ function searchResult() {
});
$genderItem.on('touchstart', function() {
if (window.queryString.channel) {
var index = $(this).data('id') + 1;
window.location.search = 'channel=' + index;
} else {
let name = $(this).data('name').toLowerCase();
window.location.href = `/${name}-brands`;
}
});
$brandItem.on('click', function() {
... ...
... ... @@ -13,6 +13,7 @@ var $ = require('yoho-jquery'),
lazyload = require('yoho-jquery-lazyload');
var search = require('./sale/search');
var defaultOpt = require('../common/query-param');
require('../common');
... ... @@ -52,7 +53,7 @@ $(function() {
$.ajax({
url: '/product/sale/search',
data: {
yh_channel: window.queryString.channel || 'boys',
yh_channel: window.queryString.channel || defaultOpt.channel || 'boys',
saleType: '2',
productPool: $vipFloor.data('id'),
limit: '4'
... ...
... ... @@ -106,7 +106,7 @@ if ($('.sale-vip-page').length > 0) {
// 获取频道
$.extend(defaultOpt, {
yh_channel: getUrlParam('channel') || 'all'
yh_channel: getUrlParam('channel') || defaultOpt.channel || 'all'
});
// 判断导航类型
... ...