|
@@ -4,6 +4,7 @@ |
|
@@ -4,6 +4,7 @@ |
4
|
* @date: 2016/09/07
|
4
|
* @date: 2016/09/07
|
5
|
*/
|
5
|
*/
|
6
|
'use strict';
|
6
|
'use strict';
|
|
|
7
|
+const co = require('bluebird').coroutine;
|
7
|
const helpers = global.yoho.helpers;
|
8
|
const helpers = global.yoho.helpers;
|
8
|
const mRoot = '../models';
|
9
|
const mRoot = '../models';
|
9
|
const typeLib = require('../../../config/type-lib');
|
10
|
const typeLib = require('../../../config/type-lib');
|
|
@@ -344,10 +345,6 @@ const index = (req, res, next) => { |
|
@@ -344,10 +345,6 @@ const index = (req, res, next) => { |
344
|
|
345
|
|
345
|
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}"}}}`;
|
346
|
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}"}}}`;
|
346
|
|
347
|
|
347
|
- // pagecache 前端做
|
|
|
348
|
- // userAgent = req.get('User-Agent'),
|
|
|
349
|
- // isWeixin = userAgent.includes('MicroMessenger'); // 标识是否是微信访问
|
|
|
350
|
-
|
|
|
351
|
// 判断参数是否有效, 无效会跳转到错误页面
|
348
|
// 判断参数是否有效, 无效会跳转到错误页面
|
352
|
if (!stringProcess.isNumeric(id)) {
|
349
|
if (!stringProcess.isNumeric(id)) {
|
353
|
res.json({
|
350
|
res.json({
|
|
@@ -366,17 +363,8 @@ const index = (req, res, next) => { |
|
@@ -366,17 +363,8 @@ const index = (req, res, next) => { |
366
|
|
363
|
|
367
|
isShare = isWeixin || isqq || isWeibo ? true : false;
|
364
|
isShare = isWeixin || isqq || isWeibo ? true : false;
|
368
|
|
365
|
|
369
|
- // WAP上设置头部导航 pagecache
|
|
|
370
|
- // if (!isApp && !isWeixin) {
|
|
|
371
|
- // parameter = {
|
|
|
372
|
- // pageHeader: headerModel.setNav({
|
|
|
373
|
- // navTitle: title
|
|
|
374
|
- // })
|
|
|
375
|
- // };
|
|
|
376
|
- // }
|
|
|
377
|
-
|
|
|
378
|
- // 获取详情内容信息, 异常则跳到错误页面
|
|
|
379
|
- return req.ctx(DetailModel).packageData(id, isApp, isWeixin, channel, isShare).then(detail => {
|
366
|
+ co(function* () {
|
|
|
367
|
+ let detail = yield req.ctx(DetailModel).packageData(id, isApp, isWeixin, channel, isShare);
|
380
|
let data = {
|
368
|
let data = {
|
381
|
guangDetail: true,
|
369
|
guangDetail: true,
|
382
|
guang: {}
|
370
|
guang: {}
|
|
@@ -425,65 +413,59 @@ const index = (req, res, next) => { |
|
@@ -425,65 +413,59 @@ const index = (req, res, next) => { |
425
|
return next();
|
413
|
return next();
|
426
|
}
|
414
|
}
|
427
|
|
415
|
|
428
|
- guangProcess.processArticleDetail(detail.getArticleContent,
|
416
|
+ let processContents = guangProcess.processArticleDetail(detail.getArticleContent,
|
429
|
isApp,
|
417
|
isApp,
|
430
|
gender,
|
418
|
gender,
|
431
|
isWeixin,
|
419
|
isWeixin,
|
432
|
isqq,
|
420
|
isqq,
|
433
|
isWeibo);
|
421
|
isWeibo);
|
434
|
|
422
|
|
435
|
- // 生成内容部分
|
|
|
436
|
- return _pageArticleContent(detail.getArticleContent,
|
|
|
437
|
- isApp,
|
|
|
438
|
- gender,
|
|
|
439
|
- isWeixin,
|
|
|
440
|
- isqq,
|
|
|
441
|
- isWeibo).then((contents) => {
|
|
|
442
|
- // console.log(contents);
|
|
|
443
|
- guang.detail.content = contents;
|
423
|
+ let goodsList = yield req.ctx(DetailModel).productInfoBySkns(processContents.allgoods);
|
444
|
|
424
|
|
445
|
- // 相关品牌
|
|
|
446
|
- if (detail.getBrand && detail.getBrand.length) {
|
|
|
447
|
- guang.relatedBrand = _relatedBrand(detail.getBrand, isApp);
|
|
|
448
|
- }
|
425
|
+ guang.detail.content = guangProcess.pushGoodsInfo(processContents.finalDetail, goodsList);
|
449
|
|
426
|
|
450
|
- // 相关标签
|
|
|
451
|
- if (detail.getArticle.tags && detail.getArticle.tags.length) {
|
|
|
452
|
- guang.relatedTag = _relatedTag(detail.getArticle.tags, isApp);
|
|
|
453
|
- }
|
427
|
+ // 相关品牌
|
|
|
428
|
+ if (detail.getBrand && detail.getBrand.length) {
|
|
|
429
|
+ guang.relatedBrand = _relatedBrand(detail.getBrand, isApp);
|
|
|
430
|
+ }
|
454
|
|
431
|
|
455
|
- // 相关文章
|
|
|
456
|
- if (detail.getOtherArticle && detail.getOtherArticle.length) {
|
|
|
457
|
- guang.relatedInfo = _relatedInfo(detail.getOtherArticle, isApp);
|
|
|
458
|
- }
|
432
|
+ // 相关标签
|
|
|
433
|
+ if (detail.getArticle.tags && detail.getArticle.tags.length) {
|
|
|
434
|
+ guang.relatedTag = _relatedTag(detail.getArticle.tags, isApp);
|
|
|
435
|
+ }
|
459
|
|
436
|
|
460
|
- // 分享参数
|
|
|
461
|
- if (detail.getArticle.cover_image) {
|
|
|
462
|
- let shareInfo = _shareInfo(id, detail.getArticle);
|
437
|
+ // 相关文章
|
|
|
438
|
+ if (detail.getOtherArticle && detail.getOtherArticle.length) {
|
|
|
439
|
+ guang.relatedInfo = _relatedInfo(detail.getOtherArticle, isApp);
|
|
|
440
|
+ }
|
463
|
|
441
|
|
464
|
- Object.assign(guang, shareInfo);
|
|
|
465
|
- data.title = detail.getArticle.article_title + ' | Yoho!Buy有货 | 潮流购物逛不停';
|
|
|
466
|
- data.title_more = true;
|
|
|
467
|
- data.description = detail.getArticle.article_summary;
|
|
|
468
|
- data.description_more = true;
|
|
|
469
|
- }
|
442
|
+ // 分享参数
|
|
|
443
|
+ if (detail.getArticle.cover_image) {
|
|
|
444
|
+ let shareInfo = _shareInfo(id, detail.getArticle);
|
470
|
|
445
|
|
471
|
- // 标识有微信分享
|
|
|
472
|
- data.hasWxShare = true;
|
|
|
473
|
- aboutModel.about(req.yoho.isApp).then((resu) => {
|
|
|
474
|
- data.guang.wxFooter = resu;
|
|
|
475
|
- res.render('info/index', Object.assign({
|
|
|
476
|
- page: 'info-index',
|
|
|
477
|
- title: '逛',
|
|
|
478
|
- gender: gender,
|
|
|
479
|
- wechatShare: true,
|
|
|
480
|
- isWeixin: isWeixin,
|
|
|
481
|
- localCss: true,
|
|
|
482
|
- isShare: isShare
|
|
|
483
|
- }, data, parameter));
|
|
|
484
|
- });
|
|
|
485
|
- }).catch(next);
|
|
|
486
|
- }).catch(next);
|
446
|
+ Object.assign(guang, shareInfo);
|
|
|
447
|
+ data.title = detail.getArticle.article_title + ' | Yoho!Buy有货 | 潮流购物逛不停';
|
|
|
448
|
+ data.title_more = true;
|
|
|
449
|
+ data.description = detail.getArticle.article_summary;
|
|
|
450
|
+ data.description_more = true;
|
|
|
451
|
+ }
|
|
|
452
|
+
|
|
|
453
|
+ // 标识有微信分享
|
|
|
454
|
+ data.hasWxShare = true;
|
|
|
455
|
+
|
|
|
456
|
+ let resu = aboutModel.about(req.yoho.isApp);
|
|
|
457
|
+
|
|
|
458
|
+ data.guang.wxFooter = resu;
|
|
|
459
|
+ res.render('info/index', Object.assign({
|
|
|
460
|
+ page: 'info-index',
|
|
|
461
|
+ title: '逛',
|
|
|
462
|
+ gender: gender,
|
|
|
463
|
+ wechatShare: true,
|
|
|
464
|
+ isWeixin: isWeixin,
|
|
|
465
|
+ localCss: true,
|
|
|
466
|
+ isShare: isShare
|
|
|
467
|
+ }, data, parameter));
|
|
|
468
|
+ })().catch(next);
|
487
|
};
|
469
|
};
|
488
|
|
470
|
|
489
|
// 301到新路由
|
471
|
// 301到新路由
|