Commit ee91e14d authored by wangqinghua's avatar wangqinghua

top置顶

parent a37b7ffa
<?xml version='1.0' encoding='utf-8'?> <?xml version='1.0' encoding='utf-8'?>
<widget id="io.ionic.partyCloud.starter.test" version="0.1.9" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"> <widget id="io.ionic.partyCloud.starter.test" version="0.2.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>部机关党建云(测试)</name> <name>部机关党建云(测试)</name>
<description>An awesome Ionic/Cordova app.</description> <description>An awesome Ionic/Cordova app.</description>
<author email="hi@ionicframework" href="http://ionicframework.com/">Ionic Framework Team</author> <author email="hi@ionicframework" href="http://ionicframework.com/">Ionic Framework Team</author>
......
import {AfterViewInit, Component, ElementRef, NgZone, ViewChild} from '@angular/core'; import {AfterViewInit, Component, ElementRef, NgZone, ViewChild} from '@angular/core';
import {Content, Slides} from "ionic-angular"; import {App, Content, NavController, Slides} from "ionic-angular";
import {TabsService} from "../../pages/tabs/tabs.service"; import {TabsService} from "../../pages/tabs/tabs.service";
import {AppGlobal} from "../../service/http.service"; import {AppGlobal} from "../../service/http.service";
import {CommonService} from "../../provide/common.service"; import {CommonService} from "../../provide/common.service";
import {StuffDetailPage} from "../../pages/home-pages/stuff-detail/stuff-detail";
@Component({ @Component({
selector: 'slide-list', selector: 'slide-list',
...@@ -15,6 +16,7 @@ export class SlideListComponent implements AfterViewInit { ...@@ -15,6 +16,7 @@ export class SlideListComponent implements AfterViewInit {
@ViewChild('tips1') tips1: ElementRef; @ViewChild('tips1') tips1: ElementRef;
isScroll = false; isScroll = false;
private nav:NavController;
//所属板块类型: //所属板块类型:
//1党章党规,2系列讲话,3中央精神,4本市部署,5通知公告,6党建动态,7工作提示,8党务参考 //1党章党规,2系列讲话,3中央精神,4本市部署,5通知公告,6党建动态,7工作提示,8党务参考
//9廉政格言,10纪检提示,11风险排查,12警示教育,13支部活动,14党建联建,15结对帮扶 //9廉政格言,10纪检提示,11风险排查,12警示教育,13支部活动,14党建联建,15结对帮扶
...@@ -31,8 +33,9 @@ export class SlideListComponent implements AfterViewInit { ...@@ -31,8 +33,9 @@ export class SlideListComponent implements AfterViewInit {
constructor(private tabsSer: TabsService,public zone:NgZone, constructor(private tabsSer: TabsService,public zone:NgZone,
private commonSer:CommonService) { private commonSer:CommonService,private app:App) {
this.slideList.length = 4; this.slideList.length = 4;
this.nav = this.app.getRootNav();
} }
ngAfterViewInit(): void { ngAfterViewInit(): void {
...@@ -50,6 +53,7 @@ export class SlideListComponent implements AfterViewInit { ...@@ -50,6 +53,7 @@ export class SlideListComponent implements AfterViewInit {
this.tips1.nativeElement.style.left = itemWidth * (index) + (itemWidth - spanWidth) / 2 + 'px'; this.tips1.nativeElement.style.left = itemWidth * (index) + (itemWidth - spanWidth) / 2 + 'px';
this.index = index; this.index = index;
this.plateType = item.type; this.plateType = item.type;
console.log(this.plateType)
const data = { const data = {
pageSize: 1, pageSize: 1,
pageCount: 100, pageCount: 100,
...@@ -85,12 +89,16 @@ export class SlideListComponent implements AfterViewInit { ...@@ -85,12 +89,16 @@ export class SlideListComponent implements AfterViewInit {
console.log(this.isScroll) console.log(this.isScroll)
} }
// //查看详情
goToDetail(item) { goToDetail(item) {
this.nav.push(StuffDetailPage, {
id: item.id
})
} }
//下拉刷新 //下拉刷新
refresh(e){ refresh(e){
console.log(this.plateType)
const data = { const data = {
pageSize: 1, pageSize: 1,
pageCount: 100, pageCount: 100,
......
import {AfterViewInit, Component, ElementRef, OnInit, ViewChild} from '@angular/core'; import {AfterViewInit, Component, ElementRef, OnInit, ViewChild} from '@angular/core';
import {TabsService} from "../../pages/tabs/tabs.service"; import {TabsService} from "../../pages/tabs/tabs.service";
import {AppGlobal} from "../../service/http.service"; import {AppGlobal} from "../../service/http.service";
import {Slides} from "ionic-angular"; import {App, NavController, Slides} from "ionic-angular";
// import {StuffDetailPage} from "../../pages/home-pages/stuff-detail/stuff-detail"; import {StuffDetailPage} from "../../pages/home-pages/stuff-detail/stuff-detail";
// import {NavController} from "ionic-angular";
@Component({ @Component({
selector: 'slide', selector: 'slide',
...@@ -15,10 +14,12 @@ export class SlideComponent implements AfterViewInit{ ...@@ -15,10 +14,12 @@ export class SlideComponent implements AfterViewInit{
picture: string = AppGlobal.domain + '/wisdomgroup'; picture: string = AppGlobal.domain + '/wisdomgroup';
slideTitle; slideTitle;
slidersItems = []; slidersItems = [];
private nav:NavController;
constructor(private tabsSer:TabsService, constructor(private tabsSer:TabsService,
// private navCtrl:NavController private app:App
) { ) {
this.nav = this.app.getRootNav();
} }
ngAfterViewInit(){ ngAfterViewInit(){
...@@ -57,8 +58,8 @@ export class SlideComponent implements AfterViewInit{ ...@@ -57,8 +58,8 @@ export class SlideComponent implements AfterViewInit{
//查看文章详情 //查看文章详情
goToDetail(item) { goToDetail(item) {
// this.navCtrl.push(StuffDetailPage, { this.nav.push(StuffDetailPage, {
// id: item.id id: item.id
// }) })
} }
} }
...@@ -47,7 +47,59 @@ ...@@ -47,7 +47,59 @@
<slide></slide> <slide></slide>
</div> </div>
<slide-list></slide-list> <!--true 隐藏 false 显示-->
<div [hidden]="isScroll" class="news-content">
<div class="tabs-parent">
<div *ngFor="let item of tabsList;let i = index" (click)="change(item)" class="tabs-children">
<span #tabSpan [style.color]="index == i ? '#e12724':''">{{item.name}}</span>
</div>
<span #tips class="tips"></span>
</div>
</div>
<!--固定 false -->
<div [hidden]="!isScroll" ion-fixed class="news-content ion-fixed">
<div class="tabs-parent">
<div *ngFor="let item of tabsList;let i = index" (click)="change(item)" class="tabs-children">
<span #tabSpan1 [style.color]="index == i ? '#e12724':''">{{item.name}}</span>
</div>
<span #tips1 class="tips"></span>
</div>
</div>
<ion-slides (ionSlideDidChange)="slideChange($event)" loop="true">
<ion-slide *ngFor="let item of slideList">
<div class="main-news">
<ng-container *ngFor="let new of item;">
<ng-container *ngIf="new.imgUrl">
<ion-row class="news-item" (click)="goToDetail(new)">
<ion-col col-8 class="news-left">
<p class="news-title">{{new.title}}</p>
<p class="news-end">
<span>{{new.source}}</span>
<span>{{new.publishTime | date:'yyyy-MM-dd'}}</span>
</p>
</ion-col>
<ion-col col-4 class="news-right">
<img src="{{picture+new.imgUrl}}">
</ion-col>
</ion-row>
</ng-container>
<ng-container *ngIf="!new.imgUrl">
<ion-row class="news-item" (click)="goToDetail(new)">
<ion-col col-12 class="news-left">
<p class="news-title">{{new.title}}</p>
<p class="news-end">
<span>{{new.source}}</span>
<span>{{new.publishTime | date:'yyyy-MM-dd'}}</span>
</p>
</ion-col>
</ion-row>
</ng-container>
</ng-container>
</div>
</ion-slide>
</ion-slides>
<!-- <ion-infinite-scroll (ionInfinite)="doInfinite($event)">--> <!-- <ion-infinite-scroll (ionInfinite)="doInfinite($event)">-->
<!-- <ion-infinite-scroll-content></ion-infinite-scroll-content>--> <!-- <ion-infinite-scroll-content></ion-infinite-scroll-content>-->
<!-- </ion-infinite-scroll>--> <!-- </ion-infinite-scroll>-->
......
...@@ -21,7 +21,7 @@ import {SlideListComponent} from "../../../components/slide-list/slide-list"; ...@@ -21,7 +21,7 @@ import {SlideListComponent} from "../../../components/slide-list/slide-list";
}) })
export class HomePage { export class HomePage {
@ViewChild(Slides) slides: Slides; @ViewChild(Slides) slides1: Slides;
@ViewChild(Content) content: Content; @ViewChild(Content) content: Content;
@ViewChild('tips') tips: ElementRef; @ViewChild('tips') tips: ElementRef;
@ViewChild('tips1') tips1: ElementRef; @ViewChild('tips1') tips1: ElementRef;
...@@ -42,12 +42,10 @@ export class HomePage { ...@@ -42,12 +42,10 @@ export class HomePage {
{name: "中央精神", type: 3, index: 2}, {name: "中央精神", type: 3, index: 2},
{name: "本市部署", type: 4, index: 3} {name: "本市部署", type: 4, index: 3}
]; ];
index = 0;
isSign = false; //签到弹窗 isSign = false; //签到弹窗
isBir = false; //政治生日弹窗 isBir = false; //政治生日弹窗
isScroll = false; //tabs置顶 isScroll = false; //tabs置顶
newList = [];
noReadNum; noReadNum;
signObj = { signObj = {
...@@ -58,6 +56,12 @@ export class HomePage { ...@@ -58,6 +56,12 @@ export class HomePage {
signText; //签到倒计时 signText; //签到倒计时
partyObj; //政治生日 partyObj; //政治生日
plateType;
index = 0;
slideList = [];
itemWidth ;
spanWidth ; //文字宽度
constructor(public navCtrl: NavController, public tts: TextToSpeech, public datePipe: DatePipe, constructor(public navCtrl: NavController, public tts: TextToSpeech, public datePipe: DatePipe,
...@@ -71,6 +75,7 @@ export class HomePage { ...@@ -71,6 +75,7 @@ export class HomePage {
this.noReadNum = value; this.noReadNum = value;
} }
}); });
this.slideList.length = 4;
} }
ionViewDidEnter(){ ionViewDidEnter(){
...@@ -82,28 +87,66 @@ export class HomePage { ...@@ -82,28 +87,66 @@ export class HomePage {
} }
ionViewDidLoad() { ionViewDidLoad() {
// this.change(this.tabsList[0]); 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]);
this.getInfo(); this.getInfo();
this.scrollHeight(); this.scrollHeight();
} }
scrollHeight(){ scrollHeight(){
const height = this.topHeight.nativeElement.offsetHeight + 80; const height = this.topHeight.nativeElement.offsetHeight + 54;
console.log(this.topHeight.nativeElement.offsetHeight)
this.content.ionScroll.subscribe(($event)=>{ this.content.ionScroll.subscribe(($event)=>{
this.zone.run(()=>{ this.zone.run(()=>{
// this.headerTag.nativeElement.
if(this.content.scrollTop > height){ if(this.content.scrollTop > height){
this.slideListCom.scroll('true'); this.isScroll = true;
}else{ }else{
this.slideListCom.scroll('false'); this.isScroll = false;
} }
this.content.resize();
}) })
}) })
} }
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])
}
//获取党员生日 //获取党员生日
...@@ -149,37 +192,6 @@ export class HomePage { ...@@ -149,37 +192,6 @@ export class HomePage {
},20) },20)
} }
change(item) {
const index = item.index;
let itemWidth = window.screen.width / 4;
let spanWidth = this.tabSpan.nativeElement.offsetWidth; //文字宽度
this.tips.nativeElement.style.width = this.tabSpan.nativeElement.offsetWidth + 'px';
this.tips1.nativeElement.style.width = this.tabSpan.nativeElement.offsetWidth + 'px';
// 自身div的一半 - 滑块的一半
this.tips.nativeElement.style.left = itemWidth * (index) + (itemWidth - spanWidth) / 2 + 'px';
this.tips1.nativeElement.style.left = itemWidth * (index) + (itemWidth - spanWidth) / 2 + 'px';
this.index = index;
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;
}
})
}
)
}
//签到接口 //签到接口
signUp() { signUp() {
this.tabsSer.sign().subscribe( this.tabsSer.sign().subscribe(
...@@ -233,8 +245,27 @@ export class HomePage { ...@@ -233,8 +245,27 @@ export class HomePage {
} }
doRefresh(e){ doRefresh(e){
this.slideListCom.refresh(e) const data = {
// e.complete(); 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();
}
)
} }
} }
...@@ -15,8 +15,8 @@ export class AppGlobal { ...@@ -15,8 +15,8 @@ export class AppGlobal {
//接口基地址 //接口基地址
// static domain = "http://101.89.112.92:80"; //正式环境 // static domain = "http://101.89.112.92:80"; //正式环境
// static domain = "http://180.168.156.212:2931"; //测试环境 // static domain = "http://180.168.156.212:2931"; //测试环境
// static domain = "http://47.103.35.216:8080"; //阿里云地址 static domain = "http://47.103.35.216:8080"; //阿里云地址
static domain = ""; //本地环境 // static domain = ""; //本地环境
//图片地址 //图片地址
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment