import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { AppService } from "../../../../service/appHttpService";
import { Storage } from "@ionic/storage";
import {SurveyWritePage} from "../survey-write/survey-write";
import {SurveyResultPage} from "../survey-result/survey-result";
import {SurveyPreviewPage} from "../survey-preview/survey-preview";


@IonicPage()
@Component({
  selector: 'page-my-survey',
  templateUrl: 'my-survey.html',
})
export class MySurveyPage {

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

  ionViewDidEnter() {
    this.storage.get("user").then((res)=>{
        this.appService.ObserverHttpGetAdd('/wisdomgroup/modules/question/findQuesByUserId/',res.id)
            .subscribe((res)=>{
                this.list = [];
                const data = res.json().datalist;
              data.forEach((res)=>{
                  if(res.isAnsNum != 0){
                      this.list.push(res);
                  }
              })
            })
    });
  }


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

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

}
