import { Component } from '@angular/core';
import {IonicPage, LoadingController, NavController, NavParams} from 'ionic-angular';
import {AppService} from "../../../../service/appHttpService";
import {Storage} from "@ionic/storage";

@IonicPage()
@Component({
  selector: 'page-survery',
  templateUrl: 'survery.html',
})
export class SurveryPage {

    userId;
    list = [];
    loading;
    constructor(public navCtrl: NavController, public navParams: NavParams,
                public appService: AppService,public storage: Storage,
                public loadingCtrl:LoadingController) {}

                ionViewDidLoad(){
                    this.loading = this.loadingCtrl.create({
                        content: '请稍等...',
                        // dismissOnPageChange: true,
                        enableBackdropDismiss: true
                    });
                    this.loading.present();
                    this.getList();
                }

    ionViewDidEnter() {
        this.getList();
    }

    getList(){
        this.storage.get("user").then((res)=>{
            this.appService.ObserverHttpGetAdd('/wisdomgroup/modules/question/findQuesByUserId/',res.id)
                .subscribe((res)=>{
                    if(this.loading){
                        this.loading.dismiss();
                    }
                    this.list = res.json().datalist;
                })
        });
    }

    getSurveyList(){
        const userId = {};
        console.log( this.userId);
    }

    //填写问卷
    geToWrite(item){
        this.navCtrl.push('SurveyWritePage',{item:item});
    }

    //查看问卷结果
    goToResult(item){
        this.navCtrl.push('SurveyPreviewPage',{item:item});
    }

}
