Authored by 沈志敏

fix bug

... ... @@ -51,8 +51,7 @@ const _pageArticleContent = (articleContent, isApp, gender) => {
src: helpers.image(imgs[0].src, 315, 420)
}, {
src: helpers.image(imgs[1].src, 315, 420)
}
];
}];
contents.push(build);
joinContentFunc(++i, len);
... ... @@ -80,7 +79,7 @@ const _pageArticleContent = (articleContent, isApp, gender) => {
for (let o = 0; o < product.data.product_list.length; o++) {
let goods = product.data.product_list[o];
// 最多显示4个
// 最多显示4个
if (o > 3) {
break;
}
... ... @@ -94,7 +93,7 @@ const _pageArticleContent = (articleContent, isApp, gender) => {
});
}
// 多个商品
// 多个商品
if (product.data.product_list.length && (product.data.product_list.length > 1)) {
build.relatedReco = reco;
} else if (product.data.product_list.length === 1) { // 单个商品
... ... @@ -249,13 +248,17 @@ const index = (req, res, next) => {
parameter = {},
title = '逛';
// pagecache 前端做
// userAgent = req.get('User-Agent'),
// isWeixin = userAgent.includes('MicroMessenger'); // 标识是否是微信访问
// pagecache 前端做
// userAgent = req.get('User-Agent'),
// isWeixin = userAgent.includes('MicroMessenger'); // 标识是否是微信访问
// 判断参数是否有效, 无效会跳转到错误页面
if (!stringProcess.isNumeric(id)) {
res.json({ code: 400, message: '非法请求', data: '' });
res.json({
code: 400,
message: '非法请求',
data: ''
});
return;
}
parameter = {
... ... @@ -297,7 +300,6 @@ const index = (req, res, next) => {
// guang双头部的问题 20160601
// 正确的URL
data.guang.author.url = helpers.https(`${detail.getAuthor.url}&openby:yohobuy={"action":"go.h5","params":{"param":{},"share":"","id":${detail.getAuthor.author_id},"type":0,"islogin":"N","url":"${detail.getAuthor.url}"}}`);
// 错误的URL
// data.guang.author.url = helpers.https(`${detail.getAuthor.url}&openby:yohobuy={"action":"go.h5","params":{"param":{"id":"${detail.getAuthor.author_id}"},"share":"","id":${detail.getAuthor.author_id},"type":0,"islogin":"N","url":"${helpers.urlFormat('/author/index', {}, 'guang')}"}}`);
}
... ... @@ -340,7 +342,6 @@ const index = (req, res, next) => {
data.description = detail.getArticle.article_summary;
data.description_more = true;
}
// 标识有微信分享
data.hasWxShare = true;
res.render('info/index', Object.assign({
... ... @@ -369,7 +370,11 @@ const mini = (req, res, next) => {
// 判断参数是否有效, 无效会跳转到错误页面
if (!stringProcess.isNumeric(id)) {
res.json({ code: 400, message: '非法请求', data: '' });
res.json({
code: 400,
message: '非法请求',
data: ''
});
return;
}
... ... @@ -440,7 +445,11 @@ const foryoho = (req, res, next) => {
// 判断参数是否有效, 无效会跳转到错误页面
if (!stringProcess.isNumeric(id)) {
res.json({ code: 400, message: '非法请求', data: '' });
res.json({
code: 400,
message: '非法请求',
data: ''
});
return;
}
... ... @@ -492,4 +501,4 @@ module.exports = {
index,
mini,
foryoho
};
};
\ No newline at end of file
... ...
... ... @@ -166,7 +166,9 @@ const getArticle = (param) => {
let page = param.page ? param.page : 1;
Object.assign(param, { page: page });
Object.assign(param, {
page: page
});
return api.all([
_category(),
... ... @@ -182,7 +184,7 @@ const getArticle = (param) => {
};
// 顶部的分类列表
let curIndex = 0;// 当前tab顺序
let curIndex = 0; // 当前tab顺序
let indexTmp = 0;
... ... @@ -265,7 +267,9 @@ const getTagEditor = (param) => {
let page = param.page ? param.page : 1;
Object.assign(param, { page: page });
Object.assign(param, {
page: page
});
return api.all([
_article(param)
... ... @@ -285,10 +289,9 @@ const getTagEditor = (param) => {
let inf = [];
let infoList = result[0].data.list.artList;
infoList.forEach(val => {
val.url = helpers.https(`${val.url}&openby:yohobuy={"action":"go.h5","params":{"param":{},"share":"","id":"","type":0,"islogin":"N","url":"${val.url}"}}`);
inf.push(guangProcess.formatArticle(val, true, false, true));
inf.push(guangProcess.formatArticle(val, true, param.isApp, true));
});
resu.guang.infos = inf;
... ... @@ -333,7 +336,9 @@ const getDynamicDataByIds = (ids, udid, other) => {
});
}
return serviceAPI.get('guang/api/v6/article/getSimpleArticleList', params, {cache: true});
return serviceAPI.get('guang/api/v6/article/getSimpleArticleList', params, {
cache: true
});
};
/**
... ... @@ -358,4 +363,4 @@ module.exports = {
getTagEditor,
getDynamicDataByIds,
getDynamicDataById
};
};
\ No newline at end of file
... ...
... ... @@ -40,11 +40,11 @@ const packageData = (id, isApp) => {
cache: true
}).then(data => {
// 接口要判断一下返回状态是否成功
if (data === '' && data.code !== 200) {
if (!data || data.code !== 200) {
result.code = 400;
return result;
}
let article = data.data;
let article = data.data || {};
result.getArticle = article;
... ... @@ -136,7 +136,9 @@ const packageData = (id, isApp) => {
}
}
getArticleContent.splice(preCount, 0, {weixinPublic: datas[4].data});
getArticleContent.splice(preCount, 0, {
weixinPublic: datas[4].data
});
}
if (datas[0]) {
result.getAuthor = datas[0].data;
... ... @@ -177,4 +179,4 @@ const intro = (id) => {
module.exports = {
packageData,
intro
};
};
\ No newline at end of file
... ...
... ... @@ -110,7 +110,7 @@ const formatArticle = (articleData, showTag, isApp, showAuthor, uid, reqQueryStr
// 编辑人员 app跳转url处理 20160601
let isLogin = uid ? true : false;
articleData.author.url = `${helpers.https(articleData.author.url)}&openby:yohobuy={"action":"go.h5","params":{"param":{"id":"${articleData.author.author_id}"},"share":"","id":${articleData.author.author_id},"type":0,"islogin":"${isLogin}","url":"https:${helpers.urlFormat('/author/index', {uid: uid}, 'guang')}"}}&uid=${uid}`;
articleData.author.url = `${helpers.https(articleData.author.url)}&openby:yohobuy={"action":"go.h5","params":{"param":{},"share":"","id":${articleData.author.author_id},"type":0,"islogin":"${isLogin}","url":"${articleData.author.url}"}}`;
result.author = articleData.author;
if (result.author.avatar) {
result.author.avatar = result.author.avatar.replace('http://', '//');
... ... @@ -282,8 +282,8 @@ const formatProduct = (productData, showTags, showNew, showSale, width, height,
if (showTags) {
result.tags = {
is_new: showNew && productData.is_new === 'Y', // 新品
is_discount: showSale && productData.is_discount === 'Y', // 在售
is_limited: productData.is_limited && productData.is_limited === 'Y', // 限量
is_discount: showSale && productData.is_discount === 'Y', // 在售
is_limited: productData.is_limited && productData.is_limited === 'Y', // 限量
is_yohood: productData.is_yohood && productData.is_yohood === 'Y', // YOHOOD
midYear: productData.midear && productData.midear === 'Y', // 年中
yearEnd: productData.yearnd && productData.yearnd === 'Y', // 年末
... ... @@ -294,7 +294,7 @@ const formatProduct = (productData, showTags, showNew, showSale, width, height,
if (result.is_soon_sold_out && result.tags.is_discount) {
result.tags.is_new = false;
} else if (result.tags.is_discount &&
(result.tags.is_new || result.tags.is_limited || result.tags.is_yohood || result.tags.is_advance)// 打折与其它组合则隐藏打折
(result.tags.is_new || result.tags.is_limited || result.tags.is_yohood || result.tags.is_advance) // 打折与其它组合则隐藏打折
) {
result.tags.is_discount = false;
} else if (result.tags.is_yohood && result.tags.is_new) { // YOHOOD和新品组合显示YOHOOD
... ... @@ -312,4 +312,4 @@ module.exports = {
getFilterUrl,
formatProduct,
getProductIcon
};
};
\ No newline at end of file
... ...