Newer
Older
import {Component} from '@angular/core';
import {AlertController, IonicPage, NavController, NavParams} from 'ionic-angular';
import {AppService} from '../../service/http.service';
import {AppVersion} from '@ionic-native/app-version';
import {AppUpdateService} from "../../service/appUpdate.service";
import {Storage} from "@ionic/storage";
import {LoginPage} from "../login/login";
@IonicPage()
@Component({
selector: 'page-version',
templateUrl: 'version.html'
})
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 storage: Storage,
private alertCtrl: AlertController) {
}
ionViewWillEnter() {
this.getversion();
this.getAppPush();
this.appUpdateService.compariVersion().subscribe(res => {
var data = res.json();
if (data.code == 200) {
this.latestVersion = data.latestVersion;
}
});
}
//获取推送开关
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) => {
}
)
}
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
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
//获取最新版本信息
getversion() {
//检测是否需要更新
this.appVersion.getVersionNumber().then((version: string) => {
this.version = version;
this.appUpdateService.compariVersion().subscribe(res => {
var data = res.json();
if (data.code == 200) {
this.latestVersion = data.latestVersion;
if (data.latestVersion != null && data.latestVersion != version) {
this.isLatest = false;
}
}
});
}).catch(err => {
});
}
//更新
update() {
if (this.isLatest) {
const alert = this.alertCtrl.create({
subTitle: '已是最新版本',
buttons: ['确定']
});
alert.present();
} else {
const confirm = this.alertCtrl.create({
message: '有最新版本,是否更新?',
buttons: [
{
text: '取消',
handler: () => {
console.log('Disagree clicked');
}
},
{
text: '确定',
handler: () => {
this.appUpdateService.downloadApp("/wisdomgroup/app/download");
}
}
]
});
confirm.present();
}
}
//后台退出
logoutApp() {
let length = this.navCtrl.length();
this.navCtrl.remove(length);
this.storage.clear();
this.appService.ObserverHttpGet("/wisdomgroup/app/logout", null)
.subscribe((res: Response) => {