Commit ef1a8d800616771b0743cf6762bf2ae4824d1382
1 parent
c1f14b7a
优选库,优选,折扣专区,对接标签聚合商品列表接口~
Showing
1 changed file
with
121 additions
and
8 deletions
src/pages/discountList/discountList.vue
| @@ -212,15 +212,37 @@ | @@ -212,15 +212,37 @@ | ||
| 212 | // 设置初始化页码 | 212 | // 设置初始化页码 |
| 213 | this.$set(this.tabs.list[this.tabs.active], 'page', 1); | 213 | this.$set(this.tabs.list[this.tabs.active], 'page', 1); |
| 214 | 214 | ||
| 215 | - // 获取店铺首页推荐商品列表 | ||
| 216 | - this.getShopRecommendGoods(this.CALL_STATUS.INIT); | 215 | + // 判断type,调用不同接口 |
| 216 | + switch (this.tabs.list[this.tabs.active].type) { | ||
| 217 | + case '1': | ||
| 218 | + | ||
| 219 | + // 获取店铺首页推荐商品列表 | ||
| 220 | + this.getShopRecommendGoods(this.CALL_STATUS.INIT); | ||
| 221 | + break; | ||
| 222 | + case '2': | ||
| 223 | + | ||
| 224 | + // 获取标签聚合商品列表 | ||
| 225 | + this.activityIconGoods(this.CALL_STATUS.INIT); | ||
| 226 | + break; | ||
| 227 | + } | ||
| 217 | } else { | 228 | } else { |
| 218 | 229 | ||
| 219 | // 判断页面是数字再执行 | 230 | // 判断页面是数字再执行 |
| 220 | if (!isNaN(parseInt(this.tabs.list[this.tabs.active].page))) { | 231 | if (!isNaN(parseInt(this.tabs.list[this.tabs.active].page))) { |
| 221 | 232 | ||
| 222 | - // 获取店铺首页推荐商品列表 | ||
| 223 | - this.getShopRecommendGoods(this.CALL_STATUS.LOAD_MORE); | 233 | + // 判断type,调用不同接口 |
| 234 | + switch (this.tabs.list[this.tabs.active].type) { | ||
| 235 | + case '1': | ||
| 236 | + | ||
| 237 | + // 获取店铺首页推荐商品列表 | ||
| 238 | + this.getShopRecommendGoods(this.CALL_STATUS.LOAD_MORE); | ||
| 239 | + break; | ||
| 240 | + case '2': | ||
| 241 | + | ||
| 242 | + // 获取标签聚合商品列表 | ||
| 243 | + this.activityIconGoods(this.CALL_STATUS.LOAD_MORE); | ||
| 244 | + break; | ||
| 245 | + } | ||
| 224 | } | 246 | } |
| 225 | } | 247 | } |
| 226 | } | 248 | } |
| @@ -284,8 +306,12 @@ | @@ -284,8 +306,12 @@ | ||
| 284 | // 根据参数判断请求哪个接口,获取哪个列表 | 306 | // 根据参数判断请求哪个接口,获取哪个列表 |
| 285 | if (this.tabs.list[this.tabs.active].type == '1' && (!this.tabs.list[this.tabs.active].page || this.tabs.list[this.tabs.active].page == 1)) { | 307 | if (this.tabs.list[this.tabs.active].type == '1' && (!this.tabs.list[this.tabs.active].page || this.tabs.list[this.tabs.active].page == 1)) { |
| 286 | 308 | ||
| 287 | - // 获取店铺首页推荐商品列表 | ||
| 288 | - this.getShopRecommendGoods(this.CALL_STATUS.INIT); | 309 | + // 获取店铺首页推荐商品列表 |
| 310 | + this.getShopRecommendGoods(this.CALL_STATUS.INIT); | ||
| 311 | + } else if (this.tabs.list[this.tabs.active].type == '2' && (!this.tabs.list[this.tabs.active].page || this.tabs.list[this.tabs.active].page == 1)) { | ||
| 312 | + | ||
| 313 | + // 获取标签聚合商品列表 | ||
| 314 | + this.activityIconGoods(this.CALL_STATUS.INIT); | ||
| 289 | } else if (this.tabs.list[this.tabs.active].type == '0') { | 315 | } else if (this.tabs.list[this.tabs.active].type == '0') { |
| 290 | 316 | ||
| 291 | // 折扣专区列表 | 317 | // 折扣专区列表 |
| @@ -431,8 +457,8 @@ | @@ -431,8 +457,8 @@ | ||
| 431 | 457 | ||
| 432 | /** | 458 | /** |
| 433 | * 获取店铺首页推荐商品列表回调 | 459 | * 获取店铺首页推荐商品列表回调 |
| 434 | - * param {res} [服务器返回数据] | ||
| 435 | - * param {ext} [扩展参数] | 460 | + * param {Object} res [服务器返回数据] |
| 461 | + * param {Object} ext [扩展参数] | ||
| 436 | */ | 462 | */ |
| 437 | getShopRecommendGoodsCallback(res, ext) { | 463 | getShopRecommendGoodsCallback(res, ext) { |
| 438 | 464 | ||
| @@ -491,6 +517,93 @@ | @@ -491,6 +517,93 @@ | ||
| 491 | }, | 517 | }, |
| 492 | 518 | ||
| 493 | /** | 519 | /** |
| 520 | + * 获取标签聚合商品列表 | ||
| 521 | + * @param {object} CALL_STATUS [何处触发请求] | ||
| 522 | + */ | ||
| 523 | + activityIconGoods(CALL_STATUS = this.CALL_STATUS.LOAD_MORE) { | ||
| 524 | + | ||
| 525 | + // 判断必要参数 | ||
| 526 | + if (this.tabs.list[this.tabs.active].icon_id) { | ||
| 527 | + | ||
| 528 | + // 设置开始加载 | ||
| 529 | + this.$set(this.tabs.list[this.tabs.active], "loading", true); | ||
| 530 | + | ||
| 531 | + // 加载中提示 | ||
| 532 | + Indicator.open('加载中...'); | ||
| 533 | + | ||
| 534 | + // 请求接口 | ||
| 535 | + this.http("/Api/" + (this.getApiVersion().good) + "/activityIconGoods", { | ||
| 536 | + shop_id: this.tabs.list[this.tabs.active].icon_id, | ||
| 537 | + page: this.tabs.list[this.tabs.active].page | ||
| 538 | + }, this.activityIconGoodsCallback, { | ||
| 539 | + method: "POST", | ||
| 540 | + CALL_STATUS | ||
| 541 | + }); | ||
| 542 | + } | ||
| 543 | + }, | ||
| 544 | + | ||
| 545 | + /** | ||
| 546 | + * 获取标签聚合商品列表回调 | ||
| 547 | + * param {Object} res [服务器返回数据] | ||
| 548 | + * param {Object} ext [扩展参数] | ||
| 549 | + */ | ||
| 550 | + activityIconGoodsCallback(res, ext) { | ||
| 551 | + | ||
| 552 | + // 加载完成 | ||
| 553 | + Indicator.close(); | ||
| 554 | + | ||
| 555 | + // 返回处理 | ||
| 556 | + if (res.code == 200) { | ||
| 557 | + | ||
| 558 | + // 解构数据 | ||
| 559 | + let {data: datas} = res; | ||
| 560 | + | ||
| 561 | + // 判断如果有数据 | ||
| 562 | + if (datas.list && datas.list.length) { | ||
| 563 | + | ||
| 564 | + /* 设置列表数据 开始 */ | ||
| 565 | + switch (ext.CALL_STATUS) { | ||
| 566 | + case this.CALL_STATUS.INIT: | ||
| 567 | + | ||
| 568 | + // 设置推荐商品列表 | ||
| 569 | + this.$set(this.lists, this.tabs.active, datas.list); | ||
| 570 | + break; | ||
| 571 | + case this.CALL_STATUS.LOAD_MORE: | ||
| 572 | + | ||
| 573 | + // 添加数据到数组 | ||
| 574 | + this.$set(this.lists, this.tabs.active, [...this.lists[this.tabs.active], ...datas.list]); | ||
| 575 | + break; | ||
| 576 | + } | ||
| 577 | + | ||
| 578 | + // 设置页码 | ||
| 579 | + this.$set(this.tabs.list[this.tabs.active], 'page', ++this.tabs.list[this.tabs.active].page); | ||
| 580 | + | ||
| 581 | + // 取消Loading中状态,恢复LoadingMore功能 | ||
| 582 | + this.$set(this.tabs.list[this.tabs.active], 'loading', false); | ||
| 583 | + this.$set(this.tabs.list[this.tabs.active], 'loadingNow', false); | ||
| 584 | + this.$set(this.tabs.list[this.tabs.active], 'finished', false); | ||
| 585 | + } else { | ||
| 586 | + | ||
| 587 | + // 取消Loading中状态,恢复LoadingMore功能 | ||
| 588 | + this.$set(this.tabs.list[this.tabs.active], 'loading', false); | ||
| 589 | + this.$set(this.tabs.list[this.tabs.active], 'loadingNow', false); | ||
| 590 | + this.$set(this.tabs.list[this.tabs.active], 'finished', true); | ||
| 591 | + } | ||
| 592 | + | ||
| 593 | + /* 设置列表数据 结束 */ | ||
| 594 | + | ||
| 595 | + } else if (res.code == 400) { | ||
| 596 | + | ||
| 597 | + // 获取商品出错 | ||
| 598 | + Toast(res.message); | ||
| 599 | + } else { | ||
| 600 | + | ||
| 601 | + // 获取商品出错 | ||
| 602 | + Toast("获取商品出错"); | ||
| 603 | + } | ||
| 604 | + }, | ||
| 605 | + | ||
| 606 | + /** | ||
| 494 | * 跳转商品详情 | 607 | * 跳转商品详情 |
| 495 | * @param {Object} item [数据对象] | 608 | * @param {Object} item [数据对象] |
| 496 | */ | 609 | */ |