...
|
...
|
@@ -4,6 +4,7 @@ |
|
|
* @date: 2016/09/07
|
|
|
*/
|
|
|
'use strict';
|
|
|
const co = require('bluebird').coroutine;
|
|
|
const helpers = global.yoho.helpers;
|
|
|
const mRoot = '../models';
|
|
|
const typeLib = require('../../../config/type-lib');
|
...
|
...
|
@@ -344,10 +345,6 @@ const index = (req, res, next) => { |
|
|
|
|
|
res.locals.appPath = `yohobuy://yohobuy.com/goapp?openby:yohobuy={"action":"go.h5","params":{"id":"${id}","share":"/guang/api/v1/share/guang?id=${id}","shareparam":{"id":"${id}"},"islogin":"N","type":1,"url":"http://guang.m.yohobuy.com/info/index","param":{"id":"${id}"}}}`;
|
|
|
|
|
|
// pagecache 前端做
|
|
|
// userAgent = req.get('User-Agent'),
|
|
|
// isWeixin = userAgent.includes('MicroMessenger'); // 标识是否是微信访问
|
|
|
|
|
|
// 判断参数是否有效, 无效会跳转到错误页面
|
|
|
if (!stringProcess.isNumeric(id)) {
|
|
|
res.json({
|
...
|
...
|
@@ -366,17 +363,8 @@ const index = (req, res, next) => { |
|
|
|
|
|
isShare = isWeixin || isqq || isWeibo ? true : false;
|
|
|
|
|
|
// WAP上设置头部导航 pagecache
|
|
|
// if (!isApp && !isWeixin) {
|
|
|
// parameter = {
|
|
|
// pageHeader: headerModel.setNav({
|
|
|
// navTitle: title
|
|
|
// })
|
|
|
// };
|
|
|
// }
|
|
|
|
|
|
// 获取详情内容信息, 异常则跳到错误页面
|
|
|
return req.ctx(DetailModel).packageData(id, isApp, isWeixin, channel, isShare).then(detail => {
|
|
|
co(function* () {
|
|
|
let detail = yield req.ctx(DetailModel).packageData(id, isApp, isWeixin, channel, isShare);
|
|
|
let data = {
|
|
|
guangDetail: true,
|
|
|
guang: {}
|
...
|
...
|
@@ -425,65 +413,59 @@ const index = (req, res, next) => { |
|
|
return next();
|
|
|
}
|
|
|
|
|
|
guangProcess.processArticleDetail(detail.getArticleContent,
|
|
|
let processContents = guangProcess.processArticleDetail(detail.getArticleContent,
|
|
|
isApp,
|
|
|
gender,
|
|
|
isWeixin,
|
|
|
isqq,
|
|
|
isWeibo);
|
|
|
|
|
|
// 生成内容部分
|
|
|
return _pageArticleContent(detail.getArticleContent,
|
|
|
isApp,
|
|
|
gender,
|
|
|
isWeixin,
|
|
|
isqq,
|
|
|
isWeibo).then((contents) => {
|
|
|
// console.log(contents);
|
|
|
guang.detail.content = contents;
|
|
|
let goodsList = yield req.ctx(DetailModel).productInfoBySkns(processContents.allgoods);
|
|
|
|
|
|
// 相关品牌
|
|
|
if (detail.getBrand && detail.getBrand.length) {
|
|
|
guang.relatedBrand = _relatedBrand(detail.getBrand, isApp);
|
|
|
}
|
|
|
guang.detail.content = guangProcess.pushGoodsInfo(processContents.finalDetail, goodsList);
|
|
|
|
|
|
// 相关标签
|
|
|
if (detail.getArticle.tags && detail.getArticle.tags.length) {
|
|
|
guang.relatedTag = _relatedTag(detail.getArticle.tags, isApp);
|
|
|
}
|
|
|
// 相关品牌
|
|
|
if (detail.getBrand && detail.getBrand.length) {
|
|
|
guang.relatedBrand = _relatedBrand(detail.getBrand, isApp);
|
|
|
}
|
|
|
|
|
|
// 相关文章
|
|
|
if (detail.getOtherArticle && detail.getOtherArticle.length) {
|
|
|
guang.relatedInfo = _relatedInfo(detail.getOtherArticle, isApp);
|
|
|
}
|
|
|
// 相关标签
|
|
|
if (detail.getArticle.tags && detail.getArticle.tags.length) {
|
|
|
guang.relatedTag = _relatedTag(detail.getArticle.tags, isApp);
|
|
|
}
|
|
|
|
|
|
// 分享参数
|
|
|
if (detail.getArticle.cover_image) {
|
|
|
let shareInfo = _shareInfo(id, detail.getArticle);
|
|
|
// 相关文章
|
|
|
if (detail.getOtherArticle && detail.getOtherArticle.length) {
|
|
|
guang.relatedInfo = _relatedInfo(detail.getOtherArticle, isApp);
|
|
|
}
|
|
|
|
|
|
Object.assign(guang, shareInfo);
|
|
|
data.title = detail.getArticle.article_title + ' | Yoho!Buy有货 | 潮流购物逛不停';
|
|
|
data.title_more = true;
|
|
|
data.description = detail.getArticle.article_summary;
|
|
|
data.description_more = true;
|
|
|
}
|
|
|
// 分享参数
|
|
|
if (detail.getArticle.cover_image) {
|
|
|
let shareInfo = _shareInfo(id, detail.getArticle);
|
|
|
|
|
|
// 标识有微信分享
|
|
|
data.hasWxShare = true;
|
|
|
aboutModel.about(req.yoho.isApp).then((resu) => {
|
|
|
data.guang.wxFooter = resu;
|
|
|
res.render('info/index', Object.assign({
|
|
|
page: 'info-index',
|
|
|
title: '逛',
|
|
|
gender: gender,
|
|
|
wechatShare: true,
|
|
|
isWeixin: isWeixin,
|
|
|
localCss: true,
|
|
|
isShare: isShare
|
|
|
}, data, parameter));
|
|
|
});
|
|
|
}).catch(next);
|
|
|
}).catch(next);
|
|
|
Object.assign(guang, shareInfo);
|
|
|
data.title = detail.getArticle.article_title + ' | Yoho!Buy有货 | 潮流购物逛不停';
|
|
|
data.title_more = true;
|
|
|
data.description = detail.getArticle.article_summary;
|
|
|
data.description_more = true;
|
|
|
}
|
|
|
|
|
|
// 标识有微信分享
|
|
|
data.hasWxShare = true;
|
|
|
|
|
|
let resu = aboutModel.about(req.yoho.isApp);
|
|
|
|
|
|
data.guang.wxFooter = resu;
|
|
|
res.render('info/index', Object.assign({
|
|
|
page: 'info-index',
|
|
|
title: '逛',
|
|
|
gender: gender,
|
|
|
wechatShare: true,
|
|
|
isWeixin: isWeixin,
|
|
|
localCss: true,
|
|
|
isShare: isShare
|
|
|
}, data, parameter));
|
|
|
})().catch(next);
|
|
|
};
|
|
|
|
|
|
// 301到新路由
|
...
|
...
|
|