Authored by yyq

产品大全

... ... @@ -77,15 +77,12 @@ const link = (req, res, next) => {
*/
const category = (req, res, next) => {
let channel = req.yoho.channel || 'boys';
let resData = {};
return Promise.all([
headerModel.requestHeaderData(channel),
req.ctx(aboutModel).getCategoryDataWithCache(channel)
]).then(result => {
Object.assign(resData, responseData, result[0], result[1]);
res.render('category', resData);
res.render('category', Object.assign(result[1], responseData, result[0]));
}).catch(next);
};
... ... @@ -95,10 +92,11 @@ const category = (req, res, next) => {
const chanpin = (req, res, next) => {
let channel = req.yoho.channel || 'boys';
headerModel.requestHeaderData(channel).then(result => {
responseData.headerData = result.headerData;
res.render('chanpin', responseData);
return Promise.all([
headerModel.requestHeaderData(channel),
req.ctx(aboutModel).getChanpinData(channel)
]).then(result => {
res.render('chanpin', Object.assign(result[1], responseData, result[0]));
}).catch(next);
};
... ...
... ... @@ -3,6 +3,7 @@ const _ = require('lodash');
const cache = global.yoho.cache;
const logger = global.yoho.logger;
const helpers = global.yoho.helpers;
const redis = global.yoho.redis;
const hotBrandsModel = require('../../../doraemon/models/hot-brands');
... ... @@ -118,7 +119,30 @@ module.exports = class extends global.yoho.BaseModel {
});
}
getChanpinData() {
getChanpinData(channel) {
return Promise.all([
redis.all([['get', 'global:yoho:seo:goodsAll']]),
hotBrandsModel.hotBrands()
]).then(result => {
let upChannel = _.toUpper(channel);
let chanpinList = [];
try {
chanpinList = JSON.parse(_.get(result, '[0][0]'));
} catch (e) {
logger.debug('chanpin all goods data parse fail.');
}
return {
pathNav: [
{pathTitle: `${upChannel}首页`, name: `${upChannel}首页`, href: indexUrl[channel]},
{pathTitle: '全部分类', name: '全部分类'}
],
hotBrands: result[1],
chanpinList
};
});
}
};
... ...
... ... @@ -14,7 +14,7 @@ router.get('/contact.html', aboutCtrl.contact);
router.get('/privacy.html', aboutCtrl.privacy);
router.get('/link.html', aboutCtrl.link);
router.get('/categorymap.html', aboutCtrl.category);
router.get('/chanpinmap.html', aboutCtrl.link);
router.get('/chanpinmap.html', aboutCtrl.chanpin);
module.exports = router;
... ...
<div class="chanpin-map-page center-content yoho-page">
{{> common/path-nav}}
<div class="chanpin-block">
<h1 class="main-title">商品大全</h1>
<ul class="list-block clearfix">
{{# chanpinList}}
<li><a href="/chanpin/{{id}}.html">{{keyword}}</a></li>
{{/ chanpinList}}
</ul>
</div>
{{#if hotBrands}}
<div class="hot-brands clearfix">
{{# hotBrands}}
<a href="{{url}}" alt="{{title}}">
<img src="{{image image}}" title="{{title}}">
</a>
{{/ hotBrands}}
</div>
{{/if}}
</div>
... ...
.chanpin-map-page {
.path-nav {
padding: 22px 0;
}
.chanpin-block {
font-size: 12px;
border: 1px solid #dfdfdf;
margin-bottom: 30px;
overflow: hidden;
.main-title {
line-height: 50px;
background-color: #eaeceb;
padding-left: 20px;
font-weight: bold;
}
}
.list-block {
width: 100.5%;
margin-bottom: -1px;
li {
width: 25%;
height: 50px;
line-height: 50px;
border: 1px solid #dfdfdf;
margin-left: -1px;
margin-top: -1px;
text-align: center;
float: left;
box-sizing: border-box;
}
a {
color: #666;
}
}
.hot-brands {
width: 101%;
margin-bottom: 70px;
> a {
width: 116px;
height: 70px;
display: block;
padding: 10px 8px;
float: left;
box-sizing: border-box;
border: 1px solid #dfdfdf;
margin-left: -1px;
margin-top: -1px;
}
img {
width: 100%;
height: 100%;
display: block;
}
}
}
... ...
... ... @@ -5,3 +5,4 @@
@import "link";
@import "privacy";
@import "category";
@import "chanpin";
... ...