Newer
Older
import {Component, ElementRef, ViewChild, NgZone, Renderer2} from '@angular/core';
import {NavController, IonicPage, Slides, Content} from 'ionic-angular';
import {Http, Response} from '@angular/http';
import {AppService, AppGlobal} from '../../../service/http.service';
import {Storage} from '@ionic/storage';
import {NoticePage} from "../notice/notice";
import {Badge} from '@ionic-native/badge';
import {TabsService} from "../tabs.service";
import {TextToSpeech} from "@ionic-native/text-to-speech";
import {CommonService} from "../../../provide/common.service";
import {SearchNewPage} from "../../home-pages/search-new/search-new";
import {StuffDetailPage} from "../../home-pages/stuff-detail/stuff-detail";
import {SlideListComponent} from "../../../components/slide-list/slide-list";
@IonicPage()
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
//所属板块类型:
//1党章党规,2系列讲话,3中央精神,4本市部署,5通知公告,6党建动态,7工作提示,8党务参考
//9廉政格言,10纪检提示,11风险排查,12警示教育,13支部活动,14党建联建,15结对帮扶
tabsList = [
{name: "系列讲话", type: 2, index: 0},
{name: "党章党规", type: 1, index: 1},
{name: "中央精神", type: 3, index: 2},
{name: "本市部署", type: 4, index: 3}
];
plateType;
index = 0;
slideList = [];
itemWidth ;
spanWidth ; //文字宽度
constructor(public navCtrl: NavController, public tts: TextToSpeech, public datePipe: DatePipe,
public appService: AppService, public http: Http, public storage: Storage,
this.itemWidth = window.screen.width / 4;
this.spanWidth = this.tabSpan.nativeElement.offsetWidth; //文字宽度
console.log(this.spanWidth)
this.tips.nativeElement.style.width = this.tabSpan.nativeElement.offsetWidth + 'px';
this.tips1.nativeElement.style.width = this.tabSpan.nativeElement.offsetWidth + 'px';
this.change(this.tabsList[0]);
const height = this.topHeight.nativeElement.offsetHeight + 54;
console.log(this.topHeight.nativeElement.offsetHeight)
this.content.ionScroll.subscribe(($event)=>{
this.zone.run(()=>{
if(this.content.scrollTop > height){
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
change(item) {
const index = item.index;
// 自身div的一半 - 滑块的一半
this.tips.nativeElement.style.left = this.itemWidth * (index) + (this.itemWidth - this.spanWidth) / 2 + 'px';
this.tips1.nativeElement.style.left = this.itemWidth * (index) + (this.itemWidth - this.spanWidth) / 2 + 'px';
this.index = index;
this.plateType = item.type;
const data = {
pageSize: 1,
pageCount: 100,
obj: {
'plateType': this.plateType,
'resourceType': 1
}
}
this.tabsSer.stuffPage(data).subscribe(
(res) => {
let arr = res.data;
arr.forEach(e => {
if (e.attachments.length > 0) {
e.imgUrl = e.attachments[0].path;
}
});
this.slideList[index] = arr;
this.slides1.slideTo(index, 500);
}
)
}
slideChange(e) {
let index = this.slides1.getActiveIndex();
if (index == this.tabsList.length) index = 0;
if (index == this.tabsList.length +1) index = 1;
this.change(this.tabsList[index])
}
//获取党员生日
getInfo() {
this.storage.get("userLoginInfo").then((value) => {
let userid = value.userid;
this.tabsSer.getInfo(userid).subscribe(
(res) => {
this.partyObj = res.apiResult.data;
//获取是否展示过政治生日
const nowDay = this.datePipe.transform( new Date(),'yyyy-MM-dd' );
const partyBir = localStorage.getItem('partyBir');
if(nowDay == partyBir){
this.start();
this.isBir = false;
}else{
this.isBir = true;
}
const nowDay = this.datePipe.transform( new Date(),'yyyy-MM-dd' );
localStorage.setItem('partyBir',nowDay);
this.homeMiddleTips.nativeElement.style.height = "60px";
this.homeMiddleTips.nativeElement.style.padding = ".5rem";
let child_div = this.verticaLamp.nativeElement.children;
const scrollWidth = this.verticaLamp.nativeElement.offsetWidth;
const textWidth = child_div[0].offsetWidth;
let i = scrollWidth;
setInterval(()=>{
i--;
if(i < -textWidth){
i = scrollWidth;
}
child_div[0].style.left = i + 'px';
},20)
}
if (totalTime < 0) {
this.signText = '';
window.clearInterval(clock);
this.disabledClick = false;
}
}, 1000)
}
//查看文章详情
goToDetail(item) {
this.navCtrl.push(StuffDetailPage, {
id: item.id
})
}
const data = {
pageSize: 1,
pageCount: 100,
obj: {
'plateType': this.plateType,
'resourceType': 1
}
}
this.tabsSer.stuffPage(data).subscribe(
(res) => {
let arr = res.data;
arr.forEach(e => {
if (e.attachments.length > 0) {
e.imgUrl = e.attachments[0].path;
}
});
this.commonSer.toastTime('刷新成功!',800)
this.slideList[this.index] = arr;
e.complete();
}
)