Merge remote-tracking branch 'origin/release/5.5' into release/5.5
Showing
1 changed file
with
58 additions
and
45 deletions
@@ -24,52 +24,8 @@ exports.getKeyActivity = (query) => { | @@ -24,52 +24,8 @@ exports.getKeyActivity = (query) => { | ||
24 | }); | 24 | }); |
25 | }; | 25 | }; |
26 | 26 | ||
27 | -/** | ||
28 | - * 转换价格 | ||
29 | - * | ||
30 | - * @param float|string $price 价格 | ||
31 | - * @return float|string 转换之后的价格 | ||
32 | - */ | ||
33 | -const transPrice = (price) => { | ||
34 | - return price ? (price * 1).toFixed(2) : '0.00'; | ||
35 | -}; | ||
36 | - | ||
37 | -/** | ||
38 | - * 获取搜索数据 | ||
39 | - * @param {[type]} origin [description] | ||
40 | - * @return {[type]} [description] | ||
41 | - */ | ||
42 | -exports.getSearchData = (params, channel) => { | ||
43 | - | ||
44 | - let searchParams = searchHandler.getSearchParams(params); | 27 | +const setSearchData = (result, params, channel) => { |
45 | let changeQuery = Object.assign({}, params); | 28 | let changeQuery = Object.assign({}, params); |
46 | - | ||
47 | - switch (channel) { | ||
48 | - case 'boys': | ||
49 | - searchParams.physical_channel = 1; | ||
50 | - break; | ||
51 | - case 'girls': | ||
52 | - searchParams.physical_channel = 2; | ||
53 | - break; | ||
54 | - case 'kids': | ||
55 | - searchParams.physical_channel = 3; | ||
56 | - break; | ||
57 | - case 'lifestyle': | ||
58 | - searchParams.physical_channel = 4; | ||
59 | - break; | ||
60 | - default: | ||
61 | - break; | ||
62 | - } | ||
63 | - | ||
64 | - // 调用接口 | ||
65 | - let apiMethod = [ | ||
66 | - headerModel.requestHeaderData(channel), | ||
67 | - searchApi.getSortList(Object.assign({}, searchParams, {msort: '', misort: '', sort: ''})), | ||
68 | - searchApi.getProductList(searchParams), | ||
69 | - searchApi.getShopList(params) | ||
70 | - ]; | ||
71 | - | ||
72 | - return api.all(apiMethod).then(result => { | ||
73 | let finalResult = { | 29 | let finalResult = { |
74 | headerData: Object.assign(result[0].headerData, { | 30 | headerData: Object.assign(result[0].headerData, { |
75 | header: true | 31 | header: true |
@@ -138,6 +94,63 @@ exports.getSearchData = (params, channel) => { | @@ -138,6 +94,63 @@ exports.getSearchData = (params, channel) => { | ||
138 | finalResult.criteo = {skn: searchHandler.getCriteo(_.get(finalResult.search, 'goods'))}; | 94 | finalResult.criteo = {skn: searchHandler.getCriteo(_.get(finalResult.search, 'goods'))}; |
139 | } | 95 | } |
140 | return finalResult; | 96 | return finalResult; |
97 | +} | ||
98 | + | ||
99 | +/** | ||
100 | + * 转换价格 | ||
101 | + * | ||
102 | + * @param float|string $price 价格 | ||
103 | + * @return float|string 转换之后的价格 | ||
104 | + */ | ||
105 | +const transPrice = (price) => { | ||
106 | + return price ? (price * 1).toFixed(2) : '0.00'; | ||
107 | +}; | ||
108 | + | ||
109 | +/** | ||
110 | + * 获取搜索数据 | ||
111 | + * @param {[type]} origin [description] | ||
112 | + * @return {[type]} [description] | ||
113 | + */ | ||
114 | +exports.getSearchData = (params, channel) => { | ||
115 | + let searchParams = searchHandler.getSearchParams(params); | ||
116 | + | ||
117 | + switch (channel) { | ||
118 | + case 'boys': | ||
119 | + searchParams.physical_channel = 1; | ||
120 | + break; | ||
121 | + case 'girls': | ||
122 | + searchParams.physical_channel = 2; | ||
123 | + break; | ||
124 | + case 'kids': | ||
125 | + searchParams.physical_channel = 3; | ||
126 | + break; | ||
127 | + case 'lifestyle': | ||
128 | + searchParams.physical_channel = 4; | ||
129 | + break; | ||
130 | + default: | ||
131 | + break; | ||
132 | + } | ||
133 | + | ||
134 | + // 调用接口 | ||
135 | + let apiMethod = [ | ||
136 | + headerModel.requestHeaderData(channel), | ||
137 | + searchApi.getSortList(Object.assign({}, searchParams, {msort: '', misort: '', sort: ''})), | ||
138 | + searchApi.getProductList(searchParams), | ||
139 | + searchApi.getShopList(params) | ||
140 | + ]; | ||
141 | + | ||
142 | + return api.all(apiMethod).then(result => { | ||
143 | + if (_.get(result, '[2].data.isChangedQuery', '') === 'Y') { | ||
144 | + return searchApi.getSortList(Object.assign({}, searchParams, {msort: '', | ||
145 | + query: _.get(result, '[2]data.suggestion.terms_suggestion[0]', ''), | ||
146 | + misort: '', sort: ''})).then(subRes => { | ||
147 | + result[1] = subRes; | ||
148 | + | ||
149 | + return setSearchData(result, params, channel); | ||
150 | + }); | ||
151 | + } | ||
152 | + | ||
153 | + return setSearchData(result, params, channel); | ||
141 | }); | 154 | }); |
142 | }; | 155 | }; |
143 | 156 |
-
Please register or login to post a comment