Skip to content
mine.ts 4.22 KiB
Newer Older
wangqinghua's avatar
wangqinghua committed
import {Component} from '@angular/core';
import {App, NavController, AlertController, NavParams} from 'ionic-angular';
import {LoginPage} from '../../login/login';
import {AppGlobal, AppService} from '../../../service/http.service';
import {PersonInfoPage} from '../../mine/person/personInfo/personInfo';
import {MyActivityListPage} from '../../mine/myActivityList/myActivityList';
import {MyReportPage} from '../../mine/myReport/myReport';
import {OperationListPage} from '../../mine/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/appUpdate.service";
import {MyDutyPage} from "../../mine/my-duty/my-duty";
import {MySurveyPage} from "../../home/mySurvey/my-survey/my-survey";
wangqinghua's avatar
wangqinghua committed
import {TabsService} from "../tabs.service";
wangqinghua's avatar
wangqinghua committed
import {EmitService} from "../../../provide/emit.service";
import {NoticePage} from "../notice/notice";
wangqinghua's avatar
wangqinghua committed


@Component({
    selector: 'page-mine',
    templateUrl: 'mine.html',
})
export class MinePage {

wangqinghua's avatar
wangqinghua committed
    user;
wangqinghua's avatar
wangqinghua committed
    orgName: '';
    gender: object;
    version: string = '';
    isLatest: boolean = true;
    picture: string = AppGlobal.picture;
wangqinghua's avatar
wangqinghua committed
    picUrl;

    mineInfo;
wangqinghua's avatar
wangqinghua committed
    noReadNum;
wangqinghua's avatar
wangqinghua committed
    constructor(public navCtrl: NavController,
                private appCtrl: App,
                private alertCtrl: AlertController,
                public navParams: NavParams,
wangqinghua's avatar
wangqinghua committed
                public tabSer:TabsService,
wangqinghua's avatar
wangqinghua committed
                public appService: AppService,
wangqinghua's avatar
wangqinghua committed
                public emitSer:EmitService,
wangqinghua's avatar
wangqinghua committed
                public storage: Storage,public app:App,
                private appUpdateService: AppUpdateService,
                private appVersion: AppVersion) {
wangqinghua's avatar
wangqinghua committed
        // 接收发射过来的数据
        this.emitSer.eventEmit.subscribe((value: any) => {
            if(!isNaN(value)){
                this.noReadNum = value;
            }
        });
wangqinghua's avatar
wangqinghua committed
    }

    ionViewWillEnter() {
        this.user = this.storage.get("user").then((value) => {
            this.user = value;
wangqinghua's avatar
wangqinghua committed
            this.picUrl = this.user.userDetail.user.picUrl;
            console.log(value)
wangqinghua's avatar
wangqinghua committed
            this.gender = this.user.userDetail.user.gender;
        });
wangqinghua's avatar
wangqinghua committed
        this.getversion();
        this.tabSer.getUserIntegral().subscribe(
            (res)=>{
                this.mineInfo = res.data;
            }
        )
wangqinghua's avatar
wangqinghua committed
    }

wangqinghua's avatar
wangqinghua committed

wangqinghua's avatar
wangqinghua committed
    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");
    }

    //我的问卷
    mySurvey() {
        this.navCtrl.push('MySurveyPage');
    }

    //后台退出
    logoutApp() {
        this.appService.ObserverHttpGet("/wisdomgroup/app/logout", null)
            .subscribe((res: Response) => {
                    let data = res.json();
                }, error => {
                }
            );
    }

    //获取最新版本信息
    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 => {
        });
    }

    goSet() {
wangqinghua's avatar
wangqinghua committed
        // this.app.getRootNav().push('VersionPage');
        this.navCtrl.push('VersionPage');
wangqinghua's avatar
wangqinghua committed
    }

    goDuty() {
        this.navCtrl.push("MyDutyPage");
    }
wangqinghua's avatar
wangqinghua committed

    //消息提醒页面
    goToNotice(){
        this.navCtrl.push(NoticePage);
    }
wangqinghua's avatar
wangqinghua committed
}