Commit beda5eeb authored by wangqinghua's avatar wangqinghua

component组件

parent a2163a48
<?xml version='1.0' encoding='utf-8'?>
<widget id="io.ionic.partyCloud.starter.test" version="0.1.6" 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.1.9" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>部机关党建云(测试)</name>
<description>An awesome Ionic/Cordova app.</description>
<author email="hi@ionicframework" href="http://ionicframework.com/">Ionic Framework Team</author>
......
<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="105" android:versionName="0.1.5" package="io.ionic.partyCloud.starter.test" xmlns:android="http://schemas.android.com/apk/res/android">
<manifest android:hardwareAccelerated="true" android:versionCode="109" android:versionName="0.1.9" package="io.ionic.partyCloud.starter.test" xmlns:android="http://schemas.android.com/apk/res/android">
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
<application android:hardwareAccelerated="true" android:icon="@mipmap/icon" android:label="@string/app_name" android:supportsRtl="true">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
......
......@@ -109,10 +109,12 @@ export class MyApp {
.subscribe((res: Response) => {
let data = res.json();
let num = 0;
data.forEach(e=>{
if(e.isRead == 0) num++;
})
this.emitSer.eventEmit.emit(num);
if(data.length > 0){
data.forEach(e=>{
if(e.isRead == 0) num++;
})
this.emitSer.eventEmit.emit(num);
}
}, error => {
}
);
......
import { NgModule } from '@angular/core';
import { SlideComponent } from './slide/slide';
import {IonicPageModule} from "ionic-angular";
@NgModule({
declarations: [SlideComponent],
imports: [
IonicPageModule
],
exports: [SlideComponent]
})
export class ComponentsModule {}
<!-- Generated template for the SlideComponent component -->
<div 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 id="tips"></span>
</div>
</div>
<div class="main-news">
<ng-container *ngFor="let new of newList;">
<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>
slide {
.news-content{
margin-top: 1.2rem;
}
//新闻区
.main-news {
padding: 0 1rem;
.news-item {
padding: .8rem 0;
.news-left {
display: flex;
flex-flow: row wrap;
min-height: 100%;
.news-title {
align-self: flex-start;
font-weight: bold;
width: 100%;
margin-bottom: .6rem;
}
.news-end {
//align-self: flex-end;
color: #999999;
span {
margin-right: 1rem;
}
}
}
.news-right {
text-align: center;
img {
border-radius: .5rem;
height: 60px;
}
}
}
.news-item + .news-item {
border-top: 1px solid #eeeeee;
}
}
}
import {Component, ElementRef, ViewChild} from '@angular/core';
import {TabsService} from "../../pages/tabs/tabs.service";
import {AppGlobal} from "../../service/http.service";
import {StuffDetailPage} from "../../pages/home-pages/stuff-detail/stuff-detail";
import {NavController} from "ionic-angular";
@Component({
selector: 'slide',
templateUrl: 'slide.html'
})
export class SlideComponent {
@ViewChild('tips') tips: ElementRef;
@ViewChild('tabSpan') tabSpan: ElementRef;
text: string;
index = 0;
newList = [];
picture: string = AppGlobal.domain + '/wisdomgroup';
tabsList = [
{name: "系列讲话", type: 2, index: 0},
{name: "党章党规", type: 1, index: 1},
{name: "中央精神", type: 3, index: 2},
{name: "本市部署", type: 4, index: 3}
];
constructor(private tabsSer:TabsService,private navCtrl:NavController) {
}
ionViewDidLoad(){
this.change(this.tabsList[0]);
}
//所属板块类型(1党规党章,2系列讲话,3中央精神,4本市部署,5通知公告,6党建动态,7工作提示,
// * 8党务参考,9廉政格言,10纪检提示,11风险排查,12警示教育,13支部活动,14党建联建,15结对帮扶)
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';
// 自身div的一半 - 滑块的一半
this.tips.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;
}
})
}
)
}
//查看文章详情
goToDetail(item) {
this.navCtrl.push(StuffDetailPage, {
id: item.id
})
}
}
......@@ -48,43 +48,8 @@
<p class="slides-title">{{slideTitle}} <span class="main-color" float-end>1<span
style="font-size: 1.5rem;font-weight: 400;">/{{slidersItems.length}}</span></span></p>
</div>
<div 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 id="tips"></span>
</div>
</div>
<div class="main-news">
<ng-container *ngFor="let new of newList;">
<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>
<!--新闻-->
<slide></slide>
</ion-content>
<!--政治生日-->
<div *ngIf="isBir" class="signMask">
......
......@@ -4,6 +4,7 @@ import { IonicPageModule} from 'ionic-angular';
import { HomePage } from './home';
import { CalendarModule } from "ion2-calendar";
import {DirectivesModule} from "../../../directives/directives.module";
import {ComponentsModule} from "../../../components/components.module";
@NgModule({
......@@ -13,7 +14,8 @@ import {DirectivesModule} from "../../../directives/directives.module";
imports: [
IonicPageModule.forChild(HomePage),
CalendarModule,
DirectivesModule
DirectivesModule,
ComponentsModule
],
entryComponents: [
HomePage,
......
......@@ -131,51 +131,6 @@ page-home {
height: 54px;
}
.news-content{
margin-top: 1.2rem;
}
//新闻区
.main-news {
padding: 0 1rem;
.news-item {
padding: .8rem 0;
.news-left {
display: flex;
flex-flow: row wrap;
min-height: 100%;
.news-title {
align-self: flex-start;
font-weight: bold;
width: 100%;
margin-bottom: .6rem;
}
.news-end {
//align-self: flex-end;
color: #999999;
span {
margin-right: 1rem;
}
}
}
.news-right {
text-align: center;
img {
border-radius: .5rem;
height: 60px;
}
}
}
.news-item + .news-item {
border-top: 1px solid #eeeeee;
}
}
.mask-button {
border-top: 1px solid #eeeeee;
text-align: center;
......
......@@ -22,28 +22,17 @@ import {DatePipe} from "@angular/common";
export class HomePage {
@ViewChild(Slides) slides: Slides;
@ViewChild(Content) content: Content;
@ViewChild('tips') tips: ElementRef;
@ViewChild('verticaLamp') verticaLamp: ElementRef;
@ViewChild('tabSpan') tabSpan: ElementRef;
@ViewChild('topHeight') topHeight: ElementRef;
@ViewChild('homeMiddleTips') homeMiddleTips: ElementRef;
picture: string = AppGlobal.domain + '/wisdomgroup';
slidersItems = [];
//所属板块类型:
//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}
];
index = 0;
picture: string = AppGlobal.domain + '/wisdomgroup';
isSign = false; //签到弹窗
isBir = false; //政治生日弹窗
newList = [];
noReadNum;
signObj = {
......@@ -78,25 +67,8 @@ export class HomePage {
}
ionViewDidLoad() {
this.change(this.tabsList[0]);
this.getBanner();
this.getInfo();
//滑动监控
this.scrollHtml();
}
scrollHtml() {
this.content.ionScroll.subscribe(
($event) => {
this.ngZone.run(() => {
if ($event.scrollTop > 300) {
console.log($event.scrollTop);
console.log(this.topHeight);
}
})
}
)
}
//获取轮播图
......@@ -136,16 +108,25 @@ export class HomePage {
this.tabsSer.getInfo(userid).subscribe(
(res) => {
this.partyObj = res.apiResult.data;
this.isBir = true;
//获取是否展示过政治生日
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;
}
}
);
})
}
//关闭弹窗 开启跑马灯
start() {
const nowDay = this.datePipe.transform( new Date(),'yyyy-MM-dd' );
localStorage.setItem('partyBir',nowDay);
this.isBir = false;
this.homeMiddleTips.nativeElement.style.height = "80px";
this.homeMiddleTips.nativeElement.style.padding = "1rem";
......@@ -163,36 +144,6 @@ export class HomePage {
},20)
}
//所属板块类型(1党规党章,2系列讲话,3中央精神,4本市部署,5通知公告,6党建动态,7工作提示,
// * 8党务参考,9廉政格言,10纪检提示,11风险排查,12警示教育,13支部活动,14党建联建,15结对帮扶)
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';
// 自身div的一半 - 滑块的一半
this.tips.nativeElement.style.left = itemWidth * (index) + (itemWidth - spanWidth) / 2 + 'px';
this.index = index;
const data = {
pageSize: 1,
pageCount: 100,
obj: {
'plateType': index,
'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() {
this.tabsSer.sign().subscribe(
......@@ -200,6 +151,7 @@ export class HomePage {
this.isSign = false;
if (res.errcode == '1000') {
this.commonSer.toast('签到成功');
this.signObj.isSign = 'yes';
} else {
this.commonSer.toast(res.errmsg);
}
......@@ -223,12 +175,7 @@ export class HomePage {
}, 1000)
}
//查看文章详情
goToDetail(item) {
this.navCtrl.push(StuffDetailPage, {
id: item.id
})
}
//前往搜索页面
goToSearch() {
......
......@@ -15,8 +15,8 @@ export class AppGlobal {
//接口基地址
// static domain = "http://101.89.112.92:80"; //正式环境
// static domain = "http://180.168.156.212:2931"; //测试环境
static domain = "http://47.103.35.216:8080"; //阿里云地址
// static domain = ""; //本地环境
// static domain = "http://47.103.35.216:8080"; //阿里云地址
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