|
@@ -94,7 +94,7 @@ module.exports = class extends global.yoho.BaseModel { |
|
@@ -94,7 +94,7 @@ module.exports = class extends global.yoho.BaseModel { |
94
|
this.searchApi = new SearchApi(ctx);
|
94
|
this.searchApi = new SearchApi(ctx);
|
95
|
}
|
95
|
}
|
96
|
|
96
|
|
97
|
- getSearchProduct(params, channel) {
|
97
|
+ getSearchProduct(params, channel, sort) {
|
98
|
let searchParams = searchHandler.getSearchParams(params);
|
98
|
let searchParams = searchHandler.getSearchParams(params);
|
99
|
|
99
|
|
100
|
switch (channel) {
|
100
|
switch (channel) {
|
|
@@ -121,16 +121,30 @@ module.exports = class extends global.yoho.BaseModel { |
|
@@ -121,16 +121,30 @@ module.exports = class extends global.yoho.BaseModel { |
121
|
return Promise.all([
|
121
|
return Promise.all([
|
122
|
headerModelCtx.requestHeaderData(channel, true),
|
122
|
headerModelCtx.requestHeaderData(channel, true),
|
123
|
this.searchApi.getSeoProductList(searchParams, 'fuzzySearch'),
|
123
|
this.searchApi.getSeoProductList(searchParams, 'fuzzySearch'),
|
124
|
- this.searchApi.getSeoProductList(Object.assign(searchParams, {
|
124
|
+ this.searchApi.getSeoProductList(Object.assign({}, searchParams, {
|
125
|
order: 's_n_desc',
|
125
|
order: 's_n_desc',
|
126
|
limit: 5
|
126
|
limit: 5
|
127
|
}), 'fuzzySearch'),
|
127
|
}), 'fuzzySearch'),
|
128
|
]).then(result => {
|
128
|
]).then(result => {
|
|
|
129
|
+ if (!sort || _.get(result[1], 'data.total') > 0) {
|
|
|
130
|
+ return result;
|
|
|
131
|
+ }
|
|
|
132
|
+
|
|
|
133
|
+ delete searchParams.query;
|
|
|
134
|
+ searchParams.sort = sort;
|
|
|
135
|
+
|
|
|
136
|
+ return this.searchApi.getSeoProductList(searchParams,
|
|
|
137
|
+ 'fuzzySearch').then(subRes => {
|
|
|
138
|
+ result[1] = subRes;
|
|
|
139
|
+
|
|
|
140
|
+ return result;
|
|
|
141
|
+ });
|
|
|
142
|
+ }).then(result => {
|
129
|
return _setHotKeywordData(result, params, channel);
|
143
|
return _setHotKeywordData(result, params, channel);
|
130
|
});
|
144
|
});
|
131
|
}
|
145
|
}
|
132
|
|
146
|
|
133
|
- getHotKeywordDate(id, params, channel) {
|
147
|
+ getHotKeywordData(id, params, channel) {
|
134
|
return redis.all([
|
148
|
return redis.all([
|
135
|
['get', `global:yoho:seo:hot:keywords:id:${id}`]
|
149
|
['get', `global:yoho:seo:hot:keywords:id:${id}`]
|
136
|
]).then(redisData => {
|
150
|
]).then(redisData => {
|
|
@@ -149,7 +163,7 @@ module.exports = class extends global.yoho.BaseModel { |
|
@@ -149,7 +163,7 @@ module.exports = class extends global.yoho.BaseModel { |
149
|
|
163
|
|
150
|
params.query = keyword.name;
|
164
|
params.query = keyword.name;
|
151
|
|
165
|
|
152
|
- return this.getSearchProduct(params, channel).then(result => {
|
166
|
+ return this.getSearchProduct(params, channel, keyword.sort_id).then(result => {
|
153
|
const keyNum = 10;
|
167
|
const keyNum = 10;
|
154
|
let hotKeys = (keyword.data || []).map(val => {
|
168
|
let hotKeys = (keyword.data || []).map(val => {
|
155
|
val.href = helpers.urlFormat(`/hot/${val.id}.html`);
|
169
|
val.href = helpers.urlFormat(`/hot/${val.id}.html`);
|