Authored by 李靖

渲染css

... ... @@ -126,6 +126,7 @@ const detailIndex = (req, res, next) => {
channel = req.query.channel || req.cookies._Channel,
isqq = req.yoho.isqq,
isWeibo = req.yoho.isWeibo,
isMip = true,
isShare;
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) => {
gender,
isWeixin,
isqq,
isWeibo);
isWeibo, isMip);
let goodsList = yield req.ctx(DetailModel).productInfoBySkns(processContents.allgoods);
... ... @@ -244,10 +245,8 @@ const detailIndex = (req, res, next) => {
gender: gender,
wechatShare: true,
isWeixin: isWeixin,
isShare: isShare
// localStyle: mipData.css,
// msg: mipData.mipHtml,
isShare: isShare,
localStyle: processContents.css
}, data));
})().catch(next);
};
... ...
... ... @@ -2,12 +2,12 @@
{{# guang}}
{{# author}}
<div class="editor-info" data-id={{id}}>
<a href={{url}}>
<mip-link href={{url}}>
<mip-img class="pic" src={{image2 avatar mode=2 q=60}}>
</mip-img>
<div class="name">{{name}}</div>
<div class="intro">{{intro}}</div>
</a>
</mip-link>
</div>
{{/ author}}
{{# detail}}
... ... @@ -32,7 +32,7 @@
{{#each tagList}}
{{#unless isApp}}
<div class="label-box" data-skn="{{product_skn}}">
<div class="lable-info-box{{#if isApp}} lable-infobox-borderadius{{/if}}"><a href="{{href}}">{{tagName}}</a></div>
<div class="lable-info-box{{#if isApp}} lable-infobox-borderadius{{/if}}"><mip-link href="{{href}}">{{tagName}}</mip-link></div>
<div class="lable-btn add-to-cart" data-skn="{{product_skn}}">
</div>
</div>
... ... @@ -54,7 +54,7 @@
<div class="related-goods clearfix">
{{#each relatedReco.goods}}
<div class="good-item">
<a href="{{url}}">
<mip-link href="{{url}}">
{{#if default_images}}
<mip-img class="pic" src="{{image2 default_images w=152 h=204}}">
</mip-img>
... ... @@ -65,7 +65,7 @@
<p class="price">&yen;{{sales_price}}</p>
{{/if}}
</div>
</a>
</mip-link>
</div>
{{/each}}
</div>
... ... @@ -75,17 +75,17 @@
{{/ detail}}
{{#detail.content}}
{{#if moreLink}}
<a class="more-goods" href="{{moreLink}}">更多商品</a>
<mip-link class="more-goods" href="{{moreLink}}">更多商品</mip-link>
{{/if}}
{{#if recommendProducts}}
<div class="recommend-goods">
<div class="good-scroll">
{{#each recommendProducts}}
<div class="good-item">
<a href="{{href}}">
<mip-link href="{{href}}">
<mip-img class="pic" src="{{image2 pic_url w=152 h=204}}">
</mip-img>
</a>
</mip-link>
<p class="price">&yen;{{price}}</p>
</div>
{{/each}}
... ... @@ -99,11 +99,11 @@
<div class="brand-c">
{{# relatedBrand}}
<div class="brand-item">
<a href={{url}}>
<mip-link href={{url}}>
<mip-img class="pic" src="{{thumb}}">
</mip-img>
<p>{{name}}</p>
</a>
</mip-link>
</div>
{{/ relatedBrand}}
</div>
... ... @@ -113,14 +113,14 @@
<div class="related-info">
{{# relatedInfo}}
<div class="info-item">
<a href={{url}}>
<mip-link href={{url}}>
<mip-img class="pic" src="{{thumb}}">
</mip-img>
<div class="info">
<p class="title">{{title}}</p>
<p class="time">{{publishTime}}</p>
</div>
</a>
</mip-link>
</div>
{{/ relatedInfo}}
</div>
... ... @@ -128,7 +128,7 @@
{{#if relatedTag}}
<div class="brand-tag">
{{# relatedTag}}
<div class="tag">{{name}}</div>
<mip-link href="//guang.m.yohobuy.com/tags/index?query={{name}}" class="tag">{{name}}</mip-link>
{{/ relatedTag}}
</div>
{{/if}}
... ...
... ... @@ -6,6 +6,7 @@
const _ = require('lodash');
const helpers = global.yoho.helpers;
const productPrcs = require('./product-process');
const mipUtils = require('../apps/mip/mip-utils');
/**
* 将商品转化成以 product_skn 为键名的对象
... ... @@ -206,16 +207,28 @@ const getProductIcon = (type) => {
/**
* 逛详情页数据处理
*/
const processArticleDetail = (articleContent, isApp, gender, isWeixin, isqq, isWeibo) => {
const processArticleDetail = (articleContent, isApp, gender, isWeixin, isqq, isWeibo, isMip) => {
let finalDetail = [];
let allgoods = '';
let localStyle = [];
_.forEach(articleContent, (value, index) => {
// 文字
if (_.get(value, 'text.data.text', false)) {
let newText = '';
let aa = '<img src="#" /><span>lsadhilkah</span><a style="color:red;" href="#">sdsd</a>';
if (isMip) {
let mipHtml = mipUtils.process(aa, index);
newText = mipHtml.mipHtml;
localStyle.push(mipHtml.css);
} else {
newText = value.text.data.text;
}
finalDetail.push({
text: value.text.data.text
text: newText
});
}
... ... @@ -350,7 +363,8 @@ const processArticleDetail = (articleContent, isApp, gender, isWeixin, isqq, isW
return {
finalDetail: finalDetail,
allgoods: allgoods
allgoods: allgoods,
css: localStyle.join('')
};
};
... ...