Authored by zhangxiaoru

merge from feature/wantSearch

@@ -132,13 +132,14 @@ const list = (req, res, next) => { @@ -132,13 +132,14 @@ const list = (req, res, next) => {
132 * 搜索主页 132 * 搜索主页
133 */ 133 */
134 const index = (req, res, next) => { 134 const index = (req, res, next) => {
135 - let title = '搜索'; 135 + let title = '搜索',
  136 + uid = req.user.uid || 0;
136 137
137 ((render) => { 138 ((render) => {
138 if (_.get(req, 'app.locals.wap.search.removeHotSearch', false)) { 139 if (_.get(req, 'app.locals.wap.search.removeHotSearch', false)) {
139 render([]); 140 render([]);
140 } else { 141 } else {
141 - searchModel.getSearchIndex().then((result) => { 142 + searchModel.getSearchIndex(uid).then((result) => {
142 render(result); 143 render(result);
143 }).catch(next); 144 }).catch(next);
144 } 145 }
@@ -152,16 +153,14 @@ const index = (req, res, next) => { @@ -152,16 +153,14 @@ const index = (req, res, next) => {
152 }), 153 }),
153 pageFooter: true, 154 pageFooter: true,
154 search: { 155 search: {
155 - defaultTerms: (result && result.defaultTerms &&  
156 -  
157 -result.defaultTerms.length !== 0) ? result.defaultTerms[0].content : '', 156 + defaultTerms: (result && result.hotTerms && result.hotTerms.defaultTerms && result.hotTerms.defaultTerms.length !== 0) ? result.hotTerms.defaultTerms[0].content : '',
158 url: helpers.urlFormat('', null, 'search'), 157 url: helpers.urlFormat('', null, 'search'),
159 - hotTerms: result.hotTerms 158 + hotTerms: result.hotTerms.hotTerms,
  159 + wantTerms: result.wantTerms.guessTerms
160 } 160 }
161 161
162 }); 162 });
163 }); 163 });
164 -  
165 }; 164 };
166 165
167 /** 166 /**
@@ -262,32 +262,34 @@ const getAllBrandNames = () => { @@ -262,32 +262,34 @@ const getAllBrandNames = () => {
262 * 获取猜你想找 262 * 获取猜你想找
263 **/ 263 **/
264 const getWantSearch = (uid) => { 264 const getWantSearch = (uid) => {
265 - return [];  
266 - // return api.get('', {  
267 - // method: 'app.search.getSomeTerms',  
268 - // uid: uid  
269 - // }, {  
270 - // cache: true  
271 - // }).then((result) => {  
272 - // if (result && result.code === 200) {  
273 - // return result.data;  
274 - // } else {  
275 - // logger.error('Hot Search return code is not 200');  
276 - // return {};  
277 - // }  
278 - // }); 265 + return api.get('', {
  266 + method: 'app.search.getSomeTerms',
  267 + uid: uid
  268 + }, {
  269 + cache: true
  270 + }).then((result) => {
  271 + if (result && result.code === 200) {
  272 + return result.data;
  273 + } else {
  274 + logger.error('Hot Search return code is not 200');
  275 + return {};
  276 + }
  277 + });
279 }; 278 };
280 279
281 /** 280 /**
282 * 获取热门搜索 281 * 获取热门搜索
283 **/ 282 **/
284 -const getSearchIndex = () => { 283 +const getHotSearch = () => {
285 return api.get('', { 284 return api.get('', {
286 method: 'app.search.getTerms' 285 method: 'app.search.getTerms'
287 }, { 286 }, {
288 cache: true 287 cache: true
289 }).then((result) => { 288 }).then((result) => {
290 if (result && result.code === 200) { 289 if (result && result.code === 200) {
  290 + if (result.data.hotTerms && result.data.hotTerms.length > 10) {
  291 + result.data.hotTerms = result.data.hotTerms.slice(0, 10);
  292 + }
291 return result.data; 293 return result.data;
292 } else { 294 } else {
293 logger.error('Hot Search return code is not 200'); 295 logger.error('Hot Search return code is not 200');
@@ -299,14 +301,14 @@ const getSearchIndex = () => { @@ -299,14 +301,14 @@ const getSearchIndex = () => {
299 /** 301 /**
300 * 搜索主页 302 * 搜索主页
301 */ 303 */
302 -// const getSearchIndex = (uid) => {  
303 -// return Promise.all([getHotSearch(), getWantSearch(uid)]).then((result) => {  
304 -// return {  
305 -// hotTerms: result[0],  
306 -// wantTerms: result[1]  
307 -// };  
308 -// });  
309 -// }; 304 +const getSearchIndex = (uid) => {
  305 + return Promise.all([getHotSearch(), getWantSearch(uid)]).then((result) => {
  306 + return {
  307 + hotTerms: result[0],
  308 + wantTerms: result[1]
  309 + };
  310 + });
  311 +};
310 312
311 /** 313 /**
312 * 获取联想词 314 * 获取联想词
@@ -537,7 +537,11 @@ $yohoPage.on('touchstart', '.btn-minus', function() { @@ -537,7 +537,11 @@ $yohoPage.on('touchstart', '.btn-minus', function() {
537 return; 537 return;
538 } 538 }
539 539
540 - if (num <= discountNum) { 540 + if (discountNum && num <= discountNum + 1) {
  541 + $('.btn-minus').addClass('discount-gray');
  542 + }
  543 +
  544 + if (discountNum && num <= discountNum) {
541 tip.show('量贩商品,' + discountNum + '件起购'); 545 tip.show('量贩商品,' + discountNum + '件起购');
542 return; 546 return;
543 } 547 }
@@ -563,6 +567,10 @@ $yohoPage.on('touchstart', '.btn-minus', function() { @@ -563,6 +567,10 @@ $yohoPage.on('touchstart', '.btn-minus', function() {
563 return; 567 return;
564 } 568 }
565 569
  570 + if (discountNum && num >= discountNum) {
  571 + $('.btn-minus').removeClass('discount-gray');
  572 + }
  573 +
566 if (num - 0 === leftNum || leftNum === 0) { 574 if (num - 0 === leftNum || leftNum === 0) {
567 return; 575 return;
568 } 576 }
@@ -131,41 +131,41 @@ function inputAction() { @@ -131,41 +131,41 @@ function inputAction() {
131 131
132 C_ID = window._ChannelVary[window.cookie('_Channel')]; 132 C_ID = window._ChannelVary[window.cookie('_Channel')];
133 133
134 -// function yasRequest(PRD_ID, PRD_NUM, ACTION_ID) {  
135 -  
136 -// if (window._yas && window._yas.sendCustomInfo) {  
137 -  
138 -// window._yas.sendCustomInfo({  
139 -// op: 'YB_CHOOSE_FOR_YOU_Y',  
140 -// param: JSON.stringify({  
141 -// REC_POSE: 100016,  
142 -// REC_ID: RECID,  
143 -// PRD_ID: PRD_ID,  
144 -// PRD_NUM: PRD_NUM,  
145 -// C_ID: C_ID,  
146 -// ACTION_ID: ACTION_ID  
147 -// })  
148 -// }, true);  
149 -// }  
150 -// } 134 +function yasRequest(PRD_ID, PRD_NUM, ACTION_ID) {
  135 +
  136 + if (window._yas && window._yas.sendCustomInfo) {
  137 +
  138 + window._yas.sendCustomInfo({
  139 + op: 'YB_CHOOSE_FOR_YOU_Y',
  140 + param: JSON.stringify({
  141 + REC_POSE: 100016,
  142 + REC_ID: RECID,
  143 + PRD_ID: PRD_ID,
  144 + PRD_NUM: PRD_NUM,
  145 + C_ID: C_ID,
  146 + ACTION_ID: ACTION_ID
  147 + })
  148 + }, true);
  149 + }
  150 +}
151 151
152 // 猜你想找展示时埋点 152 // 猜你想找展示时埋点
153 -// $('.want-search').find('li').each(function() { 153 +$('.want-search').find('li').each(function() {
154 154
155 -// querys = $(this).find('a').html(); 155 + querys = $(this).find('a').html();
156 156
157 -// if (querys) {  
158 -// prdids.push(querys);  
159 -// }  
160 -// }); 157 + if (querys) {
  158 + prdids.push(querys);
  159 + }
  160 +});
161 161
162 -// prdLoad = JSON.stringify(prdids).replace(/\[|\]|\"|/g, ''); 162 +prdLoad = JSON.stringify(prdids).replace(/\[|\]|\"|/g, '');
163 163
164 -// if (prdLoad) {  
165 -// setTimeout(function() {  
166 -// yasRequest(encodeURIComponent(prdLoad), prdids.length, 0);  
167 -// }, 200);  
168 -// } 164 +if (prdLoad) {
  165 + setTimeout(function() {
  166 + yasRequest(encodeURIComponent(prdLoad), prdids.length, 0);
  167 + }, 200);
  168 +}
169 169
170 // 热门搜索、最近搜索事件 170 // 热门搜索、最近搜索事件
171 $('.search-items .search-group').on('click', 'li', function(event) { 171 $('.search-items .search-group').on('click', 'li', function(event) {
@@ -185,15 +185,14 @@ $('.search-items .search-group').on('click', 'li', function(event) { @@ -185,15 +185,14 @@ $('.search-items .search-group').on('click', 'li', function(event) {
185 } else if ($(this).parents('.search-group').hasClass('hot-search-new')) { 185 } else if ($(this).parents('.search-group').hasClass('hot-search-new')) {
186 POS_ID = 2; 186 POS_ID = 2;
187 FLR_INDEX = 2; 187 FLR_INDEX = 2;
188 - }  
189 - // else {  
190 - // var PRD_NUM = $(this).index() + 1; 188 + } else {
  189 + var PRD_NUM = $(this).index() + 1;
191 190
192 - // POS_ID = 3;  
193 - // FLR_INDEX = 3; 191 + POS_ID = 3;
  192 + FLR_INDEX = 3;
194 193
195 - // yasRequest(query, PRD_NUM, 1);  
196 - // } 194 + yasRequest(query, PRD_NUM, 1);
  195 + }
197 196
198 if (window._yas && window._yas.sendCustomInfo) { 197 if (window._yas && window._yas.sendCustomInfo) {
199 window._yas.sendCustomInfo({ 198 window._yas.sendCustomInfo({
@@ -247,11 +246,11 @@ $search.on('touchend', function() { @@ -247,11 +246,11 @@ $search.on('touchend', function() {
247 return false; 246 return false;
248 }); 247 });
249 248
250 -// navSwiper = new Swiper('.new-hot', {  
251 -// grabCursor: true,  
252 -// slidesPerView: 'auto',  
253 -// slideElement: 'li'  
254 -// }); 249 +navSwiper = new Swiper('.new-hot', {
  250 + grabCursor: true,
  251 + slidesPerView: 'auto',
  252 + slideElement: 'li'
  253 +});
255 254
256 // 初始化历史搜索的内容 255 // 初始化历史搜索的内容
257 (function() { 256 (function() {
1 -body {  
2 - background-color: #f0f0f0;  
3 -} 1 +//body {
  2 +// background-color: #f0f0f0;
  3 +//}
4 4
5 .bundle-detail-goods { 5 .bundle-detail-goods {
6 width: 100%; 6 width: 100%;
@@ -8,4 +8,4 @@ @@ -8,4 +8,4 @@
8 @import "../../common/good"; 8 @import "../../common/good";
9 @import "../../cart/chose-panel"; 9 @import "../../cart/chose-panel";
10 @import "../../common/_suspend-home.css"; 10 @import "../../common/_suspend-home.css";
11 - 11 +@import "bundle";
@@ -47,11 +47,6 @@ @@ -47,11 +47,6 @@
47 } 47 }
48 48
49 .search-items { 49 .search-items {
50 -<<<<<<< HEAD  
51 - padding: 40px 20px;  
52 -  
53 -=======  
54 ->>>>>>> feature/wantSearch  
55 h3 { 50 h3 {
56 font-size: 24px; 51 font-size: 24px;
57 margin-bottom: 20px; 52 margin-bottom: 20px;
@@ -66,7 +61,7 @@ @@ -66,7 +61,7 @@
66 } 61 }
67 62
68 a { 63 a {
69 - display: block; 64 + display: inline-block;
70 height: 68px; 65 height: 68px;
71 line-height: 68px; 66 line-height: 68px;
72 padding: 0 20px; 67 padding: 0 20px;
@@ -78,11 +73,9 @@ @@ -78,11 +73,9 @@
78 white-space: nowrap; 73 white-space: nowrap;
79 } 74 }
80 75
81 -<<<<<<< HEAD  
82 -=======  
83 .search-index { 76 .search-index {
84 - padding-top: 30px;  
85 border-top: 1px solid #e0e0e0; 77 border-top: 1px solid #e0e0e0;
  78 + background: #fff;
86 } 79 }
87 80
88 .hot-search-new { 81 .hot-search-new {
@@ -114,7 +107,6 @@ @@ -114,7 +107,6 @@
114 } 107 }
115 } 108 }
116 109
117 ->>>>>>> feature/wantSearch  
118 .clear-icon { 110 .clear-icon {
119 float: right; 111 float: right;
120 background: #fff; 112 background: #fff;
@@ -125,7 +117,7 @@ @@ -125,7 +117,7 @@
125 } 117 }
126 118
127 .search-group { 119 .search-group {
128 - border-bottom: 1px solid #e6e6e6; 120 + background: #fff;
129 121
130 .ico-hot { 122 .ico-hot {
131 width: 22px; 123 width: 22px;
@@ -174,7 +166,6 @@ @@ -174,7 +166,6 @@
174 166
175 .search-content { 167 .search-content {
176 clear: both; 168 clear: both;
177 - padding-left: 47px;  
178 box-sizing: border-box; 169 box-sizing: border-box;
179 padding-bottom: 18px; 170 padding-bottom: 18px;
180 171
@@ -183,13 +174,27 @@ @@ -183,13 +174,27 @@
183 border: 2px solid #e0e0e0; 174 border: 2px solid #e0e0e0;
184 background: #fff; 175 background: #fff;
185 font-size: 28px; 176 font-size: 28px;
  177 + width: auto;
186 } 178 }
187 } 179 }
188 180
189 - .hot-search {  
190 - margin-top: 38px; 181 + .history-search {
  182 + padding: 30px;
  183 + }
  184 +
  185 + .want-search {
  186 + padding: 30px;
  187 + }
  188 +
  189 + .want {
  190 + max-height: 264px;
  191 + overflow: hidden;
191 } 192 }
192 } 193 }
  194 +
  195 + .swiper-slide {
  196 + width: auto;
  197 + }
193 } 198 }
194 199
195 .search-associate { 200 .search-associate {
@@ -341,4 +346,4 @@ @@ -341,4 +346,4 @@
341 font-size: 24px; 346 font-size: 24px;
342 } 347 }
343 } 348 }
344 -}  
  349 +}