Commit eb76b5e3 authored by wangqinghua's avatar wangqinghua

push

parent ae1171e4
......@@ -45,7 +45,7 @@ export class MyApp {
console.log('getVersionNumber:' + err);
});
//log角标数目显示
badge.set(10);
badge.set(2);
});
}
}
<ion-header>
<ion-toolbar>
<div class="searchToolBar">
<!-- <button ion-button clear small navPop style="padding: 0;">
<img class="back-btn" src="./assets/imgs/back.png" />
</button> -->
<ion-title text-center>
用户登录
</ion-title>
......
......@@ -159,7 +159,6 @@ export class HomePage {
ionViewWillEnter() {
//初始化日期
this.initDate();
this.getHasNewActivity();
this.getHasNewNotice();
this.getHasNewPremanager();
......@@ -185,7 +184,6 @@ export class HomePage {
});
//初始化操作记录
this.initMineOperationInfo();
}
goMyActivity() {
......@@ -245,17 +243,6 @@ export class HomePage {
});
}
//获取公告
// getNotice(id) {
// this.appService.ObserverHttpPost("/wisdomgroup/modules/notice/getNoticeById", { id: id })
// .toPromise()
// .then(res => {
// let notice = res.json();
// })
// .catch(error => {
// });
// }
//获取报备
getPremanager(id) {
......@@ -323,103 +310,8 @@ export class HomePage {
});
}
//获取当前是第几周
getWeekOfYear() {
var today = new Date();
var firstDay = new Date(today.getFullYear(), 0, 1);
var dayOfWeek = firstDay.getDay();
var spendDay = 1;
if (dayOfWeek != 0) {
spendDay = 7 - dayOfWeek + 1;
}
firstDay = new Date(today.getFullYear(), 0, 1 + spendDay);
var d = Math.ceil((today.valueOf() - firstDay.valueOf()) / 86400000);
var result = Math.ceil(d / 7);
return result + 1;
};
//初始化日历
initDate() {
this.weekNo = this.getWeekOfYear();
var date = new Date();
this.year = date.getFullYear();
this.month = date.getMonth() + 1;
//初始化周
var day = date.getDay();
var today = date.getDate();
for (let item of this.week) {
var count = item.id - day;
var now = new Date();
now.setTime(date.getTime() + count * 24 * 60 * 60 * 1000);
item.date = now.getDate();
if (count == 0) {
item.isToday = true;
}
}
}
//创建日历
myCalendar() {
this.calendar.createCalendar('日历').then(
(msg) => { console.log(msg); },
(err) => { console.log(err); }
);
this.calendar.openCalendar(new Date()).then(
(msg) => { console.log(msg); },
(err) => { console.log(err); }
);
}
///操作记录
initMineOperationInfo() {
let order = this.appService.ObserverHttpPost("/wisdomgroup/opertion/searchOperationInfo", { "P_pageNumber": 0, "P_pageSize": 3 })
.subscribe((res: Response) => {
let data = res.json();
this.operations = data.list;
console.log(JSON.stringify(this.operations));
this.operations.forEach(element => {
let timegap = Date.parse(new Date().toString()) - Date.parse(element["opertionTime"].toString());
let timegapvalue = this.timeshift(timegap);
element["timegapvalue"] = timegapvalue;
//显示25字
let content = element["opertionContent"];
if (content.length > 25) {
element["opertionContent"] = content.substr(0, 25) + "...";
}
});
}, error => {
this.appService.alert('网络异常!');
}
);
}
timeshift(timegap: number): string {
let result: string;
let nd = 1000 * 24 * 60 * 60;//一天的毫秒数
let nh = 1000 * 60 * 60;//一小时的毫秒数
let nm = 1000 * 60;//一分钟的毫秒数
let ns = 1000;//一秒钟的毫秒数
let day = Math.round(timegap / nd);//计算差多少天
let hour = Math.round(timegap % nd / nh);//计算差多少小时
let min = Math.round(timegap % nd % nh / nm);//计算差多少分钟
let sec = Math.round(timegap % nd % nh % nm / ns);//计算差多少秒//输出结果
console.log("时间相差:" + day + "天" + hour + "小时" + min + "分钟" + sec + "秒。");
if (day > 0) {
result = day + "天前";
} else if (hour > 0) {
result = hour + "小时前";
} else if (min > 0) {
result = min + "分钟前";
} else {
result = sec + "几秒前";
}
//result = day+"天"+hour+"小时"+min+"分钟"+sec+"秒"+"前";
return result;
}
//消息通知
gotoNotice(){
......
<ion-header>
<ion-toolbar>
<div class="searchToolBar">
<button ion-button clear small navPop style="padding: 0;">
<img class="back-btn" src="./assets/imgs/back.png" />
</button>
<ion-navbar>
<ion-title text-center>设置</ion-title>
</div>
</ion-toolbar>
</ion-navbar>
</ion-header>
<ion-content>
<ion-list>
<ion-item>
<ion-label>是否接受推送消息</ion-label>
<ion-toggle checked="false"></ion-toggle>
<ion-toggle [(ngModel)]="pusNumber" (ionChange)="savePush()"></ion-toggle>
</ion-item>
<ion-item>
<span>当前版本</span>
<span float-right>{{version}}</span>
</ion-item>
</ion-list>
<button class="submit-btn submit" (click)="loginOut()">退出</button>
<button class="submit-btn submit" (click)="logoutApp()">退出</button>
</ion-content>
\ No newline at end of file
......@@ -3,6 +3,8 @@ import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { AppService } from '../../service/appHttpService';
import { AppVersion } from '@ionic-native/app-version';
import { AppUpdateService } from '../../service/appUpdateService';
import { Storage } from "@ionic/storage";
import {LoginPage} from "../login/login";
@IonicPage()
@Component({
......@@ -14,21 +16,41 @@ export class VersionPage {
version: string = '';
latestVersion: string = '';
isLatest:boolean = true;
pusNumber:boolean;
constructor(
public navCtrl: NavController,
public navParams: NavParams,
public appService:AppService,
private appUpdateService: AppUpdateService,
private appVersion: AppVersion
private appVersion: AppVersion,
private storage:Storage
) {
}
ionViewWillEnter() {
this.getversion();
this.getAppPush();
}
//获取推送开关
getAppPush(){
this.appService.ObserverHttpGet('/wisdomgroup/modules/common/file/getAppPush',null)
.subscribe(
(res)=>{
this.pusNumber = res.json();
}
)
}
//保存推送开关
savePush(){
this.appService.ObserverHttpGetAdd('/wisdomgroup/modules/common/file/addAppPush/',this.pusNumber)
.subscribe(
(res)=>{}
)
}
//获取最新版本信息
getversion() {
//检测是否需要更新
......@@ -53,8 +75,19 @@ export class VersionPage {
this.appUpdateService.downloadApp("/wisdomgroup/app/download");
}
loginOut(){
//后台退出
logoutApp() {
let length = this.navCtrl.length();
this.navCtrl.remove(length);
this.storage.clear();
this.appService.ObserverHttpGet("/wisdomgroup/app/logout", null)
.subscribe((res: Response) => {
let data = res.json();
this.navCtrl.push('LoginPage');
}, error => {
this.appService.alert('网络异常!');
}
);
}
}
......@@ -82,6 +82,12 @@ export class AppService {
return this.http.get(url, params) //本地
}
//get请求
ObserverHttpGetAdd(url, params): Observable<any> {
// return this.http.get(AppGlobal.domain+url+ params) //app
return this.http.get(url+ params) //本地
}
//get请求带?的
ObserverHttpGetOption(url, params): Observable<any> {
// return this.http.get(AppGlobal.domain+url,{params: params}); //app
......
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