import { Component, OnInit } from '@angular/core';
import {CookieService} from 'ngx-cookie-service';
import {Router} from '@angular/router';
import {WeixinReplyDetailComponent} from '../weixin-reply-detail/weixin-reply-detail.component';
import { FramePageComponent } from '../../../frame/core/page/frame.page';
import { BsModalService } from 'ngx-bootstrap/modal';
import { AjaxService } from '../../../../core/service/ajax.service';

@Component({
  selector: 'app-weixin-reply-page',
  templateUrl: './weixin-reply-page.component.html',
  styleUrls: ['./weixin-reply-page.component.scss']
})
export class WeixinReplyPageComponent extends FramePageComponent implements OnInit {

  wxDefine: any;
  constructor(private router: Router, private cookies: CookieService,  modalService: BsModalService) {
    super(modalService);
    // 获取缓存中的微信编号
    const wx_id = this.cookies.get('CurrentWxId');
    if (wx_id !== undefined && wx_id.length > 0 ) {
      // 去获取
      AjaxService.requestEntity('weixin/define/find.htm', {wx_id: wx_id}, (entity) => {
        this.wxDefine = entity;
        setTimeout( () => {
          if (this.pager) {
            this.pager.reload({wx_id: this.wxDefine.wx_id});
          }
        }, 1);
      });
    } else {
      this.router.navigate(['/weixin/define/page']) ;
    }
    this.modalComponent = WeixinReplyDetailComponent;
  }


  ngOnInit() {
  }

}
