...
|
...
|
@@ -73,27 +73,11 @@ const _processListData = (list) => { |
|
|
|
|
|
});
|
|
|
listData.tabs = list.list.artList;
|
|
|
// console.log(listData)
|
|
|
|
|
|
return listData;
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 资讯首页tab
|
|
|
* @param type
|
|
|
*/
|
|
|
const _getResources = (type, appType) => {
|
|
|
return serviceAPI.get('guang/api/v1/category/get', {
|
|
|
app_type: appType
|
|
|
}).then((result) => {
|
|
|
if (result && result.code === 200) {
|
|
|
return _processNavData(result.data, type);
|
|
|
} else {
|
|
|
logger.error('Information page navigation data return code is not 200');
|
|
|
return {};
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 首页、列表页列表相关
|
...
|
...
|
@@ -102,9 +86,8 @@ const _getResources = (type, appType) => { |
|
|
* @param limit
|
|
|
* @returns {*}
|
|
|
*/
|
|
|
const _getBreakingSort = (type, pageNum, limit, appType) => {
|
|
|
const getIndexData = (pageNum, limit, appType) => {
|
|
|
return serviceAPI.get('guang/api/*/article/getList', {
|
|
|
sort_id: type,
|
|
|
page: pageNum,
|
|
|
limit: limit,
|
|
|
app_type: appType
|
...
|
...
|
@@ -119,23 +102,6 @@ const _getBreakingSort = (type, pageNum, limit, appType) => { |
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 首页接口
|
|
|
* @param type
|
|
|
* @param pageNum
|
|
|
* @param limit
|
|
|
* @returns {*}
|
|
|
*/
|
|
|
const getIndexData = (type, pageNum, limit, appType) => {
|
|
|
return Promise.all([_getResources(type, appType), _getBreakingSort(type, pageNum, limit, appType)])
|
|
|
.then((result) => {
|
|
|
return {
|
|
|
msgTypes: result[0],
|
|
|
msg: result[1]
|
|
|
};
|
|
|
});
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 列表页接口
|
|
|
* @param type
|
|
|
* @param pageNum
|
...
|
...
|
@@ -265,10 +231,9 @@ const _processHeadData = (list) => { |
|
|
* @param id
|
|
|
* @returns {*}
|
|
|
*/
|
|
|
const _getRelatedData = () => {
|
|
|
// console.log(idList);
|
|
|
const _getRelatedData = (idList) => {
|
|
|
return api.get('', {
|
|
|
qurey: '51162882',
|
|
|
query: '51121528,51191714,51176742,51176744,51188385,',
|
|
|
method: 'app.search.li'
|
|
|
}).then((result) => {
|
|
|
let productList = [];
|
...
|
...
|
@@ -276,16 +241,15 @@ const _getRelatedData = () => { |
|
|
if (result && result.code === 200) {
|
|
|
|
|
|
_.forEach(result.data.product_list, function(data) {
|
|
|
console.log(data.product_name)
|
|
|
// productList.push({
|
|
|
// name: data.product_name,
|
|
|
// price: data.sales_price,
|
|
|
// id: data.product_id,
|
|
|
// cnAlphabet: data.cn_alphabet
|
|
|
// });
|
|
|
|
|
|
productList.push({
|
|
|
name: data.product_name,
|
|
|
price: data.sales_price,
|
|
|
id: data.product_id,
|
|
|
cnAlphabet: data.cn_alphabet
|
|
|
});
|
|
|
});
|
|
|
|
|
|
console.log(productList)
|
|
|
return productList;
|
|
|
} else {
|
|
|
logger.error('推荐商品 cood 不是 200');
|
...
|
...
|
@@ -304,8 +268,7 @@ const _processContentData = (list) => { |
|
|
list = camelCase(list);
|
|
|
|
|
|
let contentData = {
|
|
|
contents: [],
|
|
|
collecation: []
|
|
|
contents: []
|
|
|
};
|
|
|
|
|
|
_.forEach(list, function(value) {
|
...
|
...
|
@@ -325,8 +288,12 @@ const _processContentData = (list) => { |
|
|
contentData.contents = list;
|
|
|
|
|
|
let idList = '';
|
|
|
let sknList = '';
|
|
|
let formatData = [];
|
|
|
let recoLength = '';
|
|
|
let related = {
|
|
|
relatedReco: [],
|
|
|
relatedGroup: []
|
|
|
}
|
|
|
|
|
|
|
|
|
_.forEach(contentData.contents, function(value) {
|
|
|
|
...
|
...
|
@@ -335,42 +302,56 @@ const _processContentData = (list) => { |
|
|
_.forEach(value.goods.data, function(data) {
|
|
|
|
|
|
idList += data.id + ',';
|
|
|
// idList = '51152761';
|
|
|
formatData.push(data);
|
|
|
related.relatedReco.push(data);
|
|
|
});
|
|
|
}
|
|
|
//console.log(idList)
|
|
|
|
|
|
recoLength = idList.length/9;
|
|
|
|
|
|
if (value.goodsGroup) {
|
|
|
|
|
|
// _.forEach(value.goodsGroup.data, function(data) {
|
|
|
// // console.log(data)
|
|
|
// // _.forEach(data.list, function(value) {
|
|
|
// // sknList += value.id + ',';
|
|
|
_.forEach(value.goodsGroup.data, function(data) {
|
|
|
|
|
|
// // formatData.push(value);
|
|
|
_.forEach(data.list, function(value) {
|
|
|
idList += value.id + ',';
|
|
|
|
|
|
// // });
|
|
|
// });
|
|
|
related.relatedGroup.push(value);
|
|
|
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
// console.log(idList)
|
|
|
|
|
|
_getRelatedData().then((result) => {
|
|
|
//console.log(result)
|
|
|
_getRelatedData(idList).then((result) => {
|
|
|
// console.log(result)
|
|
|
|
|
|
_.forEach(formatData, function(data, index) {
|
|
|
// console.log(formatData)
|
|
|
if (related.relatedReco) {
|
|
|
_.forEach(related.relatedReco, function(data, index) {
|
|
|
|
|
|
data[index] = _.assign(result[index]);
|
|
|
data= _.assign(data, result[index]);
|
|
|
//result.remove(index)
|
|
|
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
|
|
|
if (related.relatedGroup) {
|
|
|
_.forEach(related.relatedGroup, function(data, index) {
|
|
|
|
|
|
data= _.assign(data, result[index]);
|
|
|
|
|
|
// console.log(formatData)
|
|
|
return formatData;
|
|
|
});
|
|
|
}
|
|
|
// console.log(related)
|
|
|
|
|
|
return related;
|
|
|
|
|
|
}).then(() => {
|
|
|
contentData.contents.push({
|
|
|
related: related
|
|
|
});
|
|
|
console.log(contentData)
|
|
|
|
|
|
return contentData;
|
|
|
});
|
|
|
|
|
|
return contentData;
|
...
|
...
|
@@ -473,6 +454,19 @@ const _getRelateBrand = (id) => { |
|
|
});
|
|
|
};
|
|
|
|
|
|
const _getArticlePre = (id) => {
|
|
|
// return serviceAPI.get('guang/api/*/article/getArticlePre', {
|
|
|
// id: id
|
|
|
// }).then((result) => {
|
|
|
// if (result && result.code === 200) {
|
|
|
// console.log(result)
|
|
|
// return result;
|
|
|
// } else {
|
|
|
// logger.error('上一篇不是200');
|
|
|
// return {};
|
|
|
// }
|
|
|
// });
|
|
|
};
|
|
|
/**
|
|
|
* 资讯收藏
|
|
|
* @param uid
|
...
|
...
|
@@ -567,7 +561,6 @@ const addComment = (id, uid, comment) => { |
|
|
const shareData = () => {
|
|
|
return serviceAPI.get('/guang/api/*/share/guang', {}).then((result) => {
|
|
|
if (result && result.code === 200) {
|
|
|
console.log(34346);
|
|
|
return camelCase(result.data);
|
|
|
} else {
|
|
|
logger.error('Related brand return code is not 200');
|
...
|
...
|
@@ -587,6 +580,7 @@ const getDetailData = (id) => { |
|
|
_getArticleData(id),
|
|
|
_getContentData(id),
|
|
|
_getCommentsData(id),
|
|
|
_getArticlePre(id),
|
|
|
_getRelateBrand(id)]);
|
|
|
let res = yield _processHeadData([result[0], result[1], result[3]]);
|
|
|
|
...
|
...
|
|