Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import {Component, ViewChild} from '@angular/core';
import {InfiniteScrollContent, IonicPage, NavController, NavParams} from 'ionic-angular';
import {ServeService} from "../../serve.service";
import {timer} from "rxjs/observable/timer";
import {CommonService} from "../../../../provide/common.service";
@Component({
selector: 'page-goods-order',
templateUrl: 'goods-order.html',
})
export class GoodsOrderPage {
@ViewChild(InfiniteScrollContent) infiniteScrollContent: InfiniteScrollContent;
orderList = [];
pageNum = 1;
pageSize = 10;
loadMore = false;
totalNum;
constructor(public navCtrl: NavController, public navParams: NavParams,
private serveSer: ServeService, private commonSer: CommonService) {
}
ionViewDidLoad() {
this.getList();
}
getList() {
const data = {
P_pageNumber: this.pageNum,
P_pageSize: this.pageSize,
};
this.serveSer.myOrder(data).subscribe(
(res) => {
this.orderList = res.list;
}
)
}
//下拉刷新
doRefresh(e) {
this.loadMore = true;
this.infiniteScrollContent.inf.enable(true);
const data = {
P_pageNumber: 1,
P_pageSize: this.pageSize,
};
this.serveSer.myOrder(data).subscribe(
(res) => {
this.orderList = res.list;
this.totalNum = res.total;
timer(800).subscribe(() => {
this.commonSer.toast('刷新成功');
e.complete()
});
}
)
}
//加载更多
doInfinite(e) {
if (this.totalNum == this.orderList.length) {
console.log("没有更多了")
this.loadMore = false;
e.enable(false);
return false;
}
this.pageNum++;
const data = {
P_pageNumber: this.pageNum,
P_pageSize: this.pageSize,
};
this.serveSer.myOrder(data).subscribe(
(res) => {
this.totalNum = res.total;
res.list.forEach(e => {
this.orderList.push(e);
});
timer(800).subscribe(() => e.complete());
}
)
}
}