Authored by zhangxiaoru

微信公众号

@@ -55,6 +55,10 @@ const _pageArticleContent = (articleContent, isApp, gender) => { @@ -55,6 +55,10 @@ const _pageArticleContent = (articleContent, isApp, gender) => {
55 contents.push(build); 55 contents.push(build);
56 joinContentFunc(++i, len); 56 joinContentFunc(++i, len);
57 57
  58 + } else if (art.weixinPublic) {
  59 + build.weixinPublic = art.weixinPublic;
  60 + contents.push(build);
  61 + joinContentFunc(++i, len);
58 } else if (art.goods && art.goods.data) { // 相关推荐 62 } else if (art.goods && art.goods.data) { // 相关推荐
59 let reco = [], 63 let reco = [],
60 skns = [], 64 skns = [],
@@ -155,6 +159,7 @@ const _pageArticleContent = (articleContent, isApp, gender) => { @@ -155,6 +159,7 @@ const _pageArticleContent = (articleContent, isApp, gender) => {
155 joinContentFunc(0, articleContent.length); 159 joinContentFunc(0, articleContent.length);
156 }); 160 });
157 } 161 }
  162 +
158 /** 163 /**
159 * [处理品牌数据] 164 * [处理品牌数据]
160 * @param {[array]} getBrand [品牌原数据] 165 * @param {[array]} getBrand [品牌原数据]
@@ -285,6 +290,7 @@ const index = (req, res, next) => { @@ -285,6 +290,7 @@ const index = (req, res, next) => {
285 //生成内容部分 290 //生成内容部分
286 return _pageArticleContent(detail.getArticleContent, isApp, gender).then((contents) => { 291 return _pageArticleContent(detail.getArticleContent, isApp, gender).then((contents) => {
287 guang.detail.content = contents; 292 guang.detail.content = contents;
  293 +
288 // 相关品牌 294 // 相关品牌
289 if (detail.getBrand && detail.getBrand.length) { 295 if (detail.getBrand && detail.getBrand.length) {
290 guang.relatedBrand = _relatedBrand(detail.getBrand); 296 guang.relatedBrand = _relatedBrand(detail.getBrand);
@@ -5,6 +5,8 @@ @@ -5,6 +5,8 @@
5 */ 5 */
6 'use strict'; 6 'use strict';
7 const serviceAPI = global.yoho.ServiceAPI; 7 const serviceAPI = global.yoho.ServiceAPI;
  8 +const api = global.yoho.API;
  9 +const _ = require('lodash');
8 10
9 const URI_PACKAGE_ARTICLE = 'guang/service/v2/article/'; 11 const URI_PACKAGE_ARTICLE = 'guang/service/v2/article/';
10 const URI_PACKAGE_AUTHOR = 'guang/service/v1/author/'; 12 const URI_PACKAGE_AUTHOR = 'guang/service/v1/author/';
@@ -82,6 +84,14 @@ const packageData = (id, isApp) => { @@ -82,6 +84,14 @@ const packageData = (id, isApp) => {
82 cache: true 84 cache: true
83 })); 85 }));
84 86
  87 + if (isApp) {
  88 + promises.push(api.get('', {
  89 + method: 'app.resources.getSingleTemplate',
  90 + module: 'wechat',
  91 + key: 'guang_detail_wechat'
  92 + }));
  93 + }
  94 +
85 // 获取资讯相关的其它资讯 95 // 获取资讯相关的其它资讯
86 if (typeof article.tag !== 'undefined') { 96 if (typeof article.tag !== 'undefined') {
87 param = { 97 param = {
@@ -99,11 +109,29 @@ const packageData = (id, isApp) => { @@ -99,11 +109,29 @@ const packageData = (id, isApp) => {
99 })); 109 }));
100 } 110 }
101 return Promise.all(promises).then(datas => { 111 return Promise.all(promises).then(datas => {
  112 + let getArticleContent = datas[1].data;
  113 +
  114 + if (datas[3].data) {
  115 +
  116 + let preCount = 0;
  117 + let frontData = [];
  118 + let backData = [];
  119 + let i;
  120 +
  121 + for(i = 0; i < getArticleContent.length; i++) {
  122 + if (getArticleContent[i].singleImage || getArticleContent[i].text || getArticleContent[i].smallPic) {
  123 + preCount++;
  124 + }
  125 + }
  126 +
  127 + getArticleContent.splice(preCount, 0, {weixinPublic: datas[3].data});
  128 + }
  129 +
102 result.getAuthor = datas[0].data; 130 result.getAuthor = datas[0].data;
103 - result.getArticleContent = datas[1].data; 131 + result.getArticleContent = getArticleContent;
104 result.getBrand = datas[2].data; 132 result.getBrand = datas[2].data;
105 - if (datas.length === 4) {  
106 - result.getOtherArticle = datas[3].data; 133 + if (datas.length === 5) {
  134 + result.getOtherArticle = datas[4].data;
107 } 135 }
108 return result; 136 return result;
109 }); 137 });
@@ -39,6 +39,16 @@ @@ -39,6 +39,16 @@
39 </div> 39 </div>
40 {{/if}} 40 {{/if}}
41 41
  42 + {{#if weixinPublic}}
  43 + <div class="weixin post-block">
  44 + {{#each weixinPublic}}
  45 + <a href='//m.yohobuy.com/?openby:yohobuy={"action":"go.copy","params":{"text":"{{wechat_id}}"}}' class="ems-cnpl">
  46 + <img class="weixin-img" src="{{image src 280 210 1}}">
  47 + </a>
  48 + {{/each}}
  49 + </div>
  50 + {{/if}}
  51 +
42 {{#if collocation}} 52 {{#if collocation}}
43 <div class="post-block collocation-block"> 53 <div class="post-block collocation-block">
44 <ul class="thumb-container"> 54 <ul class="thumb-container">
@@ -491,4 +491,27 @@ @@ -491,4 +491,27 @@
491 } 491 }
492 } 492 }
493 } 493 }
  494 +
  495 + .weixin {
  496 + margin: 20px 0;
  497 + text-align: center;
  498 + padding: 0 20px;
  499 +
  500 + .ems-cnpl {
  501 + width: 47.3%;
  502 + display: inline-block;
  503 + background: #ededed;
  504 + position: relative;
  505 + overflow: hidden;
  506 +
  507 + .weixin-img {
  508 + width: 100%;
  509 + height: 100%;
  510 + }
  511 + }
  512 +
  513 + a:nth-child(1) {
  514 + margin-right: 20px;
  515 + }
  516 + }
494 } 517 }