|
|
|
@ -5,6 +5,7 @@ import {HomeService} from "../../home.service";
|
|
|
|
|
import {getGiftCount, getUser} from "../../../mine/mine.service";
|
|
|
|
|
import {Subject, Subscription} from "rxjs";
|
|
|
|
|
import {NavigationEnd, Router} from "@angular/router";
|
|
|
|
|
import {takeUntil} from "rxjs/operators";
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'app-article-content',
|
|
|
|
@ -18,11 +19,13 @@ export class ArticleContentComponent implements OnInit {
|
|
|
|
|
size: 10,
|
|
|
|
|
search_eq_class:""
|
|
|
|
|
};
|
|
|
|
|
hasMore: boolean = true;
|
|
|
|
|
hasMore: boolean = false;
|
|
|
|
|
@Input() className:string = ""
|
|
|
|
|
username:string = ""
|
|
|
|
|
data:Article[] = []
|
|
|
|
|
currentSelect = "new"
|
|
|
|
|
selectBtn:string = "new"
|
|
|
|
|
private destroy$ = new Subject<void>();
|
|
|
|
|
|
|
|
|
|
constructor(private homeService:HomeService,
|
|
|
|
|
private cdr:ChangeDetectorRef) { }
|
|
|
|
@ -32,13 +35,21 @@ export class ArticleContentComponent implements OnInit {
|
|
|
|
|
this.getUsername();
|
|
|
|
|
}
|
|
|
|
|
ionChange(e:any){
|
|
|
|
|
}
|
|
|
|
|
select(v:string) {
|
|
|
|
|
if(v==this.selectBtn){
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
this.hasMore = false;
|
|
|
|
|
this.selectBtn = v
|
|
|
|
|
this.searchParams['page'] = 0
|
|
|
|
|
this.data = []
|
|
|
|
|
this.currentSelect = e.detail.value
|
|
|
|
|
this.destroy$.next()
|
|
|
|
|
this.getData()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getData() {
|
|
|
|
|
|
|
|
|
|
switch (this.currentSelect){
|
|
|
|
|
case "new":
|
|
|
|
|
return this.getNewData()
|
|
|
|
@ -60,12 +71,14 @@ export class ArticleContentComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
getNewData() {
|
|
|
|
|
this.homeService.list(this.searchParams).subscribe(res=>{
|
|
|
|
|
if(res.items.length > 0) {
|
|
|
|
|
this.data = this.data.concat(res.items)
|
|
|
|
|
this.searchParams['page'] = this.searchParams['page']+1;
|
|
|
|
|
this.hasMore = res.items.length === this.searchParams['size'];
|
|
|
|
|
this.cdr.detectChanges();
|
|
|
|
|
this.homeService.list(this.searchParams).pipe(takeUntil(this.destroy$)).subscribe(res=>{
|
|
|
|
|
if(res.items){
|
|
|
|
|
if(res.items.length > 0) {
|
|
|
|
|
this.data = this.data.concat(res.items)
|
|
|
|
|
this.searchParams['page'] = this.searchParams['page']+1;
|
|
|
|
|
this.hasMore = res.items.length === this.searchParams['size'];
|
|
|
|
|
this.cdr.detectChanges();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
@ -75,24 +88,28 @@ export class ArticleContentComponent implements OnInit {
|
|
|
|
|
if(this.className != "") {
|
|
|
|
|
this.searchParams['search_eq_class'] = this.className
|
|
|
|
|
}
|
|
|
|
|
this.homeService.unlockList(this.searchParams).subscribe(res=>{
|
|
|
|
|
if(res.items.length > 0) {
|
|
|
|
|
this.data = this.data.concat(res.items)
|
|
|
|
|
this.searchParams['page'] = this.searchParams['page']+1;
|
|
|
|
|
this.hasMore = res.items.length === this.searchParams['size'];
|
|
|
|
|
this.cdr.detectChanges();
|
|
|
|
|
this.homeService.unlockList(this.searchParams).pipe(takeUntil(this.destroy$)).subscribe(res=>{
|
|
|
|
|
if(res.items) {
|
|
|
|
|
if(res.items.length > 0) {
|
|
|
|
|
this.data = this.data.concat(res.items)
|
|
|
|
|
this.searchParams['page'] = this.searchParams['page']+1;
|
|
|
|
|
this.hasMore = res.items.length === this.searchParams['size'];
|
|
|
|
|
this.cdr.detectChanges();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
getFreeData() {
|
|
|
|
|
this.homeService.freeList(this.searchParams).subscribe(res=>{
|
|
|
|
|
if(res.items.length > 0) {
|
|
|
|
|
this.data = this.data.concat(res.items)
|
|
|
|
|
this.searchParams['page'] = this.searchParams['page']+1;
|
|
|
|
|
this.hasMore = res.items.length === this.searchParams['size'];
|
|
|
|
|
this.cdr.detectChanges();
|
|
|
|
|
this.homeService.freeList(this.searchParams).pipe(takeUntil(this.destroy$)).subscribe(res=>{
|
|
|
|
|
if(res.items) {
|
|
|
|
|
if(res.items.length > 0) {
|
|
|
|
|
this.data = this.data.concat(res.items)
|
|
|
|
|
this.searchParams['page'] = this.searchParams['page']+1;
|
|
|
|
|
this.hasMore = res.items.length === this.searchParams['size'];
|
|
|
|
|
this.cdr.detectChanges();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|