Newer
Older
import {Component, ViewChild} from '@angular/core';
import {InfiniteScrollContent, IonicPage, NavController, NavParams} from 'ionic-angular';
import {MineService} from "../mine.service";
import {AppGlobal} from "../../../service/http.service";
import {StuffDetailPage} from "../../home-pages/stuff-detail/stuff-detail";
import {CommonService} from "../../../provide/common.service";
@ViewChild(InfiniteScrollContent) infiniteScrollContent:InfiniteScrollContent;
collectionList = [];
picture: string = AppGlobal.domain + '/wisdomgroup';
isLoad = true;
loadMore = true;
totalNum; //总条数
constructor(public navCtrl: NavController, public navParams: NavParams,
public mineSer: MineService,public commonSer:CommonService) {
getList() {
const data = {
pageNum: this.pageNum,
pageCount: this.pageCount
};
this.mineSer.myCollection(data).subscribe(
(res) => {
this.collectionList = res.data.list;
this.isLoad = false;
this.totalNum = res.data.total;
}
)
}
//下拉刷新
doRefresh(e){
this.loadMore = true;
this.infiniteScrollContent.inf.enable(true);
const data = {
pageNum: 1,
pageCount: this.pageCount
};
this.mineSer.myCollection(data).subscribe(
(res) => {
this.collectionList = res.data.list;
this.totalNum = res.data.total;
setTimeout(()=>{
e.complete()
},800);
}
)
}
//加载更多
doInfinite(e){
if(this.totalNum == this.collectionList.length ){
this.loadMore = false;
e.enable(false);
return false;
}
this.pageNum ++;
const data = {
pageNum: this.pageNum,
pageCount: this.pageCount
};
this.mineSer.myCollection(data).subscribe(
(res) => {
this.totalNum = res.data.total;
res.data.list.forEach(e=>{
this.collectionList.push(e);
});
setTimeout(()=>{
e.complete()
},800);
}
)
}
//查看文章详情
goToDetail(item) {
this.navCtrl.push(StuffDetailPage, {
id: item.id
})
}