Commit 5b9385f4 authored by wangqinghua's avatar wangqinghua

首页上拉加载更多的数据调整

parent 888497b4
...@@ -390,4 +390,9 @@ a[disabled], button[disabled], [ion-button][disabled], ...@@ -390,4 +390,9 @@ a[disabled], button[disabled], [ion-button][disabled],
100%{ 100%{
font-size: 2.5rem; font-size: 2.5rem;
} }
}
.noData{
text-align: center;
color: #999;
padding-bottom: 5px;
} }
\ No newline at end of file
...@@ -23,7 +23,7 @@ slide { ...@@ -23,7 +23,7 @@ slide {
} }
.slide-zoom{ .slide-zoom{
text-align: center; text-align: center;
line-height: $slide-height; line-height: 219px;
max-height: 100%; max-height: 100%;
} }
.swiper-container { .swiper-container {
......
...@@ -7,6 +7,9 @@ page-login { ...@@ -7,6 +7,9 @@ page-login {
justify-content: left; justify-content: left;
box-sizing: border-box; box-sizing: border-box;
} }
ion-title{
background-color: #e42417;
}
......
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
</ion-refresher-content> </ion-refresher-content>
</ion-refresher> </ion-refresher>
<ion-slides (ionSlideDidChange)="slideChange($event)" loop="true"> <ion-slides (ionSlideDidChange)="slideChange()" loop="true">
<ion-slide *ngFor="let new of slideList"> <ion-slide *ngFor="let new of slideList">
<div class="search-content"> <div class="search-content">
<ng-container *ngFor="let item of new"> <ng-container *ngFor="let item of new">
...@@ -107,10 +107,10 @@ ...@@ -107,10 +107,10 @@
</ion-slide> </ion-slide>
</ion-slides> </ion-slides>
<!-- <ion-infinite-scroll #infiniteScrollContent (ionInfinite)="doInfinite($event)">--> <ion-infinite-scroll #infiniteScrollContentEle (ionInfinite)="doInfinite($event)">
<!-- <ion-infinite-scroll-content--> <ion-infinite-scroll-content
<!-- loadingSpinner="bubbles" threshold="10%"--> loadingSpinner="bubbles"
<!-- loadingText="加载更多..."></ion-infinite-scroll-content>--> loadingText="加载更多..."></ion-infinite-scroll-content>
<!-- </ion-infinite-scroll>--> </ion-infinite-scroll>
</ion-content> </ion-content>
import {Component, ElementRef, Renderer2, ViewChild} from '@angular/core'; import {Component, ElementRef, Renderer2, ViewChild} from '@angular/core';
import {IonicPage, NavController, NavParams, Slide, Slides} from 'ionic-angular'; import {InfiniteScrollContent, IonicPage, NavController, NavParams, Slide, Slides} from 'ionic-angular';
import {SearchNewPage} from "../../home-pages/search-new/search-new"; import {SearchNewPage} from "../../home-pages/search-new/search-new";
import {TabsService} from "../tabs.service"; import {TabsService} from "../tabs.service";
import {StuffDetailPage} from "../../home-pages/stuff-detail/stuff-detail"; import {StuffDetailPage} from "../../home-pages/stuff-detail/stuff-detail";
...@@ -22,7 +22,8 @@ export class DiscoverPage { ...@@ -22,7 +22,8 @@ export class DiscoverPage {
@ViewChild('tabsChildren') tabsChildren: ElementRef; @ViewChild('tabsChildren') tabsChildren: ElementRef;
@ViewChild('tabSpan') tabSpan: ElementRef; @ViewChild('tabSpan') tabSpan: ElementRef;
@ViewChild('newsContent') newsContent: ElementRef; @ViewChild('newsContent') newsContent: ElementRef;
@ViewChild('infiniteScrollContent') infiniteScrollContent: ElementRef; @ViewChild(InfiniteScrollContent) infiniteScrollContent: InfiniteScrollContent;
@ViewChild('infiniteScrollContentEle') infiniteScrollContentEle: ElementRef;
//所属板块类型: //所属板块类型:
//1党章党规,2系列讲话,3中央精神,4本市部署,5通知公告,6党建动态,7工作提示,8党务参考 //1党章党规,2系列讲话,3中央精神,4本市部署,5通知公告,6党建动态,7工作提示,8党务参考
...@@ -148,6 +149,9 @@ export class DiscoverPage { ...@@ -148,6 +149,9 @@ export class DiscoverPage {
slideList = []; slideList = [];
toIndex; toIndex;
//分页
pageCount = AppGlobal.pageCount;
constructor(public navCtrl: NavController, public navParams: NavParams, constructor(public navCtrl: NavController, public navParams: NavParams,
public commonSer: CommonService,public renderer:Renderer2, public commonSer: CommonService,public renderer:Renderer2,
public tabsSer: TabsService, public emitSer: EmitService) { public tabsSer: TabsService, public emitSer: EmitService) {
...@@ -248,10 +252,11 @@ export class DiscoverPage { ...@@ -248,10 +252,11 @@ export class DiscoverPage {
this.navCtrl.push(NoticePage); this.navCtrl.push(NoticePage);
} }
//下拉刷新
doRefresh(e) { doRefresh(e) {
const data = { const data = {
pageSize: 1, pageNum: 1,
pageCount: 100, pageCount: this.pageCount,
obj: { obj: {
'plateType': this.plateType, 'plateType': this.plateType,
'resourceType': 1 'resourceType': 1
...@@ -274,15 +279,16 @@ export class DiscoverPage { ...@@ -274,15 +279,16 @@ export class DiscoverPage {
) )
} }
//上拉加载
doInfinite(e) { doInfinite(e) {
this.renderer.setStyle(this.infiniteScrollContent.nativeElement,'height','84px'); this.renderer.setStyle(this.infiniteScrollContentEle.nativeElement,'height','84px');
setTimeout(()=>{ setTimeout(()=>{
e.complete(); e.complete();
this.renderer.setStyle(this.infiniteScrollContent.nativeElement,'height','0px'); this.renderer.setStyle(this.infiniteScrollContentEle.nativeElement,'height','0px');
},1000) },1000)
} }
slideChange(e) { slideChange() {
let index = this.slides.getActiveIndex(); let index = this.slides.getActiveIndex();
if (index == this.tabsList.length) index = 0; if (index == this.tabsList.length) index = 0;
if (index == this.tabsList.length + 1) index = 1; if (index == this.tabsList.length + 1) index = 1;
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
</ion-buttons> </ion-buttons>
</ion-navbar> </ion-navbar>
</ion-header> </ion-header>
<ion-content> <ion-content overflow-scroll="false">
<ion-refresher (ionRefresh)="doRefresh($event)"> <ion-refresher (ionRefresh)="doRefresh($event)">
<ion-refresher-content pullingText="下拉刷新" <ion-refresher-content pullingText="下拉刷新"
refreshingSpinner="bubbles"> refreshingSpinner="bubbles">
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
</div> </div>
</div> </div>
<ion-slides (ionSlideDidChange)="slideChange()" loop="true"> <ion-slides (ionSlideDidChange)="slideChange()" loop="true">
<ion-slide *ngFor="let item of slideList;let i = index"> <ion-slide [style.top]="isScroll == true?'50px':''" *ngFor="let item of slideList;let i = index">
<div class="main-news"> <div class="main-news">
<ng-container *ngFor="let new of item;"> <ng-container *ngFor="let new of item;">
<ng-container *ngIf="new.imgUrl"> <ng-container *ngIf="new.imgUrl">
...@@ -105,11 +105,12 @@ ...@@ -105,11 +105,12 @@
</ion-slide> </ion-slide>
</ion-slides> </ion-slides>
<!-- <ion-infinite-scroll #infiniteScrollContent (ionInfinite)="doInfinite($event)">--> <ion-infinite-scroll #infiniteScrollContentEle (ionInfinite)="doInfinite($event)">
<!-- <ion-infinite-scroll-content--> <ion-infinite-scroll-content
<!-- loadingSpinner="bubbles"--> loadingSpinner="bubbles"
<!-- loadingText="加载更多..."></ion-infinite-scroll-content>--> loadingText="加载更多..."></ion-infinite-scroll-content>
<!-- </ion-infinite-scroll>--> </ion-infinite-scroll>
<p class="noData" *ngIf="!loadMore">已经到底了</p>
</ion-content> </ion-content>
<!--政治生日--> <!--政治生日-->
<div *ngIf="isBir" class="signMask" (click)="close($event)"> <div *ngIf="isBir" class="signMask" (click)="close($event)">
......
...@@ -195,7 +195,7 @@ page-home { ...@@ -195,7 +195,7 @@ page-home {
align-items: baseline; align-items: baseline;
font-size: 1.4rem; font-size: 1.4rem;
overflow-y: scroll; overflow-y: scroll;
padding-bottom: 1rem; padding-bottom: 5rem;
text-align: left; text-align: left;
} }
.slide-zoom{ .slide-zoom{
......
...@@ -32,7 +32,8 @@ export class HomePage { ...@@ -32,7 +32,8 @@ export class HomePage {
@ViewChild('topHeight') topHeight: ElementRef; @ViewChild('topHeight') topHeight: ElementRef;
@ViewChild('headerTag') headerTag: ElementRef; @ViewChild('headerTag') headerTag: ElementRef;
@ViewChild('homeMiddleTips') homeMiddleTips: ElementRef; @ViewChild('homeMiddleTips') homeMiddleTips: ElementRef;
@ViewChild('infiniteScrollContent') infiniteScrollContent: ElementRef; @ViewChild('infiniteScrollContentEle') infiniteScrollContentEle: ElementRef;
@ViewChild(InfiniteScrollContent) infiniteScrollContent: InfiniteScrollContent;
picture: string = AppGlobal.domain + '/wisdomgroup'; picture: string = AppGlobal.domain + '/wisdomgroup';
//所属板块类型: //所属板块类型:
...@@ -46,7 +47,7 @@ export class HomePage { ...@@ -46,7 +47,7 @@ export class HomePage {
// ]; // ];
tabsList = [ tabsList = [
{name: "系列讲话", type: 2, index: 0}, {name: "系列讲话", type: 2, index: 0},
{name: "党章党规", type: 1,index: 1}, {name: "党章党规", type: 1, index: 1},
{name: "中央精神", type: 3, index: 2}, {name: "中央精神", type: 3, index: 2},
{name: "本市部署", type: 4, index: 3} {name: "本市部署", type: 4, index: 3}
]; ];
...@@ -73,15 +74,16 @@ export class HomePage { ...@@ -73,15 +74,16 @@ export class HomePage {
spanWidth; //文字宽度 spanWidth; //文字宽度
pageSize = 1; pageNum = 1;
pageCount = 100; pageCount = AppGlobal.pageCount;
//分页 //分页
totalNum; totalNum;
loadMore = true;
constructor(public navCtrl: NavController, public tts: TextToSpeech, public datePipe: DatePipe, constructor(public navCtrl: NavController, public tts: TextToSpeech, public datePipe: DatePipe,
public commonSer: CommonService, public emitSer: EmitService, public commonSer: CommonService, public emitSer: EmitService,
public zone: NgZone, public slideListCom: SlideListComponent, public zone: NgZone, public slideListCom: SlideListComponent,
public renderer:Renderer2,public slideCom:SlideComponent, public renderer: Renderer2, public slideCom: SlideComponent,
public appService: AppService, public http: Http, public storage: Storage, public appService: AppService, public http: Http, public storage: Storage,
public badge: Badge, public tabsSer: TabsService) { public badge: Badge, public tabsSer: TabsService) {
// 接收发射过来的数据 // 接收发射过来的数据
...@@ -100,6 +102,7 @@ export class HomePage { ...@@ -100,6 +102,7 @@ export class HomePage {
this.signObj = res.data; this.signObj = res.data;
} }
); );
this.change(this.tabsList[0]);
} }
ionViewDidLoad() { ionViewDidLoad() {
...@@ -107,7 +110,6 @@ export class HomePage { ...@@ -107,7 +110,6 @@ export class HomePage {
this.spanWidth = this.tabSpan.nativeElement.offsetWidth; //文字宽度 this.spanWidth = this.tabSpan.nativeElement.offsetWidth; //文字宽度
this.tips.nativeElement.style.width = this.tabSpan.nativeElement.offsetWidth + 'px'; this.tips.nativeElement.style.width = this.tabSpan.nativeElement.offsetWidth + 'px';
this.tips1.nativeElement.style.width = this.tabSpan.nativeElement.offsetWidth + 'px'; this.tips1.nativeElement.style.width = this.tabSpan.nativeElement.offsetWidth + 'px';
this.change(this.tabsList[0]);
this.getInfo(); this.getInfo();
this.scrollHeight(); this.scrollHeight();
} }
...@@ -127,15 +129,16 @@ export class HomePage { ...@@ -127,15 +129,16 @@ export class HomePage {
} }
change(item) { change(item) {
this.pageSize = 1; this.pageNum = 1;
const index = item.index; this.loadMore = true;
this.infiniteScrollContent.inf.enable(true);
this.index = item.index;
// 自身div的一半 - 滑块的一半 // 自身div的一半 - 滑块的一半
this.tips.nativeElement.style.left = this.itemWidth * (index) + (this.itemWidth - this.spanWidth) / 2 + 'px'; this.tips.nativeElement.style.left = this.itemWidth * (this.index) + (this.itemWidth - this.spanWidth) / 2 + 'px';
this.tips1.nativeElement.style.left = this.itemWidth * (index) + (this.itemWidth - this.spanWidth) / 2 + 'px'; this.tips1.nativeElement.style.left = this.itemWidth * (this.index) + (this.itemWidth - this.spanWidth) / 2 + 'px';
this.index = index;
this.plateType = item.type; this.plateType = item.type;
const data = { const data = {
pageSize: this.pageSize, pageNum: this.pageNum,
pageCount: this.pageCount, pageCount: this.pageCount,
obj: { obj: {
'plateType': this.plateType, 'plateType': this.plateType,
...@@ -146,21 +149,21 @@ export class HomePage { ...@@ -146,21 +149,21 @@ export class HomePage {
(res) => { (res) => {
let arr = res.data.list; let arr = res.data.list;
this.totalNum = res.data.total; this.totalNum = res.data.total;
if(arr.length > 0){ if (arr.length > 0) {
arr.forEach(e => { arr.forEach(e => {
if (e.attachments.length > 0) { if (e.attachments.length > 0) {
e.imgUrl = e.attachments[0].path; e.imgUrl = e.attachments[0].path;
} }
}); });
this.slideList[index] = arr; this.slideList[this.index] = arr;
} }
if(this.slides1) this.slides1.slideTo(index, 500); if (this.slides1) this.slides1.slideTo(this.index, 500);
} }
) )
} }
slideChange() { slideChange() {
if(this.initSlide == 0){ //防止初始化加载 if (this.initSlide == 0) { //防止初始化加载
this.initSlide = 1; this.initSlide = 1;
return false; return false;
} }
...@@ -264,24 +267,28 @@ export class HomePage { ...@@ -264,24 +267,28 @@ export class HomePage {
//上拉加载 //上拉加载
doInfinite(e) { doInfinite(e) {
if(this.totalNum == this.slideList[this.index].length){ console.log(this.totalNum)
e.complete(); console.log(this.slideList[this.index].length + 1)
this.commonSer.toastTime('没有更多数据了',1000); if (this.totalNum < this.slideList[this.index].length + 1) {
return false console.log('没有数据了');
this.loadMore = false;
e.enable(false);
return false;
} }
this.pageSize ++; this.pageNum++;
const data = { const data = {
pageSize: this.pageSize, pageNum: this.pageNum,
pageCount: this.pageCount, pageCount: this.pageCount,
obj: { obj: {
'plateType': this.plateType, 'plateType': this.plateType,
'resourceType': 1 'resourceType': 1
} }
} };
this.renderer.setStyle(this.infiniteScrollContentEle.nativeElement, 'height', '60px');
this.tabsSer.stuffPage(data).subscribe( this.tabsSer.stuffPage(data).subscribe(
(res) => { (res) => {
let arr = res.data.list; let arr = res.data.list;
if(arr.length > 0){ if (arr.length > 0) {
arr.forEach(e => { arr.forEach(e => {
if (e.attachments.length > 0) { if (e.attachments.length > 0) {
e.imgUrl = e.attachments[0].path; e.imgUrl = e.attachments[0].path;
...@@ -289,12 +296,10 @@ export class HomePage { ...@@ -289,12 +296,10 @@ export class HomePage {
this.slideList[this.index].push(e); this.slideList[this.index].push(e);
}); });
} }
setTimeout(() => {
this.renderer.setStyle(this.infiniteScrollContent.nativeElement,'height','84px');
setTimeout(()=>{
e.complete(); e.complete();
this.renderer.setStyle(this.infiniteScrollContent.nativeElement,'height','0px'); this.renderer.setStyle(this.infiniteScrollContentEle.nativeElement, 'height', '0px');
},800) }, 1000)
} }
) )
...@@ -303,7 +308,7 @@ export class HomePage { ...@@ -303,7 +308,7 @@ export class HomePage {
//下拉刷新 //下拉刷新
doRefresh(e) { doRefresh(e) {
const data = { const data = {
pageSize: 1, pageNum: 1,
pageCount: this.pageCount, pageCount: this.pageCount,
obj: { obj: {
'plateType': this.plateType, 'plateType': this.plateType,
...@@ -313,7 +318,7 @@ export class HomePage { ...@@ -313,7 +318,7 @@ export class HomePage {
this.tabsSer.stuffPage(data).subscribe( this.tabsSer.stuffPage(data).subscribe(
(res) => { (res) => {
let arr = res.data.list; let arr = res.data.list;
if(arr.length > 0){ if (arr.length > 0) {
arr.forEach(e => { arr.forEach(e => {
if (e.attachments.length > 0) { if (e.attachments.length > 0) {
e.imgUrl = e.attachments[0].path; e.imgUrl = e.attachments[0].path;
...@@ -321,10 +326,10 @@ export class HomePage { ...@@ -321,10 +326,10 @@ export class HomePage {
}); });
} }
this.slideList[this.index] = arr; this.slideList[this.index] = arr;
setTimeout(()=>{ setTimeout(() => {
this.commonSer.toastTime('刷新成功!', 800); this.commonSer.toastTime('刷新成功!', 800);
e.complete(); e.complete();
},800) }, 800)
} }
) )
} }
......
...@@ -32,6 +32,8 @@ export class AppGlobal { ...@@ -32,6 +32,8 @@ export class AppGlobal {
getLogin: '/app/loginpost', getLogin: '/app/loginpost',
getDetails: '/api/ionic3/details' getDetails: '/api/ionic3/details'
}; };
static pageCount = 2;
} }
@Injectable() @Injectable()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment