Newer
Older
import { App, NavController, AlertController, NavParams } from 'ionic-angular';
import { MyActivityListPage } from '../../myActivityList/myActivityList';
import { MyReportPage } from '../../myReport/myReport';
import { OperationListPage } from '../../operation-list/operation-list';
import { VersionPage } from '../../version/version';
import { Response } from '@angular/http';
import { Storage } from '@ionic/storage';
import { AppVersion } from '@ionic-native/app-version';
import { AppUpdateService } from '../../../service/appUpdateService';
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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
84
85
@Component({
selector: 'page-mine',
templateUrl: 'mine.html',
})
export class MinePage {
user: any;
orgName: '';
gender: object;
version: string = '';
isLatest:boolean = true;
constructor(public navCtrl: NavController,
private appCtrl: App,
private alertCtrl: AlertController,
public navParams: NavParams,
public appService: AppService,
public storage: Storage,
private appUpdateService: AppUpdateService,
private appVersion: AppVersion) {
this.orgNameInfo();
}
ionViewWillEnter() {
this.getversion();
}
orgNameInfo(): void {
this.user = this.storage.get("user").then((value) => {
this.user = value;
console.log(this.user);
console.log("id1:" + this.user.id);
this.gender = this.user.userDetail.user.gender;
console.log("gender:" + this.gender);
this.getOrgName(this.user.id, result => {
let data = result;
this.orgName = data["orgName"];
});
});
}
getOrgName(id, callback?): any {
this.appService.ObserverHttpPost("/wisdomgroup/app/getOrgName", { "userid": id })
.toPromise()
.then(res => {
var data = res.json();
callback(data == null ? "[]" : data);
})
.catch(error => {
});
}
personInfo() {
this.navCtrl.push("PersonInfoPage");
}
//我的活动
myActivityList() {
this.navCtrl.push("MyActivityListPage");
}
//我的报备
myReport() {
this.navCtrl.push("MyReportPage");
}
//操作记录
myOperationList() {
this.navCtrl.push("OperationListPage");
}
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
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
152
153
logout() {
this.alertCtrl.create({
message: "确认退出登录?",
buttons: [
{
text: '取消',
role: 'cancel'
},
{
text: '确定',
handler: () => {
// this.appService.ObserverHttpGet("/wisdomgroup/app/logout",null)
// .subscribe((res: Response) => {
// this.appCtrl.getRootNav().setRoot(LoginPage)
// }, error => {
// this.appService.alert('系统错误!');
// })
//退出登陆,将缓存中的用户注销,跳转到登陆页面。
this.storage.get("user").then((value) => {
console.log(value);
});
this.storage.remove("user");
this.storage.remove("userLoginInfo");
this.logoutApp();
this.appCtrl.getRootNav().setRoot(LoginPage)
}
}]
}).present();
}
//后台退出
logoutApp() {
this.appService.ObserverHttpGet("/wisdomgroup/app/logout", null)
.subscribe((res: Response) => {
let data = res.json();
}, error => {
this.appService.alert('网络异常!');
}
);
}
//版本信息
currentVersion() {
this.navCtrl.push("VersionPage");
}
//获取最新版本信息
getversion() {
//检测是否需要更新
this.appVersion.getVersionNumber().then((version: string) => {
this.version = version;
this.appUpdateService.compariVersion().subscribe(data => {
if (data.code == 200) {
if (data.latestVersion != null && data.latestVersion != version) {
this.isLatest = false;
}
}
});
}).catch(err => {
console.log('getVersionNumber:' + err);
});
}