Authored by 陈轩

Merge remote-tracking branch 'origin/release/5.1' into release/5.1

... ... @@ -27,10 +27,12 @@ const editor = (req, res, next) => {
id = req.query.id || 0,
title = '编辑简介',
parameter = {},
isApp = req.query.app_version || req.query.appVersion || false,
isApp = req.yoho.isApp,
gender = req.query.gender || req.cookies._Channel && channels[req.cookies._Channel] || 1;
if (isApp === false) {
if (isApp) {
uid = req.query.uid;
} else {
parameter = {
pageHeader: headerModel.setNav({
navTitle: title
... ... @@ -76,7 +78,11 @@ const editor = (req, res, next) => {
const pageData = (req, res, next) => {
/* 判断是不是AJAX请求 */
if (!req.xhr) {
res.json({ code: 400, message: '非法请求', data: '' });
res.json({
code: 400,
message: '非法请求',
data: ''
});
return;
}
... ... @@ -90,15 +96,23 @@ const pageData = (req, res, next) => {
isTab = req.query.isTab || false,
showAuthor = false;
let uid = req.user.uid,
let uid = req.user.uid || req.query.uid,
udid = req.sessionID;
if (!stringProcess.isNumeric(sortId)) {
res.json({ code: 400, message: '参数错误', data: '' });
res.json({
code: 400,
message: '参数错误',
data: ''
});
return;
}
if (!page && !isNaN(page)) {
res.json({ code: 400, message: '参数错误', data: '' });
res.json({
code: 400,
message: '参数错误',
data: ''
});
return;
}
if (!authorId && isNaN(authorId)) {
... ... @@ -106,9 +120,15 @@ const pageData = (req, res, next) => {
}
return indexModel.getPageData(gender, sortId, uid, udid, page, tag, authorId, isApp, showAuthor, isTab).then(data => {
if (data) {
res.render('index/page', Object.assign(data, { layout: false }));
res.render('index/page', Object.assign(data, {
layout: false
}));
} else {
res.json({ code: 400, message: '', data: '' });
res.json({
code: 400,
message: '',
data: ''
});
}
}).catch(next);
... ... @@ -134,7 +154,7 @@ const index = (req, res, next) => {
};
let param = {
uid: req.user.uid,
uid: req.user.uid || req.query.uid,
udid: req.user.udid,
... ... @@ -172,7 +192,7 @@ const tag = (req, res, next) => {
tag: req.query.query,
isApp: req.query.app_version || req.query.appVersion || false,
gender: req.query.gender || '1,3',
uid: req.user.uid || 0,
uid: req.user.uid || req.query.uid || 0,
udid: req.sessionID,
type: req.query.type || 0
... ... @@ -203,7 +223,7 @@ const listDynamicData = (req, res) => {
type = req.query.type;
if (req.user.uid) {
other.uid = req.user.uid;
other.uid = req.user.uid || req.query.uid;
}
if (query) {
... ... @@ -227,7 +247,7 @@ const listDynamicData = (req, res) => {
const detailDynamicData = (req, res) => {
let id = req.query.id,
uid = req.user.uid,
uid = req.user.uid || req.query.uid,
udid = req.sessionID;
indexModel.getDynamicDataById(id, uid, udid).then((ret) => {
... ... @@ -244,4 +264,4 @@ module.exports = {
tag,
listDynamicData,
detailDynamicData
};
};
\ No newline at end of file
... ...
... ... @@ -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,8 @@ 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 +335,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 +362,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
... ...
... ... @@ -146,39 +146,42 @@ function initInfosEvt($container) {
// APP收藏
$btn = $this.closest('.collect-btn');
if ($btn.length > 0) {
e.preventDefault();
if ($btn.hasClass('collected')) {
opt = 'cancel';
}
$info = $this.closest('.guang-info');
var uid = getUrlParam('uid');
if (uid) {
e.preventDefault();
if ($btn.hasClass('collected')) {
opt = 'cancel';
}
if (getUrlParam('yh_channel')) {
yhChannel = getUrlParam('yh_channel');
}
$info = $this.closest('.guang-info');
$.ajax({
type: 'POST',
url: '/guang/opt/collectArticle',
data: {
id: $info.data('id'),
opt: opt,
yh_channel: yhChannel,
uid: getUrlParam('uid')
},
success: function(data) {
if (data.code && data.code === 200) {
if (getUrlParam('yh_channel')) {
yhChannel = getUrlParam('yh_channel');
}
// 切换收藏状态
$btn.toggleClass('collected');
} else {
tip.show(data.message);
$.ajax({
type: 'POST',
url: '/guang/opt/collectArticle',
data: {
id: $info.data('id'),
opt: opt,
yh_channel: yhChannel,
uid: uid
},
success: function(data) {
if (data.code && data.code === 200) {
// 切换收藏状态
$btn.toggleClass('collected');
} else {
tip.show(data.message);
}
},
error: function() {
tip.show('网络断开连接了~');
}
},
error: function() {
tip.show('网络断开连接了~');
}
});
});
}
}
});
... ... @@ -251,9 +254,9 @@ function loadMore($container, opt, url) {
if (opt.page === 1) {
loading.hideLoadingMask();
$loading.removeClass('hide');// 显示空屏加载时hide的隐藏
$loading.removeClass('hide'); // 显示空屏加载时hide的隐藏
window.rePosFooter();// 插入内容后重新计算底部位置
window.rePosFooter(); // 插入内容后重新计算底部位置
}
opt.page++;
... ... @@ -275,4 +278,4 @@ exports.mySwiper = mySwiper;
exports.initSwiper = initSwiper;
exports.initInfosEvt = initInfosEvt;
exports.setLazyLoadAndMellipsis = setLazyLoadAndMellipsis;
exports.loadMore = loadMore;
exports.loadMore = loadMore;
\ No newline at end of file
... ...
... ... @@ -84,9 +84,9 @@ const formatArticle = (articleData, showTag, isApp, showAuthor, uid, reqQueryStr
let collectUrl = 'javascript:;'; // 根据用户是否登录做处理的链接
if (!uid) {
let playUrlEncode = originUrl.replace(/\//g, '\\/');
let playUrlEncode = originUrl.replace(/\//g, '\\\/');
collectUrl = `${originUrl}?openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"${playUrlEncode}","param":{"from":"app"}},"requesturl":{"url":"","param":{}},"priority":"N"}}`;
collectUrl = `${originUrl}?openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"http:${playUrlEncode}","param":{"from":"app"}},"requesturl":{"url":"","param":{}},"priority":"N"}}`;
}
result.collect.url = collectUrl;
} else { // 点赞
... ... @@ -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
... ...