import { Component, OnInit } from '@angular/core';
import { FramePageComponent } from '../../../../frame/core/page/frame.page';
import { BsModalService } from 'ngx-bootstrap/modal';
import {MsgService} from "../../../../../core/service/msg.service";

@Component({
  selector: 'app-shichang-room',
  templateUrl: './shichang-room.component.html',
  styleUrls: ['./shichang-room.component.scss']
})
export class ShichangRoomComponent extends FramePageComponent implements OnInit {

  constructor(modalService: BsModalService) {
    super(modalService);
  }

  currentStep = 'Init';
  room_id : any;
  material = [];
  array:any
  coutDown: number = 5;
  private intervalId: any;

  ngOnInit(): void {
    clearTimeout(this.intervalId);
  }

  changeCert() {
    this.requerst();
    this.intervalId = setInterval(() => {
          this.requerst();
      },this.coutDown*1000);

  }
  requerst(){
    this.AjaxService.requestArray('sc/roomviewmaterial.htm', {room_id: this.room_id}, (array) => {
      this.array = array;
      if(this.array.length>0){
        this.material=this.array[0].s01.split(',');
        this.currentStep = 'Prepare';

      }else {
        this.currentStep = 'Prepare';
        MsgService.errorToastr("没有考生！")
      }
    });
  }

  ngOnDestroy(): void {
    clearTimeout(this.intervalId);
  }


}
