Authored by 李靖

渲染css

@@ -126,6 +126,7 @@ const detailIndex = (req, res, next) => { @@ -126,6 +126,7 @@ const detailIndex = (req, res, next) => {
126 channel = req.query.channel || req.cookies._Channel, 126 channel = req.query.channel || req.cookies._Channel,
127 isqq = req.yoho.isqq, 127 isqq = req.yoho.isqq,
128 isWeibo = req.yoho.isWeibo, 128 isWeibo = req.yoho.isWeibo,
  129 + isMip = true,
129 isShare; 130 isShare;
130 131
131 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}"}}}`; 132 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}"}}}`;
@@ -198,7 +199,7 @@ const detailIndex = (req, res, next) => { @@ -198,7 +199,7 @@ const detailIndex = (req, res, next) => {
198 gender, 199 gender,
199 isWeixin, 200 isWeixin,
200 isqq, 201 isqq,
201 - isWeibo); 202 + isWeibo, isMip);
202 203
203 let goodsList = yield req.ctx(DetailModel).productInfoBySkns(processContents.allgoods); 204 let goodsList = yield req.ctx(DetailModel).productInfoBySkns(processContents.allgoods);
204 205
@@ -244,10 +245,8 @@ const detailIndex = (req, res, next) => { @@ -244,10 +245,8 @@ const detailIndex = (req, res, next) => {
244 gender: gender, 245 gender: gender,
245 wechatShare: true, 246 wechatShare: true,
246 isWeixin: isWeixin, 247 isWeixin: isWeixin,
247 - isShare: isShare  
248 -  
249 - // localStyle: mipData.css,  
250 - // msg: mipData.mipHtml, 248 + isShare: isShare,
  249 + localStyle: processContents.css
251 }, data)); 250 }, data));
252 })().catch(next); 251 })().catch(next);
253 }; 252 };
@@ -2,12 +2,12 @@ @@ -2,12 +2,12 @@
2 {{# guang}} 2 {{# guang}}
3 {{# author}} 3 {{# author}}
4 <div class="editor-info" data-id={{id}}> 4 <div class="editor-info" data-id={{id}}>
5 - <a href={{url}}> 5 + <mip-link href={{url}}>
6 <mip-img class="pic" src={{image2 avatar mode=2 q=60}}> 6 <mip-img class="pic" src={{image2 avatar mode=2 q=60}}>
7 </mip-img> 7 </mip-img>
8 <div class="name">{{name}}</div> 8 <div class="name">{{name}}</div>
9 <div class="intro">{{intro}}</div> 9 <div class="intro">{{intro}}</div>
10 - </a> 10 + </mip-link>
11 </div> 11 </div>
12 {{/ author}} 12 {{/ author}}
13 {{# detail}} 13 {{# detail}}
@@ -32,7 +32,7 @@ @@ -32,7 +32,7 @@
32 {{#each tagList}} 32 {{#each tagList}}
33 {{#unless isApp}} 33 {{#unless isApp}}
34 <div class="label-box" data-skn="{{product_skn}}"> 34 <div class="label-box" data-skn="{{product_skn}}">
35 - <div class="lable-info-box{{#if isApp}} lable-infobox-borderadius{{/if}}"><a href="{{href}}">{{tagName}}</a></div> 35 + <div class="lable-info-box{{#if isApp}} lable-infobox-borderadius{{/if}}"><mip-link href="{{href}}">{{tagName}}</mip-link></div>
36 <div class="lable-btn add-to-cart" data-skn="{{product_skn}}"> 36 <div class="lable-btn add-to-cart" data-skn="{{product_skn}}">
37 </div> 37 </div>
38 </div> 38 </div>
@@ -54,7 +54,7 @@ @@ -54,7 +54,7 @@
54 <div class="related-goods clearfix"> 54 <div class="related-goods clearfix">
55 {{#each relatedReco.goods}} 55 {{#each relatedReco.goods}}
56 <div class="good-item"> 56 <div class="good-item">
57 - <a href="{{url}}"> 57 + <mip-link href="{{url}}">
58 {{#if default_images}} 58 {{#if default_images}}
59 <mip-img class="pic" src="{{image2 default_images w=152 h=204}}"> 59 <mip-img class="pic" src="{{image2 default_images w=152 h=204}}">
60 </mip-img> 60 </mip-img>
@@ -65,7 +65,7 @@ @@ -65,7 +65,7 @@
65 <p class="price">&yen;{{sales_price}}</p> 65 <p class="price">&yen;{{sales_price}}</p>
66 {{/if}} 66 {{/if}}
67 </div> 67 </div>
68 - </a> 68 + </mip-link>
69 </div> 69 </div>
70 {{/each}} 70 {{/each}}
71 </div> 71 </div>
@@ -75,17 +75,17 @@ @@ -75,17 +75,17 @@
75 {{/ detail}} 75 {{/ detail}}
76 {{#detail.content}} 76 {{#detail.content}}
77 {{#if moreLink}} 77 {{#if moreLink}}
78 - <a class="more-goods" href="{{moreLink}}">更多商品</a> 78 + <mip-link class="more-goods" href="{{moreLink}}">更多商品</mip-link>
79 {{/if}} 79 {{/if}}
80 {{#if recommendProducts}} 80 {{#if recommendProducts}}
81 <div class="recommend-goods"> 81 <div class="recommend-goods">
82 <div class="good-scroll"> 82 <div class="good-scroll">
83 {{#each recommendProducts}} 83 {{#each recommendProducts}}
84 <div class="good-item"> 84 <div class="good-item">
85 - <a href="{{href}}"> 85 + <mip-link href="{{href}}">
86 <mip-img class="pic" src="{{image2 pic_url w=152 h=204}}"> 86 <mip-img class="pic" src="{{image2 pic_url w=152 h=204}}">
87 </mip-img> 87 </mip-img>
88 - </a> 88 + </mip-link>
89 <p class="price">&yen;{{price}}</p> 89 <p class="price">&yen;{{price}}</p>
90 </div> 90 </div>
91 {{/each}} 91 {{/each}}
@@ -99,11 +99,11 @@ @@ -99,11 +99,11 @@
99 <div class="brand-c"> 99 <div class="brand-c">
100 {{# relatedBrand}} 100 {{# relatedBrand}}
101 <div class="brand-item"> 101 <div class="brand-item">
102 - <a href={{url}}> 102 + <mip-link href={{url}}>
103 <mip-img class="pic" src="{{thumb}}"> 103 <mip-img class="pic" src="{{thumb}}">
104 </mip-img> 104 </mip-img>
105 <p>{{name}}</p> 105 <p>{{name}}</p>
106 - </a> 106 + </mip-link>
107 </div> 107 </div>
108 {{/ relatedBrand}} 108 {{/ relatedBrand}}
109 </div> 109 </div>
@@ -113,14 +113,14 @@ @@ -113,14 +113,14 @@
113 <div class="related-info"> 113 <div class="related-info">
114 {{# relatedInfo}} 114 {{# relatedInfo}}
115 <div class="info-item"> 115 <div class="info-item">
116 - <a href={{url}}> 116 + <mip-link href={{url}}>
117 <mip-img class="pic" src="{{thumb}}"> 117 <mip-img class="pic" src="{{thumb}}">
118 </mip-img> 118 </mip-img>
119 <div class="info"> 119 <div class="info">
120 <p class="title">{{title}}</p> 120 <p class="title">{{title}}</p>
121 <p class="time">{{publishTime}}</p> 121 <p class="time">{{publishTime}}</p>
122 </div> 122 </div>
123 - </a> 123 + </mip-link>
124 </div> 124 </div>
125 {{/ relatedInfo}} 125 {{/ relatedInfo}}
126 </div> 126 </div>
@@ -128,7 +128,7 @@ @@ -128,7 +128,7 @@
128 {{#if relatedTag}} 128 {{#if relatedTag}}
129 <div class="brand-tag"> 129 <div class="brand-tag">
130 {{# relatedTag}} 130 {{# relatedTag}}
131 - <div class="tag">{{name}}</div> 131 + <mip-link href="//guang.m.yohobuy.com/tags/index?query={{name}}" class="tag">{{name}}</mip-link>
132 {{/ relatedTag}} 132 {{/ relatedTag}}
133 </div> 133 </div>
134 {{/if}} 134 {{/if}}
@@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
6 const _ = require('lodash'); 6 const _ = require('lodash');
7 const helpers = global.yoho.helpers; 7 const helpers = global.yoho.helpers;
8 const productPrcs = require('./product-process'); 8 const productPrcs = require('./product-process');
  9 +const mipUtils = require('../apps/mip/mip-utils');
9 10
10 /** 11 /**
11 * 将商品转化成以 product_skn 为键名的对象 12 * 将商品转化成以 product_skn 为键名的对象
@@ -206,16 +207,28 @@ const getProductIcon = (type) => { @@ -206,16 +207,28 @@ const getProductIcon = (type) => {
206 /** 207 /**
207 * 逛详情页数据处理 208 * 逛详情页数据处理
208 */ 209 */
209 -const processArticleDetail = (articleContent, isApp, gender, isWeixin, isqq, isWeibo) => { 210 +const processArticleDetail = (articleContent, isApp, gender, isWeixin, isqq, isWeibo, isMip) => {
210 let finalDetail = []; 211 let finalDetail = [];
211 let allgoods = ''; 212 let allgoods = '';
  213 + let localStyle = [];
212 214
213 _.forEach(articleContent, (value, index) => { 215 _.forEach(articleContent, (value, index) => {
214 216
215 // 文字 217 // 文字
216 if (_.get(value, 'text.data.text', false)) { 218 if (_.get(value, 'text.data.text', false)) {
  219 + let newText = '';
  220 + let aa = '<img src="#" /><span>lsadhilkah</span><a style="color:red;" href="#">sdsd</a>';
  221 +
  222 + if (isMip) {
  223 + let mipHtml = mipUtils.process(aa, index);
  224 +
  225 + newText = mipHtml.mipHtml;
  226 + localStyle.push(mipHtml.css);
  227 + } else {
  228 + newText = value.text.data.text;
  229 + }
217 finalDetail.push({ 230 finalDetail.push({
218 - text: value.text.data.text 231 + text: newText
219 }); 232 });
220 } 233 }
221 234
@@ -350,7 +363,8 @@ const processArticleDetail = (articleContent, isApp, gender, isWeixin, isqq, isW @@ -350,7 +363,8 @@ const processArticleDetail = (articleContent, isApp, gender, isWeixin, isqq, isW
350 363
351 return { 364 return {
352 finalDetail: finalDetail, 365 finalDetail: finalDetail,
353 - allgoods: allgoods 366 + allgoods: allgoods,
  367 + css: localStyle.join('')
354 }; 368 };
355 }; 369 };
356 370