Newer
Older
import {Component, ElementRef, ViewChild, NgZone, Renderer2, Input, ViewChildren, QueryList} from '@angular/core';
import {
NavController,
IonicPage,
Slides,
Content,
InfiniteScrollContent,
FabList,
FabContainer,
ModalController
} from 'ionic-angular';
import {Http, Response} from '@angular/http';
import {AppService, AppGlobal} from '../../../service/http.service';
import {Storage} from '@ionic/storage';
import {Badge} from '@ionic-native/badge';
import {TabsService} from "../tabs.service";
import {CommonService} from "../../../provide/common.service";
import {StuffDetailPage} from "../../home-pages/stuff-detail/stuff-detail";
@IonicPage()
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
@ViewChild('infiniteScrollContentEle') infiniteScrollContentEle: ElementRef;
@ViewChild(InfiniteScrollContent) InfiniteScrollContent: InfiniteScrollContent;
swiperImg;
swiperArticle;
{name: "系列讲话", type: 2, index: 0},
{name: "党章党规", type: 1, index: 1},
{name: "中央精神", type: 3, index: 2},
{name: "本市部署", type: 4, index: 3},
{name: "评论解读", type: 17, index: 4},
public zone: NgZone, public tabSer: TabsService, private appMainSer: AppMainService,
public appService: AppService, public http: Http, public storage: Storage,
this.appMainSer.readInfo.subscribe(value => {
this.noReadNum = value;
})
this.toRight = false;
} else {
this.toRight = true;
}
}
this.tabSer.getUserIntegral().subscribe(
(res) => {
this.mineInfo = res.data;
this.username = this.mineInfo.username.slice(-2);
const htmlFontSize = getComputedStyle(window.document.documentElement)['font-size'];
this.itemWidth = htmlFontSize.split("px")[0] * 8;
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';
//初始化swiper
initSwiper() {
let that = this;
that.swiperImg = new Swiper('#swiper-container', {
speed: 1000,
delay: 3000,
disableOnInteraction: false,
},//可选选项,自动滑动
observer: true,
if (that.swiperImg) {
that.slideIndex = this.activeIndex + 1;
that.slideTitle = that.slidersItems[this.activeIndex].title;
that.swiperImg.update();
}
click: function () {
const item = that.slidersItems[this.activeIndex];
if (item.plateType == 20) return false;
that.navCtrl.push(StuffDetailPage, {
id: item.id
})
},
}
});
this.swiperArticle = new Swiper('#swiper-article', {
slidesPerView: 1,
speed: 1000,
autoplay: false,//可选选项,自动滑动
observer: true,
observeParents: 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) {
// 自身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';
arr.forEach(e => {
if (e.attachments.length > 0) {
e.imgUrl = e.attachments[0].path;
}
});
this.getMore(res);
}
)
}
//加载更多
getMore(res) {
const totalNum: number = res.data.total;
obj: {
'plateType': this.plateType,
'resourceType': 1
}
};
this.tabsSer.stuffPage(data).subscribe(
(res) => {
res.data.list.splice(0, 10);
res.data.list.forEach(e => {
if (e.attachments.length > 0) {
e.imgUrl = e.attachments[0].path;
}
this.slideList[this.index].push(e);
});
//获取党员生日
getInfo() {
this.storage.get("userLoginInfo").then((value) => {
let userid = value.userid;
this.tabsSer.getInfo(userid).subscribe(
(res) => {
if (res.apiResult.data) { //党员展示政治生日
this.partyObj = res.apiResult.data;
//获取是否展示过政治生日
const nowDay = this.datePipe.transform(new Date(), 'yyyy-MM-dd');
const partyBir = localStorage.getItem('partyBir');
setTimeout(() => {
this.start();
this.isBir = false;
}, 500)
} else {
this.isBir = true;
}
} else { //非党员不展示政治生日
this.isBir = false;
"resourceType": 2, //1标题图片,2推荐轮播图,3视频
"isRecommend": 1, //推荐(1是0否)
}
};
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;
this.slideTitle = this.slidersItems[this.slidersItems.length - 1].title;
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;
let i = scrollWidth;
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
})
}
arr.forEach(e => {
if (e.attachments.length > 0) {
e.imgUrl = e.attachments[0].path;
}
});
}
this.isSign = false;
}
stop(e) {
e.stopPropagation();
}
let modal = this.modalCtrl.create(FilterComponent, {
list: this.tabsList,
type: this.plateType,
title: '我的频道',
desc:'点击进入我的频道'
}, {
enterAnimation: 'modal-from-right-enter',
leaveAnimation: 'modal-from-right-leave'
});
modal.onDidDismiss(data => {
if (data) {
this.change(data)
}
});
modal.present();
}