Commit ed33b2fce8aae21ff7478a04ffaf0f1ee2c68957
1 parent
55291fd9
上拉加载更多
Showing
3 changed files
with
55 additions
and
21 deletions
src/components/giftGivingItem/giftGivingItem.less
src/pages/myGiftBox/myGiftBox.less
| ... | ... | @@ -47,7 +47,15 @@ |
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 | .item_box{ |
| 50 | - height: calc(100vh-90px); | |
| 51 | - overflow-y: auto; | |
| 50 | + // height: calc(100vh-200px); | |
| 51 | + padding-bottom: 40px; | |
| 52 | + // overflow-y: auto; | |
| 53 | + height: auto; | |
| 54 | + } | |
| 55 | + .tip_text{ | |
| 56 | + text-align: center; | |
| 57 | + margin-top: 20px; | |
| 58 | + font-size: 26px; | |
| 59 | + color: #999; | |
| 52 | 60 | } |
| 53 | 61 | } | ... | ... |
src/pages/myGiftBox/myGiftBox.vue
| ... | ... | @@ -18,7 +18,7 @@ |
| 18 | 18 | <div class="item_box"> |
| 19 | 19 | <div |
| 20 | 20 | infinite-scroll-immediate-check="true" |
| 21 | - v-infinite-scroll="getorderGiftList" | |
| 21 | + v-infinite-scroll="onInfiniteScroll" | |
| 22 | 22 | infinite-scroll-disabled="loading" |
| 23 | 23 | :infinite-scroll-distance="50" |
| 24 | 24 | > |
| ... | ... | @@ -37,6 +37,8 @@ |
| 37 | 37 | :giftGivingItem="giftGivingItem" |
| 38 | 38 | > |
| 39 | 39 | </giftGivingItem> |
| 40 | + <!-- 没有更多了 --> | |
| 41 | + <div class="tip_text">{{this.tipText}}</div> | |
| 40 | 42 | </div> |
| 41 | 43 | </div> |
| 42 | 44 | </div> |
| ... | ... | @@ -53,16 +55,18 @@ export default { |
| 53 | 55 | return { |
| 54 | 56 | active: 0, |
| 55 | 57 | receivingGiftsInfo: null, // 收礼列表页数据 |
| 56 | - receivingGifts: { | |
| 58 | + loading: false, // 判断是否加载 | |
| 59 | + receivingGifts: { // 收礼 | |
| 57 | 60 | loading: false, // 加载 |
| 58 | 61 | pages: 0 // 分页 |
| 59 | 62 | }, |
| 60 | 63 | giftGivingItem: null, // 送礼列表页数据 |
| 61 | - giftsRuleUrl:null, // 礼物规则URL | |
| 62 | - giftGiving: { | |
| 64 | + giftsRuleUrl: null, // 礼物规则URL | |
| 65 | + giftGiving: { // 送礼 | |
| 63 | 66 | loading: false, // 加载 |
| 64 | 67 | pages: 0 // 分页 |
| 65 | - } | |
| 68 | + }, | |
| 69 | + tipText:null // 是否已加载完 | |
| 66 | 70 | }; |
| 67 | 71 | }, |
| 68 | 72 | components: { |
| ... | ... | @@ -75,20 +79,46 @@ export default { |
| 75 | 79 | // 送礼订单列表 |
| 76 | 80 | this.getorderGiveGiftList(); |
| 77 | 81 | // 赠礼规则 |
| 78 | - this.orderGiftContent() | |
| 82 | + this.orderGiftContent(); | |
| 79 | 83 | }, |
| 80 | 84 | methods: { |
| 85 | + /** | |
| 86 | + * tab切换 | |
| 87 | + */ | |
| 81 | 88 | onTap(active) { |
| 82 | 89 | this.active = active; |
| 90 | + // 初始化加载状态 | |
| 91 | + this.loading = false; | |
| 83 | 92 | if (active === 1) { |
| 84 | 93 | // 调用im是否显示隐藏1显示im聊天弹窗0不显示 |
| 85 | 94 | this.setGiftBottomVisibleBySwitchTab(1); |
| 95 | + // 送礼订单列表 | |
| 96 | + this.getorderGiveGiftList(); | |
| 86 | 97 | } else { |
| 98 | + // 收礼订单列表 | |
| 99 | + this.getorderGiftList(); | |
| 87 | 100 | // 调用im是否显示隐藏1显示im聊天弹窗0不显示 |
| 88 | 101 | this.setGiftBottomVisibleBySwitchTab(0); |
| 89 | 102 | } |
| 90 | 103 | }, |
| 91 | 104 | /** |
| 105 | + * 下啦滑动加载更多 | |
| 106 | + */ | |
| 107 | + onInfiniteScroll() { | |
| 108 | + if (this.active === 0) { | |
| 109 | + // 收礼订单列表 | |
| 110 | + this.loading = this.receivingGifts.loading | |
| 111 | + this.getorderGiftList(); | |
| 112 | + } else { | |
| 113 | + // 送礼订单列表 | |
| 114 | + this.loading = this.giftGiving.loading | |
| 115 | + this.getorderGiveGiftList(); | |
| 116 | + } | |
| 117 | + if(!this.loading){ | |
| 118 | + this.tipText = "已经全部加载完毕" | |
| 119 | + } | |
| 120 | + }, | |
| 121 | + /** | |
| 92 | 122 | * 显示和隐藏聊天 |
| 93 | 123 | */ |
| 94 | 124 | setGiftBottomVisibleBySwitchTab(itme) { |
| ... | ... | @@ -157,7 +187,7 @@ export default { |
| 157 | 187 | if (datas.list && datas.list.length) { |
| 158 | 188 | // 隐藏加载圈 |
| 159 | 189 | this.receivingGifts.loading = false; |
| 160 | - if (this.pages > 1) { | |
| 190 | + if (this.receivingGifts.pages > 1) { | |
| 161 | 191 | this.$set(this, "receivingGiftsInfo", [ |
| 162 | 192 | ...this.receivingGiftsInfo, |
| 163 | 193 | ...datas.list |
| ... | ... | @@ -277,15 +307,11 @@ export default { |
| 277 | 307 | if (datas.list && datas.list.length) { |
| 278 | 308 | // 隐藏加载圈 |
| 279 | 309 | this.giftGiving.loading = false; |
| 280 | - if (this.pages > 1) { | |
| 281 | - this.$set(this, "giftGivingItem", [ | |
| 282 | - ...this.giftGivingItem, | |
| 283 | - ...datas.list | |
| 284 | - ]); | |
| 310 | + if (this.giftGiving.pages > 1) { | |
| 311 | + this.$set(this, "giftGivingItem",[...this.giftGivingItem,...datas.list]); | |
| 285 | 312 | } else { |
| 286 | 313 | this.$set(this, "giftGivingItem", datas.list); |
| 287 | 314 | } |
| 288 | - console.log(this.giftGivingItem); | |
| 289 | 315 | } |
| 290 | 316 | /* 获取送礼订单列表 结束 */ |
| 291 | 317 | } else if (res.code == 400) { |
| ... | ... | @@ -318,19 +344,19 @@ export default { |
| 318 | 344 | * @param {object} res [服务器返回数据] |
| 319 | 345 | * @param {object} ext [扩展参数] |
| 320 | 346 | */ |
| 321 | - orderGiftContentCallback(res, ext){ | |
| 322 | - // 加载完成 | |
| 347 | + orderGiftContentCallback(res, ext) { | |
| 348 | + // 加载完成 | |
| 323 | 349 | Indicator.close(); |
| 324 | 350 | |
| 325 | 351 | // 返回处理 |
| 326 | 352 | if (res.code == 200) { |
| 327 | - // 解构数据 | |
| 353 | + // 解构数据 | |
| 328 | 354 | let { data: datas } = res; |
| 329 | - this.giftsRuleUrl = datas.content | |
| 355 | + this.giftsRuleUrl = datas.content; | |
| 330 | 356 | } |
| 331 | 357 | }, |
| 332 | 358 | // 送礼规则说明 |
| 333 | - giftRules(){ | |
| 359 | + giftRules() { | |
| 334 | 360 | // 判断并调用通用跳转 |
| 335 | 361 | if (typeof this.$parent.gotoDetail === "function") { |
| 336 | 362 | // 临时,设置跳转商品详情参数 | ... | ... |