Newer
Older
import {AlertController, IonicPage, NavController, NavParams} from 'ionic-angular';
import { AppVersion } from '@ionic-native/app-version';
import { AppUpdateService } from '../../service/appUpdateService';
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;
constructor(
public navCtrl: NavController,
public navParams: NavParams,
public appService:AppService,
private appUpdateService: AppUpdateService,
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)=>{
//保存推送开关
savePush(){
this.appService.ObserverHttpGetAdd('/wisdomgroup/modules/common/file/addAppPush/',this.pusNumber)
.subscribe(
(res)=>{}
)
}
//获取最新版本信息
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 => {
console.log('getVersionNumber:' + err);
});
}
//更新
update(){
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) => {
let data = res.json();
this.navCtrl.push('LoginPage');
}, error => {
this.appService.alert('网络异常!');
}
);