Authored by ccbikai(👎🏻🍜)

Merge branch 'release/guang'

... ... @@ -165,16 +165,15 @@ const tag = (req, res, next) => {
pageHeader: headerData,
module: 'guang',
page: 'index-editor',
title: tagTitle + ' | Yoho!Buy有货 | 潮流购物逛不停',
pageFooter: true
title: tagTitle + ' | Yoho!Buy有货 | 潮流购物逛不停'
};
let param = {
tag: req.query.query,
isApp: req.query.app_version || req.query.appVersion || false,
gender: req.query.gender || req.cookies._Channel && channels[req.cookies._Channel] || '1,3',
uid: req.user.uid,
udid: req.user.udid,
gender: req.query.gender || '1,3',
uid: req.user.uid || 0,
udid: req.sessionID,
type: req.query.type || 0
};
... ...
... ... @@ -288,7 +288,11 @@ const index = (req, res, next) => {
};
// guang双头部的问题 20160601
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')}"}}`);
// 正确的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')}"}}`);
}
let guang = data.guang;
... ...
... ... @@ -16,29 +16,59 @@ let channels = {
lifestyle: '4'
};
let yhChannel = {
boys: 1,
girl: 2
};
const getListData = (req, res, next) => {
let gender = req.query.gender || req.cookies._Channel && channels[req.cookies._Channel] || '1,3';
let recom = '4';
let all = '1';
let type = req.query.type;
let channel = req.cookies._Channel && yhChannel[req.cookies._Channel] || 1;
let isRecommend = '0';
let starBrand = '2';
let originalBrand = '3';
plustarModel.getListData(gender, recom, all).then((result) => {
if (type === '2') {
plustarModel.getBrandsData(gender, starBrand, originalBrand, channel, isRecommend).then((result) => {
res.render('plustar/list', {
module: 'guang',
page: 'plustar-list',
title: '明星原创',
pageHeader: headerModel.setNav({
navTitle: '明星原创'
}),
pageFooter: true,
ps: {
sName: '明星潮品',
pName: '原创潮牌',
star: result.star,
plus: result.plus
}
});
}).catch(next);
} else {
plustarModel.getListData(gender, recom, all).then((result) => {
res.render('plustar/list', {
module: 'guang',
page: 'plustar-list',
title: '国际优选',
pageHeader: headerModel.setNav({
navTitle: '国际优选'
}),
pageFooter: true,
ps: {
sName: '设计师',
pName: '经典潮牌',
star: result.star,
plus: result.plus
}
});
}).catch(next);
res.render('plustar/list', {
module: 'guang',
page: 'plustar-list',
title: '国际优选',
pageHeader: headerModel.setNav({
navTitle: '国际优选'
}),
pageFooter: true,
ps: {
sName: '设计师',
pName: '经典潮牌',
star: result.star,
plus: result.plus
}
});
}).catch(next);
}
};
const getDetailData = (req, res, next) => {
... ...
... ... @@ -141,10 +141,10 @@ const _article = (param) => {
page: param.page || 1,
uid: param.uid,
udid: param.udid,
sort_id: param.type === '0' ? param.type : '1',
sort_id: 0,
tag: param.tag ? param.tag : null,
author_id: param.authorId ? param.authorId : null,
limit: param.limit ? param.limit : null
//author_id: param.authorId ? param.authorId : null,
//limit: param.limit ? param.limit : null
}, {
cache: true,
code: 200
... ... @@ -278,13 +278,14 @@ const getTagEditor = (param) => {
}
};
if (result && result[0] && result[0].data && result[0].data.list) {
if (result && result[0] && result[0].data && result[0].data.list && result[0].data.list.artList) {
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));
});
... ...
... ... @@ -40,7 +40,7 @@ const packageData = (id, isApp) => {
cache: true
}).then(data => {
// 接口要判断一下返回状态是否成功
if (data.code !== 200) {
if (data === '' && data.code !== 200) {
result.code = 400;
return result;
}
... ... @@ -110,28 +110,43 @@ const packageData = (id, isApp) => {
}
return Promise.all(promises).then(datas => {
let getArticleContent = datas[1].data;
if (datas) {
if (datas[1]) {
if (isApp && datas[4].data) {
let getArticleContent = datas[1].data;
let preCount = 0;
let i;
result.getArticleContent = getArticleContent;
for (i = 0; i < getArticleContent.length; i++) {
if (getArticleContent[i].singleImage || getArticleContent[i].text || getArticleContent[i].smallPic) {
preCount++;
}
if (isApp && datas[4] && datas[4].data) {
let preCount = 0;
let i;
for (i = 0; i < getArticleContent.length; i++) {
if (getArticleContent[i].singleImage || getArticleContent[i].text || getArticleContent[i].smallPic) {
preCount++;
}
}
getArticleContent.splice(preCount, 0, {weixinPublic: datas[4].data});
}
if (datas[0]) {
result.getAuthor = datas[0].data;
}
getArticleContent.splice(preCount, 0, {weixinPublic: datas[4].data});
}
result.getAuthor = datas[0].data;
result.getArticleContent = getArticleContent;
result.getBrand = datas[2].data;
if (datas.length === 5 && isApp || datas.length === 4 && !isApp) {
result.getOtherArticle = datas[3].data;
if (datas[2]) {
result.getBrand = datas[2].data;
}
if (datas.length === 5 && isApp || datas.length === 4 && !isApp) {
if (datas[3]) {
result.getOtherArticle = datas[3].data;
}
}
}
return result;
});
});
... ...
... ... @@ -9,11 +9,9 @@ const helpers = global.yoho.helpers;
const formaData = (data, gender) => {
let build = [];
// console.log(data)
_.forEach(data, function(val) {
// 多张图
if (val.data[1]) {
let imgs = [];
_.forEach(val.data, function(list) {
... ... @@ -34,7 +32,7 @@ const formaData = (data, gender) => {
}
// 单张图
if (val.data[0]) {
if (val.data[0] && !val.data[1]) {
_.forEach(val.data, function(list) {
build.push({
url: '/guang/plustar/brandinfo?id=' + val.id + '&gender=' + gender,
... ... @@ -48,15 +46,19 @@ const formaData = (data, gender) => {
return build;
};
const getContentData = (gender, type, channel, isRecommend) => {
let param = {
gender: gender,
brand_type: type,
yh_channel: channel
};
const getContentData = (gender, type) => {
if (isRecommend) {
param.is_recommend = isRecommend;
}
return serviceAPI.get('guang/api/v3/plustar/getlist', {
gender: gender,
brand_type: type
}).then((result) => {
return serviceAPI.get('guang/api/v3/plustar/getlist', param).then((result) => {
if (result && result.code === 200) {
// console.log(result)
return formaData(result.data.data.list[0].data, gender);
} else {
logger.error('列表 list data return code is not 200');
... ... @@ -74,6 +76,15 @@ const getListData = (gender, recom, all) => {
});
};
const getBrandsData = (gender, starBrand, originalBrand, channel, isRecommend) => {
return Promise.all([getContentData(gender, starBrand, isRecommend, channel), getContentData(gender, originalBrand, isRecommend, channel)]).then((result) => {
return {
star: result[0],
plus: result[1]
};
});
};
// 新品到着
const getNewProduct = (brandId, gender, url) => {
... ... @@ -97,7 +108,6 @@ const getNewProduct = (brandId, gender, url) => {
let obj = {};
let price;
// console.log(list)
if (index <= 5) {
let tag = [];
... ... @@ -270,5 +280,6 @@ const getDetailData = (id, uid, udid, gender, isApp, clientType) => {
module.exports = {
getListData,
getContentData,
getDetailData
getDetailData,
getBrandsData
};
... ...
... ... @@ -22,7 +22,7 @@
<div class="loading status hide">
正在加载...
</div>
<span class="no-more status">没有更多啦</span>
<span class="no-more status hide">没有更多啦</span>
</div>
{{#if tag}}
... ...
... ... @@ -13,7 +13,6 @@
<div class="swiper-pagination"></div>
</div>
{{/if}}
{{# infos}}
{{> index/info}}
{{/ infos}}
\ No newline at end of file
... ...
... ... @@ -195,7 +195,7 @@ function reMarginFooter(fixedElement) {
a.async = 1;
a.src = j;
m.parentNode.insertBefore(a, m);
})(window, document, 'script', (document.location.protocol === 'https:' ? 'https' : 'http') + '://cdn.yoho.cn/yas-jssdk/1.0.17/yas.js', '_yas');
}(window, document, 'script', (document.location.protocol === 'https:' ? 'https' : 'http') + '://cdn.yoho.cn/yas-jssdk/1.0.17/yas.js', '_yas'));
(function() {
var uid = getUid();
... ...
... ... @@ -215,7 +215,7 @@ function loadMore($container, opt, url) {
success: function(data) {
var $newItems;
if (data === ' ') {
if (data === '') {
opt.end = true;
searching = false;
... ...