Newer
Older
import {Component, ElementRef, ViewChild, NgZone, Renderer2, Input, ViewChildren, QueryList} from '@angular/core';
import {NavController, IonicPage, Slides, Content, InfiniteScrollContent, FabList, FabContainer} 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";
import {interval} from "rxjs/observable/interval";
import {SwiperComponent} from "../../../components/swiper/swiper";
@IonicPage()
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
@ViewChild('infiniteScrollContentEle') infiniteScrollContentEle: ElementRef;
@ViewChild(InfiniteScrollContent) InfiniteScrollContent: InfiniteScrollContent;
swiperImg;
swiperArticle;
//所属板块类型:
//1党章党规,2系列讲话,3中央精神,4本市部署,5通知公告,6党建动态,7工作提示,8党务参考
//9廉政格言,10纪检提示,11风险排查,12警示教育,13支部活动,14党建联建,15结对帮扶
// tabsList = [
// {name: "党章党规", type: 1, index: 0},
// {name: "系列讲话", type: 2, index: 1},
// {name: "中央精神", type: 3, index: 2},
// {name: "本市部署", type: 4, index: 3}
// ];
{name: "最新", type: 0, index: 0},
{name: "系列讲话", type: 2, index: 1},
{name: "党章党规", type: 1, index: 2},
{name: "中央精神", type: 3, index: 3},
{name: "本市部署", type: 4, index: 4}
constructor(public navCtrl: NavController, public tts: TextToSpeech, public datePipe: DatePipe,
public appService: AppService, public http: Http, public storage: Storage,
this.tabSer.getUserIntegral().subscribe(
(res) => {
this.mineInfo = res.data;
this.username = this.mineInfo.username.slice(-2);
}
)
console.log(this.tabsParent.nativeElement.children[0].children[0].offsetWidth);
this.spanWidth = this.tabsParent.nativeElement.children[0].children[0].offsetWidth; //文字宽度
this.tips.nativeElement.style.width = this.spanWidth + 'px';
this.tips1.nativeElement.style.width = this.spanWidth + 'px';
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
//初始化swiper
initSwiper() {
console.log('initSwiper')
let that = this;
that.swiperImg = new Swiper('#swiper-container', {
speed: 1000,
autoplay:{
delay: 3000,
disableOnInteraction: false,
},//可选选项,自动滑动
observer: true,
observeParents: true,
observeSlideChildren:true,
loop: true,
on: {
slideChangeTransitionEnd: function () {
console.log(this.activeIndex);
that.slideIndex = this.activeIndex +1;
that.slideTitle = that.slidersItems[this.activeIndex].title;
that.swiperImg.update();
},
}
});
this.swiperArticle = new Swiper('#swiper-article', {
slidesPerView: 1,
speed: 1000,
autoplay: false,//可选选项,自动滑动
observer: true,
observeParents: true,
observeSlideChildren:true,
loop: false,
on: {
slideChangeTransitionEnd: function () {
that.swiperArticle.update();
that.change(that.tabsList[this.activeIndex]);
},
}
})
}
this.content.ionScroll.subscribe(($event) => {
this.zone.run(() => {
if (this.content.scrollTop > height) {
this.pageNum = 1;
this.loadMore = true;
this.index = item.index;
// 自身div的一半 - 滑块的一半
this.tips.nativeElement.style.left = this.itemWidth * (this.index) + (this.itemWidth - this.spanWidth) / 2 + 'px';
this.tips1.nativeElement.style.left = this.itemWidth * (this.index) + (this.itemWidth - this.spanWidth) / 2 + 'px';
this.InfiniteScrollContent.inf.enable(true);
arr.forEach(e => {
if (e.attachments.length > 0) {
e.imgUrl = e.attachments[0].path;
}
});
// let index = this.slides.toArray()[1].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;
//获取轮播图
getBanner() {
const data = {
isRecent: 0,
obj: {
resourceType: 2,
isRecommend: 1,
}
};
this.tabsSer.stuffPage(data).subscribe(
(res) => {
if (res.data.list.length > 0) {
res.data.list.forEach(e => {
if (e.attachments.length > 0) {
e.imgUrl = e.attachments[0].path;
}
})
}
this.slidersItems = res.data.list;
}
)
}
const nowDay = this.datePipe.transform(new Date(), 'yyyy-MM-dd');
localStorage.setItem('partyBir', nowDay);
let child_div = this.verticaLamp.nativeElement.children;
const scrollWidth = this.verticaLamp.nativeElement.offsetWidth;
const textWidth = child_div[0].offsetWidth;
i = scrollWidth;
}
child_div[0].style.left = i + 'px';
if (totalTime < 0) {
this.signText = '';
window.clearInterval(clock);
this.disabledClick = false;
}
}, 1000)
}
//查看文章详情
goToDetail(item) {
this.navCtrl.push(StuffDetailPage, {
id: item.id
})
}
// const index = this.slides.toArray()[0].realIndex;
// if (this.slidersItems[index].plateType == 20) return false;
// this.navCtrl.push(StuffDetailPage, {
// id: this.slidersItems[index].id
// })
if (this.totalNum < this.slideList[this.index].length + 1) {
console.log('没有数据了');
this.loadMore = false;
e.enable(false);
return false;
// this.renderer.setStyle(this.infiniteScrollContentEle.nativeElement, 'height', '60px');
this.tabsSer.stuffPage(data).subscribe(
(res) => {
let arr = res.data.list;
arr.forEach(e => {
if (e.attachments.length > 0) {
e.imgUrl = e.attachments[0].path;
}
this.slideList[this.index].push(e);
});
}
// this.renderer.setStyle(this.infiniteScrollContentEle.nativeElement, 'height', '0px');
arr.forEach(e => {
if (e.attachments.length > 0) {
e.imgUrl = e.attachments[0].path;
}
});
}
this.isSign = false;
}
stop(e) {
e.stopPropagation();
}