Newer
Older
import {Component, ViewChild} from '@angular/core';
import {InfiniteScrollContent, IonicPage, NavController, NavParams} from 'ionic-angular';
import {ServeService} from "../../serve.service";
import {CommonService} from "../../../../provide/common.service";
import {timer} from "rxjs/observable/timer";
import {CarApplyPage} from "../car-apply/car-apply";
@ViewChild(InfiniteScrollContent) infiniteScrollContent: InfiniteScrollContent;
pageNum = 1;
pageSize = 10;
changeType = 1;
footerView = false;
checkAll = false;
chooseObj = [];
totalNum;
apply = {
list: [],
isLoad: false,
loadMore: false
};
constructor(public navCtrl: NavController, public navParams: NavParams,
private serveSer: ServeService, private commonSer: CommonService) {
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
}
ionViewWillLeave() {
this.footerView = false;
}
getList() {
const data = {
P_pageNumber: 1,
P_pageSize: this.pageSize,
status: this.changeType
};
this.serveSer.searchCarCheckList(data).subscribe(
(res) => {
this.apply.list = res.data.list;
}
)
}
change(type) {
this.changeType = type;
this.getList();
}
changeCheck(item) {
const index = this.chooseObj.indexOf(item.id);
if (index > -1) {
this.chooseObj.splice(index, 1);
} else {
this.chooseObj.push(item.id);
}
this.checkAll = this.chooseObj.length === this.apply.list.length;
}
//下拉刷新
doRefresh(e) {
this.apply.loadMore = true;
this.infiniteScrollContent.inf.enable(true);
const data = {
P_pageNumber: 1,
P_pageSize: this.pageSize,
status: this.changeType
};
this.serveSer.searchCarCheckList(data).subscribe(
(res) => {
this.apply.list = res.data.list;
this.totalNum = res.data.total;
timer(800).subscribe(() => {
this.commonSer.toast('刷新成功');
e.complete()
});
}
)
}
//加载更多
doInfinite(e) {
if (this.totalNum == this.apply.list.length) {
console.log("没有更多了");
this.apply.loadMore = false;
e.enable(false);
return false;
}
this.pageNum++;
const data = {
P_pageNumber: this.pageNum,
P_pageSize: this.pageSize,
status: this.changeType
};
this.serveSer.searchCarCheckList(data).subscribe(
(res) => {
this.totalNum = res.data.total;
res.list.forEach(e => {
this.apply.list.push(e);
});
timer(800).subscribe(() => e.complete());
}
)
}
goDetail(item){