Authored by biao

fix channel bug

... ... @@ -383,15 +383,18 @@ const _getSingehotViaResult = (args, originQuery, queryResult, type) => {
const getIndex = skn => {
const originQueryArr = originQuery.split(' ');
let index;
_.forEach(originQueryArr, (query, idx) => {
if (query.toString() === skn.toString()) {
index = idx;
}
});
if (originQuery) {
const originQueryArr = originQuery.split(' ');
_.forEach(originQueryArr, (query, idx) => {
if (query.toString() === skn.toString()) {
index = idx;
}
});
}
return index;
};
... ... @@ -407,20 +410,20 @@ const _getSingehotViaResult = (args, originQuery, queryResult, type) => {
height: 373
});
if (pos > 12) {
if (pos > 11) {
return;
}
if (it.product_id) {
formatData.idx = getIndex(it.product_skn);
data.singlehot.imgHot.push(formatData);
pos +=1 ;
pos += 1;
}
});
}
data.singlehot.imgHot = _.sortBy(data.singlehot.imgHot, item => {
return item.idx;
});
... ... @@ -449,12 +452,14 @@ const _getSingehotViaResult = (args, originQuery, queryResult, type) => {
*/
const _processFloorDataWithQueryReusult = (rawData, originQuery, queryResult, title, type) => {
let data = {};
let idx = 0;
_.forEach(rawData, (subData, index) => {
const text = subData.data.text && _getText(subData.data.text);
if (text === title) {
data = _getSingehotViaResult(rawData.slice(index, index + 4), originQuery, queryResult, type);
data = _getSingehotViaResult(rawData.slice(index, index + 4), originQuery[idx], queryResult, type);
idx += 1;
}
});
... ... @@ -565,7 +570,7 @@ const needQuery = {
'BOY KIDS': true,
人气单品: true,
ACCESSORIES: true
}
};
const getQuery = args => {
let goods = args[2] && args[2].data;
... ... @@ -578,7 +583,7 @@ const getQuery = args => {
}
return skns;
}
};
const _processFloorData = (rawData, type) => {
... ... @@ -587,6 +592,7 @@ const _processFloorData = (rawData, type) => {
let singlehotFloorIndex = [];
let singlehotFloorTitle = [];
let queryParam = '';
let params = [];
// 定义各种楼层需要用到的接口返回的数组中元素的个数
const bigFloorLength = 5;
... ... @@ -613,6 +619,7 @@ const _processFloorData = (rawData, type) => {
if (needQuery[text]) {
queryParam = getQuery(rawData.slice(index, lastIndex));
params.push(queryParam);
}
} else if (data.template_name === 'debrisSlider') { // 处理girls的banner
... ... @@ -653,7 +660,7 @@ const _processFloorData = (rawData, type) => {
return {
floors: floorList,
promise: _.reverse(searchPromise),
queryParam: queryParam,
queryParams: params,
singlehotFloorTitle: _.reverse(singlehotFloorTitle),
singlehotFloorIndex: _.reverse(singlehotFloorIndex)
};
... ... @@ -861,7 +868,7 @@ const getContent = type => {
searchPromise: processResult.promise,
singlehotFloorIndex: processResult.singlehotFloorIndex,
singlehotFloorTitle: processResult.singlehotFloorTitle,
queryParam: processResult.queryParam,
queryParams: processResult.queryParams,
channelType: type
};
... ... @@ -875,7 +882,7 @@ const getContent = type => {
.splice(result.singlehotFloorIndex[index], 0,
_processFloorDataWithQueryReusult(
result.rawData,
result.queryParam,
result.queryParams,
data,
result.singlehotFloorTitle[index],
result.channelType
... ...