Newer
Older
import {StatusBar} from '@ionic-native/status-bar';
import {SplashScreen} from '@ionic-native/splash-screen';
import {Storage} from "@ionic/storage";
import {LoginPage} from '../pages/login/login';
import {AppVersion} from '@ionic-native/app-version';
import {AppUpdateService} from '../service/appUpdateService';
import {Keyboard} from '@ionic-native/keyboard';
import {Badge} from '@ionic-native/badge';
import {Response} from "@angular/http";
import {TabsPage} from "../pages/tabs/tabs";
constructor(platform: Platform,
public statusBar: StatusBar,
public splashScreen: SplashScreen,
alertCtrl: AlertController,
keyboard: Keyboard,
appUpdateService: AppUpdateService,
appVersion: AppVersion,
private geolocation: Geolocation,
badge: Badge,
// public navCtrl: NavController,
public storage: Storage,
public appService: AppService) {
platform.ready().then(() => {
this.splashScreen.hide();
this.statusBar.show();
this.statusBar.overlaysWebView(false);
this.statusBar.backgroundColorByHexString('#19b5ff');
this.statusBar.styleLightContent();
//检测是否需要更新
appVersion.getVersionNumber().then((version: string) => {
appUpdateService.compariVersion().subscribe(res => {
let data = res.json();
if (data.code == 200) {
if (data.latestVersion != null && data.latestVersion != version) {
appUpdateService.detectionUpgrade(data.androidDownload, true); //提示升级
}
}
});
}).catch(err => {
console.log('getVersionNumber:' + err);
});
});
loadLogin() {
this.storage.get("userLoginInfo").then((value) => {
if (value != null && value != '') {
this.user = value;
if(this.user.remember){
this.appService.ObserverHttpPost("/wisdomgroup/app/loginpost", this.user)
.subscribe((res: Response) => {
let data = res.json();
if (data["code"] == '200') {
this.storage.set('user', data.data);
this.user.userid = data.data.id;
this.storage.set('userLoginInfo', this.user);
this.rootPage = TabsPage;
} else {
this.appService.alert('手机号或密码错误!');
this.rootPage = LoginPage;
}
}, error => {