Newer
Older
import {Component, ElementRef, ViewChild} from '@angular/core';
import {IonicPage, NavController, NavParams} 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;
//所属板块类型:
//1党章党规,2系列讲话,3中央精神,4本市部署,5通知公告,6党建动态,7工作提示,8党务参考
//9廉政格言,10纪检提示,11风险排查,12警示教育,13支部活动,14党建联建,15结对帮扶
},
{
"name": "党务参考",
"type": 8,
"indexChildren": '05'
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
"indexChildren": '14'
}
]
},
{
"name": "党风廉政", "type": 9, "indexParent": 2, "children": [
{
"name": "最新",
"type": 9,
"indexChildren": '21'
},
{
"name": "廉政格言",
"type": 9,
"indexChildren": '22'
},
{
"name": "纪检提示",
"type": 10,
"indexChildren": '23'
},
{
"name": "风险排查",
"type": 11,
"indexChildren": '24'
},
{
"name": "警示教育",
"type": 12,
"indexChildren": '25'
}
]
},
{
"name": "互动交流", "type": -1, "indexParent": 3, "children": [
{
"name": "最新",
"type": -1,
"indexChildren": '31'
},
{
"name": "学思践悟",
"type": -1,
"indexChildren": '32'
},
{
"name": "话题讨论",
"type": -1,
"indexChildren": '33'
},
{
"name": "你问我答",
"type": -1,
"indexChildren": '34'
}]
},
{"name": "知识拓展", "type": -1, "indexParent": 4, "children": []}
constructor(public navCtrl: NavController, public navParams: NavParams,
//父级选择
changeParent(item) {
this.newsContent.nativeElement.scrollLeft = 0; //二级菜单滑动重置
const index = item.indexParent;
this.indexParent = index;
this.childrenList = item.children;
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,
pageCount: 100,
obj: {
'resourceType': 1
}
};
this.tabsSer.stuffPage(data).subscribe(
(res) => {
this.newList = res.data;
this.newList.forEach(e => {
if (e.attachments.length > 0) {
e.imgUrl = e.attachments[0].path;
}
})
}
)
}
//子级选择
changeChildren(item) {
this.indexChildren = item.indexChildren;
const data = {
pageSize: 1,
pageCount: 100,
obj: {
'plateType': item.type,
'resourceType': 1
this.tabsSer.stuffPage(data).subscribe(
(res) => {
this.newList = res.data;
this.newList.forEach(e => {
if (e.attachments.length > 0) {
e.imgUrl = e.attachments[0].path;
}
})
}
)
}
//前往搜索页面
goToSearch() {
this.navCtrl.push(SearchNewPage);
}
//查看详情
goToDetail(item) {
this.navCtrl.push(StuffDetailPage, {
id: item.id
});
}
//前往发布页面