...
|
...
|
@@ -323,8 +323,111 @@ const branchSearchHot = () => { |
|
|
});
|
|
|
};
|
|
|
|
|
|
// /**
|
|
|
// * 获取搜索的品牌列表
|
|
|
// *
|
|
|
// * @param int $channel 1表示男生频道, 2表示女生频道, 3表示潮童频道, 4表示创意生活频道
|
|
|
// * @return array
|
|
|
// */
|
|
|
// const branchSearch = (params) => {
|
|
|
// return api.all([
|
|
|
|
|
|
// getBrandForSearch(params.channel),
|
|
|
// branchSearchHistory(params),
|
|
|
// branchSearchHot(),
|
|
|
|
|
|
// ]).then(result => {
|
|
|
|
|
|
// let resu = {
|
|
|
// brandPage: true,
|
|
|
// showDownloadApp: true,
|
|
|
// pageFooter: true,
|
|
|
// hot: [],
|
|
|
// history: [],
|
|
|
// brandList: []
|
|
|
// };
|
|
|
|
|
|
// if (result && result[0] && result[0].data) {
|
|
|
|
|
|
// let brandList = result[0].data.brands;
|
|
|
|
|
|
// let obj = {};
|
|
|
|
|
|
// for (let key in brandList) {
|
|
|
|
|
|
// let build = [];
|
|
|
|
|
|
// brandList[key].forEach(row => {
|
|
|
|
|
|
// build.push({
|
|
|
// name: row.brand_name,
|
|
|
// isHot: row.is_hot === 'Y' ? true : false,
|
|
|
// isNew: row.is_show_new === 'Y' ? true : false,
|
|
|
// url: helpers.urlFormat('', null, row.brand_domain),
|
|
|
// brandId: row.id,
|
|
|
// brandDomain: row.brand_domain,
|
|
|
// searchName: row.brand_name_en + row.brand_name_cn
|
|
|
// });
|
|
|
|
|
|
// obj[key] = build;
|
|
|
|
|
|
// });
|
|
|
|
|
|
// }
|
|
|
|
|
|
// resu.brandList = JSON.stringify(obj);
|
|
|
// }
|
|
|
|
|
|
|
|
|
// if (result && result[2] && result[2].data) {
|
|
|
|
|
|
// let hotList = result[2].data;
|
|
|
|
|
|
// for (let key in hotList) {
|
|
|
|
|
|
// let obj = {};
|
|
|
|
|
|
// obj = Object.assign(obj, {name: hotList[key].brandName});
|
|
|
|
|
|
// resu.hot.push(obj);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (result && result[1] && result[1].data) {
|
|
|
|
|
|
// let hisList = result[1].data;
|
|
|
|
|
|
// let obj = [];
|
|
|
|
|
|
// let build = {
|
|
|
|
|
|
// list: []
|
|
|
|
|
|
// };
|
|
|
|
|
|
// for (let key in hisList) {
|
|
|
|
|
|
// obj.push({
|
|
|
// name: hisList[key].searchTerms,
|
|
|
// searchTime: hisList[key].searchTime
|
|
|
// });
|
|
|
|
|
|
// }
|
|
|
|
|
|
// build.list = obj;
|
|
|
|
|
|
// resu.history = build;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// return resu;
|
|
|
|
|
|
// });
|
|
|
// };
|
|
|
/**
|
|
|
* 获取搜索的品牌列表
|
|
|
* 获取搜索的品牌列表 pagecache重构
|
|
|
*
|
|
|
* @param int $channel 1表示男生频道, 2表示女生频道, 3表示潮童频道, 4表示创意生活频道
|
|
|
* @return array
|
...
|
...
|
@@ -333,7 +436,7 @@ const branchSearch = (params) => { |
|
|
return api.all([
|
|
|
|
|
|
getBrandForSearch(params.channel),
|
|
|
branchSearchHistory(params),
|
|
|
// branchSearchHistory(params),
|
|
|
branchSearchHot(),
|
|
|
|
|
|
]).then(result => {
|
...
|
...
|
@@ -379,9 +482,9 @@ const branchSearch = (params) => { |
|
|
}
|
|
|
|
|
|
|
|
|
if (result && result[2] && result[2].data) {
|
|
|
if (result && result[1] && result[1].data) {
|
|
|
|
|
|
let hotList = result[2].data;
|
|
|
let hotList = result[1].data;
|
|
|
|
|
|
for (let key in hotList) {
|
|
|
|
...
|
...
|
@@ -395,32 +498,32 @@ const branchSearch = (params) => { |
|
|
|
|
|
}
|
|
|
|
|
|
if (result && result[1] && result[1].data) {
|
|
|
// if (result && result[1] && result[1].data) {
|
|
|
|
|
|
let hisList = result[1].data;
|
|
|
// let hisList = result[1].data;
|
|
|
|
|
|
let obj = [];
|
|
|
// let obj = [];
|
|
|
|
|
|
let build = {
|
|
|
// let build = {
|
|
|
|
|
|
list: []
|
|
|
// list: []
|
|
|
|
|
|
};
|
|
|
// };
|
|
|
|
|
|
for (let key in hisList) {
|
|
|
// for (let key in hisList) {
|
|
|
|
|
|
obj.push({
|
|
|
name: hisList[key].searchTerms,
|
|
|
searchTime: hisList[key].searchTime
|
|
|
});
|
|
|
// obj.push({
|
|
|
// name: hisList[key].searchTerms,
|
|
|
// searchTime: hisList[key].searchTime
|
|
|
// });
|
|
|
|
|
|
}
|
|
|
// }
|
|
|
|
|
|
build.list = obj;
|
|
|
// build.list = obj;
|
|
|
|
|
|
resu.history = build;
|
|
|
// resu.history = build;
|
|
|
|
|
|
}
|
|
|
// }
|
|
|
|
|
|
return resu;
|
|
|
|
...
|
...
|
@@ -439,10 +542,40 @@ const delBrandSearchHistory = (param) => { |
|
|
|
|
|
});
|
|
|
};
|
|
|
/**
|
|
|
* [异步获取用户最近搜索词]
|
|
|
*/
|
|
|
const branchSearchHistoryAsync = (uid) => {
|
|
|
return branchSearchHistory({uid}).then((result) => {
|
|
|
let hisList = result.data;
|
|
|
|
|
|
let obj = [];
|
|
|
|
|
|
let build = {
|
|
|
|
|
|
list: []
|
|
|
|
|
|
};
|
|
|
|
|
|
for (let key in hisList) {
|
|
|
|
|
|
obj.push({
|
|
|
name: hisList[key].searchTerms,
|
|
|
searchTime: hisList[key].searchTime
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
build.list = obj;
|
|
|
|
|
|
return build;
|
|
|
});
|
|
|
}
|
|
|
|
|
|
module.exports = {
|
|
|
getBrandByChannel,
|
|
|
branchSearch,
|
|
|
delBrandSearchHistory,
|
|
|
addSearchHistory
|
|
|
addSearchHistory,
|
|
|
branchSearchHistoryAsync
|
|
|
}; |
...
|
...
|
|