Commit d354faedc95abc8a7de97e3017446bda5e3bb1c9

Authored by 王强
1 parent fd9a88a0

优选库,搜索页面“更多”选项个数不一致问题,是上拉加载导致的page参数问题,已修复~

Showing 1 changed file with 46 additions and 52 deletions
src/pages/search/search.vue
@@ -161,31 +161,40 @@ @@ -161,31 +161,40 @@
161 */ 161 */
162 more(status = "") { 162 more(status = "") {
163 163
  164 + // 获取keyword/初始化页码
  165 + let keyword = window.sessionStorage.getItem("keyword") || this.$refs.searchCom.getKeyword();
  166 +
  167 + // 设置请求参数
  168 + let params = {
  169 + keyword: keyword
  170 + };
  171 +
164 // 设置展示的页面状态编码 172 // 设置展示的页面状态编码
165 if (status) { 173 if (status) {
166 this.$set(this.displayPage, "value", status); 174 this.$set(this.displayPage, "value", status);
  175 + this.$set(this.paging, "page", 1);
  176 + this.$set(params, 'page', 1);
  177 + } else {
  178 + this.$set(this.paging, "page", ++this.paging.page);
  179 + this.$set(params, 'page', this.paging.page);
167 } 180 }
168 181
169 - // 获取keyword/初始化页码  
170 - let keyword = window.sessionStorage.getItem("keyword") || this.$refs.searchCom.getKeyword();  
171 - this.$set(this.paging, "page", ++this.paging.page);  
172 -  
173 // 根据displayPage的value,判断调用哪个单页面 182 // 根据displayPage的value,判断调用哪个单页面
174 switch (this.displayPage.value) { 183 switch (this.displayPage.value) {
175 case this.displayPage.status.GOODS: // 商品搜素 184 case this.displayPage.status.GOODS: // 商品搜素
176 185
177 // 商品搜素 186 // 商品搜素
178 - this.goodsSearch(keyword); 187 + this.goodsSearch(params);
179 break; 188 break;
180 case this.displayPage.status.DAREN: // 达人搜素 189 case this.displayPage.status.DAREN: // 达人搜素
181 190
182 // 达人搜素 191 // 达人搜素
183 - this.darenSearch(keyword); 192 + this.darenSearch(params);
184 break; 193 break;
185 case this.displayPage.status.FOOD: // 美食搜素 194 case this.displayPage.status.FOOD: // 美食搜素
186 195
187 // 美食搜素 196 // 美食搜素
188 - this.foodsSearch(keyword); 197 + this.foodsSearch(params);
189 break; 198 break;
190 } 199 }
191 }, 200 },
@@ -364,9 +373,9 @@ @@ -364,9 +373,9 @@
364 373
365 /** 374 /**
366 * 商品搜索 375 * 商品搜索
367 - * @param {String} keyword [搜索关键字] 376 + * @param {Object} params [请求参数]
368 */ 377 */
369 - goodsSearch(keyword) { 378 + goodsSearch(params) {
370 379
371 // 加载中 380 // 加载中
372 this.$set(this.paging, "loading", true); 381 this.$set(this.paging, "loading", true);
@@ -374,22 +383,21 @@ @@ -374,22 +383,21 @@
374 // 加载中提示 383 // 加载中提示
375 Indicator.open("搜索中..."); 384 Indicator.open("搜索中...");
376 385
  386 + // 添加请求参数
  387 + this.$set(params, 'uid', this.getStore("uid") || 0);
  388 +
377 // 获取证书请求接口 389 // 获取证书请求接口
378 - this.http("/Api/" + this.getApiVersion().index + "/goodsSearch", {  
379 - keyword: keyword,  
380 - uid: this.getStore("uid"),  
381 - page: this.paging.page  
382 - }, this.pagingSearchCallback, { 390 + this.http("/Api/" + this.getApiVersion().index + "/goodsSearch", params, this.pagingSearchCallback, {
383 method: "POST", 391 method: "POST",
384 - keyword 392 + params
385 }); 393 });
386 }, 394 },
387 395
388 /** 396 /**
389 * 达人搜索 397 * 达人搜索
390 - * @param {String} keyword [搜索关键字] 398 + * @param {Object} params [请求参数]
391 */ 399 */
392 - darenSearch(keyword) { 400 + darenSearch(params) {
393 401
394 // 加载中 402 // 加载中
395 this.$set(this.paging, "loading", true); 403 this.$set(this.paging, "loading", true);
@@ -397,22 +405,21 @@ @@ -397,22 +405,21 @@
397 // 加载中提示 405 // 加载中提示
398 Indicator.open("搜索中..."); 406 Indicator.open("搜索中...");
399 407
  408 + // 添加请求参数
  409 + this.$set(params, 'uid', this.getStore("uid") || 0);
  410 +
400 // 获取证书请求接口 411 // 获取证书请求接口
401 - this.http("/Api/" + this.getApiVersion().index + "/darenSearch", {  
402 - keyword: keyword,  
403 - uid: this.getStore("uid"),  
404 - page: this.paging.page  
405 - }, this.pagingSearchCallback, { 412 + this.http("/Api/" + this.getApiVersion().index + "/darenSearch", params, this.pagingSearchCallback, {
406 method: "POST", 413 method: "POST",
407 - keyword 414 + params
408 }); 415 });
409 }, 416 },
410 417
411 /** 418 /**
412 * 美食搜索 419 * 美食搜索
413 - * @param {String} keyword [搜索关键字] 420 + * @param {Object} params [请求参数]
414 */ 421 */
415 - foodsSearch(keyword) { 422 + foodsSearch(params) {
416 423
417 // 加载中 424 // 加载中
418 this.$set(this.paging, "loading", true); 425 this.$set(this.paging, "loading", true);
@@ -420,28 +427,15 @@ @@ -420,28 +427,15 @@
420 // 加载中提示 427 // 加载中提示
421 Indicator.open("搜索中..."); 428 Indicator.open("搜索中...");
422 429
423 -  
424 - // window.alert('keyword:' + keyword);  
425 - // window.alert('uid:' + this.getStore("uid"));  
426 - // window.alert('longitude:' + this.coordinate.longitude);  
427 - // window.alert('latitude:' + this.coordinate.latitude);  
428 - // window.alert('page:' + this.paging.page);  
429 -  
430 -  
431 -  
432 -  
433 - 430 + // 添加请求参数
  431 + this.$set(params, 'uid', this.getStore("uid") || 0);
  432 + this.$set(params, 'longitude', this.coordinate.longitude);
  433 + this.$set(params, 'latitude', this.coordinate.latitude);
  434 +
434 // 获取证书请求接口 435 // 获取证书请求接口
435 - this.http("/Api/" + this.getApiVersion().index + "/foodsSearch", {  
436 - keyword: keyword,  
437 - uid: this.getStore("uid"),  
438 - longitude: this.coordinate.longitude,  
439 - latitude: this.coordinate.latitude,  
440 - page: this.paging.page  
441 - }, this.pagingSearchCallback, { 436 + this.http("/Api/" + this.getApiVersion().index + "/foodsSearch", params, this.pagingSearchCallback, {
442 method: "POST", 437 method: "POST",
443 - keyword,  
444 - coordinate: this.coordinate 438 + params
445 }); 439 });
446 }, 440 },
447 441
@@ -476,10 +470,10 @@ @@ -476,10 +470,10 @@
476 if (datas.goods.length) { 470 if (datas.goods.length) {
477 471
478 // 替换标题中的keyword 472 // 替换标题中的keyword
479 - this.keywordHigh(datas.goods, ext.keyword); 473 + this.keywordHigh(datas.goods, ext.params.keyword);
480 474
481 // 判断数据处理方式 475 // 判断数据处理方式
482 - if (this.paging.page > 1) { // 追加数据 476 + if (ext.params.page > 1) { // 追加数据
483 this.$set(this.goodsLists, "list", [...this.goodsLists.list, ...datas.goods]); 477 this.$set(this.goodsLists, "list", [...this.goodsLists.list, ...datas.goods]);
484 } else { // 初始化数据 478 } else { // 初始化数据
485 this.$set(this.goodsLists, "list", datas.goods); 479 this.$set(this.goodsLists, "list", datas.goods);
@@ -499,10 +493,10 @@ @@ -499,10 +493,10 @@
499 if (datas.shop.length) { 493 if (datas.shop.length) {
500 494
501 // 替换标题中的keyword 495 // 替换标题中的keyword
502 - this.keywordHigh(datas.shop, ext.keyword); 496 + this.keywordHigh(datas.shop, ext.params.keyword);
503 497
504 // 判断数据处理方式 498 // 判断数据处理方式
505 - if (this.paging.page > 1) { 499 + if (ext.params.page > 1) {
506 this.$set(this.darenLists, "list", [...this.darenLists.list, ...datas.shop]); 500 this.$set(this.darenLists, "list", [...this.darenLists.list, ...datas.shop]);
507 } else { 501 } else {
508 this.$set(this.darenLists, "list", datas.shop); 502 this.$set(this.darenLists, "list", datas.shop);
@@ -522,14 +516,14 @@ @@ -522,14 +516,14 @@
522 if (datas.foodsShop.length) { 516 if (datas.foodsShop.length) {
523 517
524 // 替换标题中的keyword 518 // 替换标题中的keyword
525 - this.keywordHigh(datas.foodsShop, ext.keyword); 519 + this.keywordHigh(datas.foodsShop, ext.params.keyword);
526 520
527 // 判断数据处理方式 521 // 判断数据处理方式
528 - if (this.paging.page > 1) { 522 + if (ext.params.page > 1) {
529 this.$set(this.foodLists, "list", [...this.foodLists.list, ...datas.foodsShop]); 523 this.$set(this.foodLists, "list", [...this.foodLists.list, ...datas.foodsShop]);
530 } else { 524 } else {
531 this.$set(this.foodLists, "list", datas.foodsShop); 525 this.$set(this.foodLists, "list", datas.foodsShop);
532 - this.$set(this.foodLists, "coordinate", ext.coordinate); 526 + this.$set(this.foodLists, "coordinate", {'longitude': ext.params.longitude, 'latitude': ext.params.latitude});
533 } 527 }
534 528
535 // 设置还有需要加载的内容 529 // 设置还有需要加载的内容