product-detail.js
1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
'use strict';
const css = require('../css');
const co = require('bluebird').coroutine;
const _ = require('lodash');
const mRoot = '../models';
const productDetailModel = require(`${mRoot}/product-detail`);
exports.index = (req, res, next) => {
co(function* () {
let params = {
productSkn: req.params.skn,
protocol: req.protocol
};
let detailData = yield req.ctx(productDetailModel).index(params);
let mipPic = _.get(detailData, 'baseInfo.goods_list[0].images_list[0].image_url');
let mipDes = _.get(detailData, 'baseInfo.phrase');
let miptitle = _.get(detailData, 'baseInfo.product_name');
if (!_.get(detailData, 'baseInfo.product_skn')) {
return next();
}
return res.render('product/detail', Object.assign(detailData, {
title: `${detailData.title}-YOHO!BUY有货`,
css: yield css('product/detail.css'),
localStyle: detailData.mipCss,
mipFooter: true,
canonical: {
currentHref: `https://m.yohobuy.com/product/${detailData.baseInfo.product_skn}.html`
},
showAnaJson: {
url: `${req.protocol}://m.yohobuy.com${req.originalUrl}`,
title: `${miptitle}-YOHO!BUY有货`,
pic: mipPic,
des: mipDes,
publishTime: ''
}
}));
})().catch(next);
};