Newer
Older
import {Component, ElementRef, NgZone, Renderer2, ViewChild} from '@angular/core';
import {Content, InfiniteScrollContent, IonicPage, NavController, NavParams, Slide, Slides} from 'ionic-angular';
import {TabsService} from "../tabs.service";
import {StuffDetailPage} from "../../home-pages/stuff-detail/stuff-detail";
import {PublishPage} from "../../discover-pages/publish/publish";
import {EmitService} from "../../../provide/emit.service";
import {NoticePage} from "../notice/notice";
@ViewChild('tips') tips: ElementRef;
@ViewChild('tabsParent') tabsParent: ElementRef;
@ViewChild('tabsChildren') tabsChildren: ElementRef;
@ViewChild('tabSpan') tabSpan: ElementRef;
@ViewChild(InfiniteScrollContent) infiniteScrollContent: InfiniteScrollContent;
@ViewChild('infiniteScrollContentEle') infiniteScrollContentEle: ElementRef;
},
{
"name": "党务参考",
"type": 8,
"indexChildren": '05'
"indexChildren": '14'
}
]
},
{
"name": "党风廉政", "type": 9, "indexParent": 2, "children": [
{
"name": "廉政格言",
"type": 9,
"indexChildren": '22'
},
{
"name": "纪检提示",
"type": 10,
"indexChildren": '23'
},
{
"name": "风险排查",
"type": 11,
"indexChildren": '24'
},
{
"name": "警示教育",
"type": 12,
"indexChildren": '25'
}
]
},
{
},
{
"name": "你问我答",
"type": 24,
"indexChildren": '35'
{
"name": "视频资料",
"type": 16,
"indexChildren": '41'
},
{
"name": "组工咨询",
"type": 17,
"indexChildren": '42'
},
{
"name": "工具书籍",
"type": 18,
"indexChildren": '43'
},
{
"name": "综合知识",
"type": 19,
"indexChildren": '44'
},
constructor(public navCtrl: NavController, public navParams: NavParams,
public commonSer: CommonService, public renderer: Renderer2,
public zone: NgZone,
//父级选择
changeParent(item) {
this.newsContent.nativeElement.scrollLeft = 0; //二级菜单滑动重置
if (this.childrenList.length > 0) this.indexChildren = this.childrenList[0].indexChildren;
let itemWidth = window.screen.width / 4;
let spanWidth = this.tabSpan.nativeElement.offsetWidth; //文字宽度
this.tips.nativeElement.style.width = this.tabSpan.nativeElement.offsetWidth + 'px';
// 自身div的一半 - 滑块的一半
this.tips.nativeElement.style.left = itemWidth * (index) + (itemWidth - spanWidth) / 2 + 'px';
const data = {
pageSize: 1,
'resourceType': 1
}
};
this.tabsSer.stuffPage(data).subscribe(
(res) => {
this.newList.forEach(e => {
if (e.attachments.length > 0) {
e.imgUrl = e.attachments[0].path;
}
}
)
}
//子级选择
changeChildren(item) {
this.indexChildren = item.indexChildren;
this.newList.forEach(e => {
if (e.attachments.length > 0) {
e.imgUrl = e.attachments[0].path;
}
})
obj: {
'plateType': this.plateType,
'resourceType': 1
}
};
this.tabsSer.stuffPage(data).subscribe(
(res) => {
this.newList.forEach(e => {
if (e.attachments.length > 0) {
e.imgUrl = e.attachments[0].path;
}
})
if (this.totalNum < this.slideList[this.toIndex].length + 1) {
console.log('没有数据了');
this.loadMore = false;
return false;
}
this.pageNum++;
const data = {
pageNum: this.pageNum,
pageCount: this.pageCount,
obj: {
'plateType': this.plateType,
'resourceType': 1
}
};
this.renderer.setStyle(this.infiniteScrollContentEle.nativeElement.children[0], 'minHeight', '60px');
this.tabsSer.stuffPage(data).subscribe(
(res) => {
let arr = res.data.list;
if (arr.length > 0) {
arr.forEach(e => {
if (e.attachments.length > 0) {
e.imgUrl = e.attachments[0].path;
}
this.renderer.setStyle(this.infiniteScrollContentEle.nativeElement.children[0], 'minHeight', '0px');
//前往搜索页面
goToSearch() {
this.navCtrl.push(SearchNewPage);
}
//查看详情
goToDetail(item) {
this.navCtrl.push(StuffDetailPage, {
id: item.id
});
}
//前往发布页面
}
//消息提醒页面
goToNotice() {
this.navCtrl.push(NoticePage);
}
if (index == this.tabsList.length + 1) index = 1;
this.changeParent(this.tabsList[index])
this.isPublish = false;
}
stop(e) {
e.stopPropagation();
}