Newer
Older
import {Component, ViewChild} from '@angular/core';
import {NavController, IonicPage, Slides} from 'ionic-angular';
import {ActivityListPage} from "../../home/activity/activityList/activityList";
import {Http, Response} from '@angular/http';
import {AppService, AppGlobal} from '../../../service/http.service';
import {Calendar} from '@ionic-native/calendar';
import {ActivityApplyPage} from "../../home/activity/activityApply/activityApply";
import {ActivityDetailPage} from "../../home/activity/activityDetail/activityDetail";
import {OutGoingReportPage} from "../../home/report/outGoingReport/outGoingReport";
import {AnnouncementPage} from '../../home/announcement/announcementList/announcement';
import {Storage} from '@ionic/storage';
import {OutGoingReportEditPage} from "../../home/report/outGoingReportEdit/outGoingReportEdit";
import {AnnouncementViewPage} from '../../home/announcement/announcementView/announcementView';
import {CalendarComponentOptions, DayConfig} from "ion2-calendar";
import {NoticePage} from "../notice/notice";
import {monthCh, weekDay} from "../../../app/main";
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";
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
@ViewChild(Slides) slides: Slides;
hasNew = {
activity: 0,
notice: 0,
premanager: 0,
message: 0,
test: 0,
};
//日历
date: string;
type: 'string';
optionsMulti: CalendarComponentOptions;
newArr: DayConfig[] = [];
//未读通知
NoticeNotreadCount = '0';
//尚未报备
PremanagerNotdoCount = '0';
//是否显示正在开发中
isWait: boolean = false;
slidersItems = [];
noticeList = [];
picture: string = AppGlobal.picture;
operations: Array<string>;
//当前年份
year;
//当前月份
month;
//当前第几周
weekNo;
noticeTips;
role;
noReadNum;
constructor(public navCtrl: NavController, public tts: TextToSpeech,
public commonSer: CommonService, public emitSer: EmitService,
public appService: AppService, public http: Http, private calendar: Calendar, public storage: Storage,
public badge: Badge, public tabsSer: TabsService) {
// 接收发射过来的数据
this.emitSer.eventEmit.subscribe((value: any) => {
if (!isNaN(value)) {
this.noReadNum = value;
}
});
ngOnInit(): void {
this.appService.ObserverHttpGet("/wisdomgroup/modules/message/findAllActivityForAppWithXQ", null).subscribe((res: Response) => {
this.noticeList = res.json().slice(0, 2);
}, error => {
this.appService.alert('系统错误!');
});
}
ionViewDidEnter() {
//获取权限
this.getRole();
//获取消息数量
this.getNewCount();
//获取日历
this.getCalendar();
ionViewWillEnter() {
this.slidersItems = [];
this.getHasNew();
//初始化日期
this.appService.ObserverHttpGet("/wisdomgroup/modules/common/file/getBanner", {}).subscribe((res: Response) => {
this.slidersItems = res.json();
}, error => {
ionViewDidLeave() {
this.newArr = [];
if (this.slides) {
this.slides.stopAutoplay();
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
//获取权限
getRole() {
this.tabsSer.getRoles().subscribe(
(res) => {
this.role = res
},
error => {
this.appService.alert('系统错误!');
}
)
}
wait() {
this.isWait = true;
}
cancleWait() {
this.isWait = false;
}
go(item) {
if (item.type == 1) {
this.getActivity(item.id);
} else if (item.type == 2) {
this.getPremanager(item.id);
} else if (item.type == 3) {
this.navCtrl.push("AnnouncementViewPage", {
id: item.id
});
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
}
//获取活动ById
getActivity(id) {
this.appService.ObserverHttpPost("/wisdomgroup/modules/activity/appFindById", {id: id})
.toPromise()
.then(res => {
let activity = res.json();
this.navCtrl.push('ActivityDetailPage', {id: activity.id});
})
.catch(error => {
});
}
//获取报备
getPremanager(id) {
this.storage.remove("temp_userpre");
this.storage.remove("managerId");
this.storage.remove("city");
this.storage.remove("cityList");
this.storage.remove("person");
this.appService.ObserverHttpPost("/wisdomgroup/modules/premanager/findById", {id: id}).subscribe((res) => {
let premanager = res.json();
this.storage.set("premanager", premanager);
this.navCtrl.push("OutGoingReportEditPage");
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
}
//外出报备跳转
goOutGoingReportAboutAll() {
this.navCtrl.push("OutGoingReportPage", {
type: 1
});
}
//前往
goTo(page) {
this.navCtrl.push(page);
}
readBook() {
this.tts.speak({text: "你好,欢迎,向前走10米,路口右转,执行10米,在左转", locale: 'zh-CN'})
.then(() => {
console.log('Success');
}).catch((reason: any) => {
console.error('Error', reason);
});
}
/**
* 获取是否有新的信息
*/
getHasNew() {
//获取是否有新活动
this.tabsSer.hasNewActivity().subscribe(
(res) => {
this.hasNew.activity = res;
}
)
//获取是否有新通知
this.tabsSer.hasNewNotice().subscribe(
(res) => {
this.hasNew.notice = res;
}
)
//获取是否有新通知
this.tabsSer.hasNewMessage().subscribe(
(res) => {
this.hasNew.message = res;
}
)
//获取是否有新报备
this.tabsSer.hasNewPremanager().subscribe(
(res) => {
this.hasNew.premanager = res;
}
)
//获取是否有新问卷
this.tabsSer.hasNewTest().subscribe(
(res) => {
this.hasNew.test = res;
}
)
}
//获取所有未读消息的数量--->设置角标
getNewCount() {
this.appService.ObserverHttpGetData('/wisdomgroup/modules/activity/hasNewCount', null)
.subscribe((res) => {
let data = Number(res.json());
this.noticeTips = data;
console.log(this.noticeTips)
if (data > 0) {
this.badge.set(data);
} else {
this.badge.clear();
}
//日历
getCalendar() {
this.newArr = [];
let date = new Date();
let year = date.getFullYear();
let month = date.getMonth() + 1;
//2.参加活动日期
this.tabsSer.appOrderCal().subscribe(
(order) => {
order.forEach(event => {
this.newArr.push({
date: new Date(event.batch.batchGoDate),
disable: true,
cssClass: 'dayOff2'
})
this.tabsSer.appPreCal().subscribe(
(pre) => {
pre.forEach(event => {
this.newArr.push({
date: new Date(event.formshTime),
disable: true,
cssClass: 'dayOff4'
})
});
this.loadEvent(year, month);
}
)
}
);
}
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
loadEvent(year, month) {
//5.获取每月值班信息
const data = {
date: year + '/' + month + '/01'
};
this.tabsSer.getMyScheduleOnMonth(data).subscribe(
(schedule) => {
for (let i = 0; i < schedule.length; i++) {
const ev = {
date: new Date(schedule[i].dutyDate),
disable: true,
cssClass: 'dayOff3'
};
this.newArr.push(ev);
}
this.tabsSer.getFestivalAboutMonth(data).subscribe(
(festival) => {
festival.forEach(event => {
const data = {
date: new Date(event.date),
disable: true,
cssClass: 'dayOff1'
};
this.newArr.push(data);
});
this.setCalendar(year, month);
}
)
}
)
}
setCalendar(year, month) {
let date = new Date();
//4.每月的周末
let d = new Date(year, month, 0).getDate();
for (let i = 1; i < d + 1; i++) {
date.setFullYear(year, month - 1, i);
let day = date.getDay();
if (day == 6 || day == 0) {
const data = {
date: new Date(year, month - 1, i),
this.optionsMulti = {
pickMode: 'multi',
monthFormat: 'YYYY 年 MM 月 ',
weekdays: weekDay,
monthPickerFormat: monthCh,
weekStart: 0,
disableWeeks: [0, 1, 2, 3, 4, 5, 6],
daysConfig: this.newArr
//月份改变
monChange(e) {
this.loadEvent(e.newMonth.years, e.newMonth.months);
}
id: number;
title: string;
date: number;
isToday: boolean = false;